mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-06 03:50:23 +02:00
Remove ViewPagers
This commit is contained in:
parent
375afef17b
commit
762f62cfac
9 changed files with 80 additions and 217 deletions
|
@ -20,10 +20,10 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import androidx.viewpager.widget.ViewPager
|
|
||||||
import io.timelimit.android.R
|
import io.timelimit.android.R
|
||||||
import io.timelimit.android.data.model.Category
|
import io.timelimit.android.data.model.Category
|
||||||
import io.timelimit.android.data.model.User
|
import io.timelimit.android.data.model.User
|
||||||
|
@ -35,6 +35,11 @@ import io.timelimit.android.logic.DefaultAppLogic
|
||||||
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
||||||
import io.timelimit.android.ui.main.AuthenticationFab
|
import io.timelimit.android.ui.main.AuthenticationFab
|
||||||
import io.timelimit.android.ui.main.FragmentWithCustomTitle
|
import io.timelimit.android.ui.main.FragmentWithCustomTitle
|
||||||
|
import io.timelimit.android.ui.manage.category.apps.CategoryAppsFragment
|
||||||
|
import io.timelimit.android.ui.manage.category.blocked_times.BlockedTimeAreasFragment
|
||||||
|
import io.timelimit.android.ui.manage.category.settings.CategorySettingsFragment
|
||||||
|
import io.timelimit.android.ui.manage.category.timelimit_rules.CategoryTimeLimitRulesFragment
|
||||||
|
import io.timelimit.android.ui.manage.category.usagehistory.UsageHistoryFragment
|
||||||
import kotlinx.android.synthetic.main.fragment_manage_category.*
|
import kotlinx.android.synthetic.main.fragment_manage_category.*
|
||||||
|
|
||||||
class ManageCategoryFragment : Fragment(), FragmentWithCustomTitle {
|
class ManageCategoryFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
|
@ -47,7 +52,6 @@ class ManageCategoryFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
private val user: LiveData<User?> by lazy {
|
private val user: LiveData<User?> by lazy {
|
||||||
logic.database.user().getUserByIdLive(params.childId)
|
logic.database.user().getUserByIdLive(params.childId)
|
||||||
}
|
}
|
||||||
private val adapter: PagerAdapter by lazy { PagerAdapter(childFragmentManager, params) }
|
|
||||||
private val activity: ActivityViewModelHolder by lazy { getActivity() as ActivityViewModelHolder }
|
private val activity: ActivityViewModelHolder by lazy { getActivity() as ActivityViewModelHolder }
|
||||||
private var wereViewsCreated = false
|
private var wereViewsCreated = false
|
||||||
|
|
||||||
|
@ -70,43 +74,28 @@ class ManageCategoryFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
|
|
||||||
val navigation = Navigation.findNavController(view)
|
val navigation = Navigation.findNavController(view)
|
||||||
|
|
||||||
pager.adapter = adapter
|
bottom_navigation_view.setOnNavigationItemReselectedListener { /* ignore */ }
|
||||||
|
bottom_navigation_view.setOnNavigationItemSelectedListener { menuItem ->
|
||||||
bottom_navigation_view.setOnNavigationItemSelectedListener {
|
childFragmentManager.beginTransaction()
|
||||||
menuItem ->
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||||
|
.replace(R.id.container, when(menuItem.itemId) {
|
||||||
pager?.currentItem = when(menuItem.itemId) {
|
R.id.manage_category_tab_apps -> CategoryAppsFragment.newInstance(params)
|
||||||
R.id.manage_category_tab_apps -> 0
|
R.id.manage_category_tab_time_limit_rules -> CategoryTimeLimitRulesFragment.newInstance(params)
|
||||||
R.id.manage_category_tab_time_limit_rules -> 1
|
R.id.manage_category_tab_blocked_time_areas -> BlockedTimeAreasFragment.newInstance(params)
|
||||||
R.id.manage_category_tab_blocked_time_areas -> 2
|
R.id.manage_category_tab_usage_log -> UsageHistoryFragment.newInstance(params)
|
||||||
R.id.manage_category_tab_usage_log -> 3
|
R.id.manage_category_tab_settings -> CategorySettingsFragment.newInstance(params)
|
||||||
R.id.manage_category_tab_settings -> 4
|
else -> throw IllegalStateException()
|
||||||
else -> throw IllegalStateException()
|
})
|
||||||
}
|
.commit()
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pager.addOnPageChangeListener(object: ViewPager.OnPageChangeListener {
|
if (childFragmentManager.findFragmentById(R.id.container) == null) {
|
||||||
override fun onPageScrollStateChanged(state: Int) {
|
childFragmentManager.beginTransaction()
|
||||||
// ignore
|
.replace(R.id.container, CategoryAppsFragment.newInstance(params))
|
||||||
}
|
.commit()
|
||||||
|
}
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
|
||||||
bottom_navigation_view.selectedItemId = when(position) {
|
|
||||||
0 -> R.id.manage_category_tab_apps
|
|
||||||
1 -> R.id.manage_category_tab_time_limit_rules
|
|
||||||
2 -> R.id.manage_category_tab_blocked_time_areas
|
|
||||||
3 -> R.id.manage_category_tab_usage_log
|
|
||||||
4 -> R.id.manage_category_tab_settings
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!wereViewsCreated) {
|
if (!wereViewsCreated) {
|
||||||
wereViewsCreated = true
|
wereViewsCreated = true
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* TimeLimit Copyright <C> 2019 Jonas Lochmann
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation version 3 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package io.timelimit.android.ui.manage.category
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.FragmentManager
|
|
||||||
import androidx.fragment.app.FragmentStatePagerAdapter
|
|
||||||
import io.timelimit.android.ui.manage.category.apps.CategoryAppsFragment
|
|
||||||
import io.timelimit.android.ui.manage.category.blocked_times.BlockedTimeAreasFragment
|
|
||||||
import io.timelimit.android.ui.manage.category.settings.CategorySettingsFragment
|
|
||||||
import io.timelimit.android.ui.manage.category.timelimit_rules.CategoryTimeLimitRulesFragment
|
|
||||||
import io.timelimit.android.ui.manage.category.usagehistory.UsageHistoryFragment
|
|
||||||
|
|
||||||
class PagerAdapter(fragmentManager: FragmentManager, private val params: ManageCategoryFragmentArgs): FragmentStatePagerAdapter(fragmentManager) {
|
|
||||||
override fun getCount() = 5
|
|
||||||
|
|
||||||
override fun getItem(position: Int): Fragment = when (position) {
|
|
||||||
0 -> CategoryAppsFragment.newInstance(params)
|
|
||||||
1 -> CategoryTimeLimitRulesFragment.newInstance(params)
|
|
||||||
2 -> BlockedTimeAreasFragment.newInstance(params)
|
|
||||||
3 -> UsageHistoryFragment.newInstance(params)
|
|
||||||
4 -> CategorySettingsFragment.newInstance(params)
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,10 +20,10 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import androidx.viewpager.widget.ViewPager
|
|
||||||
import io.timelimit.android.R
|
import io.timelimit.android.R
|
||||||
import io.timelimit.android.data.model.User
|
import io.timelimit.android.data.model.User
|
||||||
import io.timelimit.android.data.model.UserType
|
import io.timelimit.android.data.model.UserType
|
||||||
|
@ -34,11 +34,13 @@ import io.timelimit.android.logic.DefaultAppLogic
|
||||||
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
||||||
import io.timelimit.android.ui.main.AuthenticationFab
|
import io.timelimit.android.ui.main.AuthenticationFab
|
||||||
import io.timelimit.android.ui.main.FragmentWithCustomTitle
|
import io.timelimit.android.ui.main.FragmentWithCustomTitle
|
||||||
|
import io.timelimit.android.ui.manage.child.advanced.ManageChildAdvancedFragment
|
||||||
|
import io.timelimit.android.ui.manage.child.apps.ChildAppsFragment
|
||||||
|
import io.timelimit.android.ui.manage.child.category.ManageChildCategoriesFragment
|
||||||
import kotlinx.android.synthetic.main.fragment_manage_child.*
|
import kotlinx.android.synthetic.main.fragment_manage_child.*
|
||||||
|
|
||||||
class ManageChildFragment : Fragment(), FragmentWithCustomTitle {
|
class ManageChildFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
private val params: ManageChildFragmentArgs by lazy { ManageChildFragmentArgs.fromBundle(arguments!!) }
|
private val params: ManageChildFragmentArgs by lazy { ManageChildFragmentArgs.fromBundle(arguments!!) }
|
||||||
private val adapter: PagerAdapter by lazy { PagerAdapter(childFragmentManager, params) }
|
|
||||||
private val logic: AppLogic by lazy { DefaultAppLogic.with(context!!) }
|
private val logic: AppLogic by lazy { DefaultAppLogic.with(context!!) }
|
||||||
private val child: LiveData<User?> by lazy { logic.database.user().getUserByIdLive(params.childId) }
|
private val child: LiveData<User?> by lazy { logic.database.user().getUserByIdLive(params.childId) }
|
||||||
private val activity: ActivityViewModelHolder by lazy { getActivity() as ActivityViewModelHolder }
|
private val activity: ActivityViewModelHolder by lazy { getActivity() as ActivityViewModelHolder }
|
||||||
|
@ -74,39 +76,26 @@ class ManageChildFragment : Fragment(), FragmentWithCustomTitle {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pager.adapter = adapter
|
bottom_navigation_view.setOnNavigationItemReselectedListener { /* ignore */ }
|
||||||
|
bottom_navigation_view.setOnNavigationItemSelectedListener { menuItem ->
|
||||||
bottom_navigation_view.setOnNavigationItemSelectedListener {
|
childFragmentManager.beginTransaction()
|
||||||
menuItem ->
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||||
|
.replace(R.id.container, when (menuItem.itemId) {
|
||||||
pager?.currentItem = when (menuItem.itemId) {
|
R.id.manage_child_tab_categories -> ManageChildCategoriesFragment.newInstance(params)
|
||||||
R.id.manage_child_tab_categories -> 0
|
R.id.manage_child_tab_apps -> ChildAppsFragment.newInstance(params)
|
||||||
R.id.manage_child_tab_apps -> 1
|
R.id.manage_child_tab_manage -> ManageChildAdvancedFragment.newInstance(params)
|
||||||
R.id.manage_child_tab_manage -> 2
|
else -> throw IllegalStateException()
|
||||||
else -> throw IllegalStateException()
|
})
|
||||||
}
|
.commit()
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pager.addOnPageChangeListener(object: ViewPager.OnPageChangeListener {
|
if (childFragmentManager.findFragmentById(R.id.container) == null) {
|
||||||
override fun onPageScrollStateChanged(state: Int) {
|
childFragmentManager.beginTransaction()
|
||||||
// ignore
|
.replace(R.id.container, ManageChildCategoriesFragment.newInstance(params))
|
||||||
}
|
.commit()
|
||||||
|
}
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
|
||||||
bottom_navigation_view.selectedItemId = when(position) {
|
|
||||||
0 -> R.id.manage_child_tab_categories
|
|
||||||
1 -> R.id.manage_child_tab_apps
|
|
||||||
2 -> R.id.manage_child_tab_manage
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCustomTitle() = child.map { it?.name }
|
override fun getCustomTitle() = child.map { it?.name }
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* TimeLimit Copyright <C> 2019 Jonas Lochmann
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation version 3 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package io.timelimit.android.ui.manage.child
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentManager
|
|
||||||
import androidx.fragment.app.FragmentStatePagerAdapter
|
|
||||||
import io.timelimit.android.ui.manage.child.advanced.ManageChildAdvancedFragment
|
|
||||||
import io.timelimit.android.ui.manage.child.apps.ChildAppsFragment
|
|
||||||
import io.timelimit.android.ui.manage.child.category.ManageChildCategoriesFragment
|
|
||||||
|
|
||||||
class PagerAdapter(fragmentManager: FragmentManager, private val params: ManageChildFragmentArgs): FragmentStatePagerAdapter(fragmentManager) {
|
|
||||||
override fun getCount() = 3
|
|
||||||
|
|
||||||
override fun getItem(position: Int) = when(position) {
|
|
||||||
0 -> ManageChildCategoriesFragment.newInstance(params)
|
|
||||||
1 -> ChildAppsFragment.newInstance(params)
|
|
||||||
2 -> ManageChildAdvancedFragment.newInstance(params)
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,11 +20,11 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.Navigation
|
import androidx.navigation.Navigation
|
||||||
import androidx.viewpager.widget.ViewPager
|
|
||||||
import io.timelimit.android.BuildConfig
|
import io.timelimit.android.BuildConfig
|
||||||
import io.timelimit.android.R
|
import io.timelimit.android.R
|
||||||
import io.timelimit.android.coroutines.runAsync
|
import io.timelimit.android.coroutines.runAsync
|
||||||
|
@ -39,15 +39,17 @@ import io.timelimit.android.logic.DefaultAppLogic
|
||||||
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
import io.timelimit.android.ui.main.ActivityViewModelHolder
|
||||||
import io.timelimit.android.ui.main.AuthenticationFab
|
import io.timelimit.android.ui.main.AuthenticationFab
|
||||||
import io.timelimit.android.ui.manage.device.add.AddDeviceFragment
|
import io.timelimit.android.ui.manage.device.add.AddDeviceFragment
|
||||||
|
import io.timelimit.android.ui.overview.about.AboutFragment
|
||||||
import io.timelimit.android.ui.overview.about.AboutFragmentParentHandlers
|
import io.timelimit.android.ui.overview.about.AboutFragmentParentHandlers
|
||||||
import io.timelimit.android.ui.overview.overview.CanNotAddDevicesInLocalModeDialogFragmentListener
|
import io.timelimit.android.ui.overview.overview.CanNotAddDevicesInLocalModeDialogFragmentListener
|
||||||
|
import io.timelimit.android.ui.overview.overview.OverviewFragment
|
||||||
import io.timelimit.android.ui.overview.overview.OverviewFragmentParentHandlers
|
import io.timelimit.android.ui.overview.overview.OverviewFragmentParentHandlers
|
||||||
|
import io.timelimit.android.ui.overview.uninstall.UninstallFragment
|
||||||
import kotlinx.android.synthetic.main.fragment_main.*
|
import kotlinx.android.synthetic.main.fragment_main.*
|
||||||
|
|
||||||
class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentParentHandlers,
|
class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentParentHandlers,
|
||||||
CanNotAddDevicesInLocalModeDialogFragmentListener {
|
CanNotAddDevicesInLocalModeDialogFragmentListener {
|
||||||
|
|
||||||
private val adapter: PagerAdapter by lazy { PagerAdapter(childFragmentManager) }
|
|
||||||
private val logic: AppLogic by lazy { DefaultAppLogic.with(context!!) }
|
private val logic: AppLogic by lazy { DefaultAppLogic.with(context!!) }
|
||||||
private lateinit var navigation: NavController
|
private lateinit var navigation: NavController
|
||||||
private val showAuthButtonLive = MutableLiveData<Boolean>()
|
private val showAuthButtonLive = MutableLiveData<Boolean>()
|
||||||
|
@ -84,7 +86,7 @@ class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentPa
|
||||||
}
|
}
|
||||||
}.observe(this, Observer { shouldShowSetup ->
|
}.observe(this, Observer { shouldShowSetup ->
|
||||||
if (shouldShowSetup == true) {
|
if (shouldShowSetup == true) {
|
||||||
pager.post {
|
fab.post {
|
||||||
navigation.safeNavigate(
|
navigation.safeNavigate(
|
||||||
MainFragmentDirections.actionOverviewFragmentToSetupTermsFragment(),
|
MainFragmentDirections.actionOverviewFragmentToSetupTermsFragment(),
|
||||||
R.id.overviewFragment
|
R.id.overviewFragment
|
||||||
|
@ -108,52 +110,39 @@ class MainFragment : Fragment(), OverviewFragmentParentHandlers, AboutFragmentPa
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pager.adapter = adapter
|
fun updateShowFab(selectedItemId: Int) {
|
||||||
|
showAuthButtonLive.value = when (selectedItemId) {
|
||||||
bottom_navigation_view.setOnNavigationItemSelectedListener {
|
R.id.main_tab_overview -> true
|
||||||
menuItem ->
|
R.id.main_tab_uninstall -> !BuildConfig.storeCompilant
|
||||||
|
R.id.main_tab_about -> false
|
||||||
pager?.currentItem = when(menuItem.itemId) {
|
|
||||||
R.id.main_tab_overview -> 0
|
|
||||||
R.id.main_tab_uninstall -> 1
|
|
||||||
R.id.main_tab_about -> 2
|
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bottom_navigation_view.setOnNavigationItemReselectedListener { /* ignore */ }
|
||||||
|
bottom_navigation_view.setOnNavigationItemSelectedListener { menuItem ->
|
||||||
|
childFragmentManager.beginTransaction()
|
||||||
|
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
|
||||||
|
.replace(R.id.container, when(menuItem.itemId) {
|
||||||
|
R.id.main_tab_overview -> OverviewFragment()
|
||||||
|
R.id.main_tab_uninstall -> UninstallFragment()
|
||||||
|
R.id.main_tab_about -> AboutFragment()
|
||||||
|
else -> throw IllegalStateException()
|
||||||
|
})
|
||||||
|
.commit()
|
||||||
|
|
||||||
|
updateShowFab(menuItem.itemId)
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateShowFab(selectedPage: Int) {
|
if (childFragmentManager.findFragmentById(R.id.container) == null) {
|
||||||
showAuthButtonLive.value = when (selectedPage) {
|
childFragmentManager.beginTransaction()
|
||||||
0 -> true
|
.replace(R.id.container, OverviewFragment())
|
||||||
1 -> !BuildConfig.storeCompilant
|
.commit()
|
||||||
2 -> false
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateShowFab(pager.currentItem)
|
updateShowFab(bottom_navigation_view.selectedItemId)
|
||||||
|
|
||||||
pager.addOnPageChangeListener(object: ViewPager.OnPageChangeListener {
|
|
||||||
override fun onPageScrollStateChanged(state: Int) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
|
||||||
updateShowFab(position)
|
|
||||||
|
|
||||||
bottom_navigation_view.selectedItemId = when(pager.currentItem) {
|
|
||||||
0 -> R.id.main_tab_overview
|
|
||||||
1 -> R.id.main_tab_uninstall
|
|
||||||
2 -> R.id.main_tab_about
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun openAddDeviceScreen() {
|
override fun openAddDeviceScreen() {
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* TimeLimit Copyright <C> 2019 Jonas Lochmann
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation version 3 of the License.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package io.timelimit.android.ui.overview.main
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentManager
|
|
||||||
import androidx.fragment.app.FragmentStatePagerAdapter
|
|
||||||
import io.timelimit.android.ui.overview.about.AboutFragment
|
|
||||||
import io.timelimit.android.ui.overview.overview.OverviewFragment
|
|
||||||
import io.timelimit.android.ui.overview.uninstall.UninstallFragment
|
|
||||||
|
|
||||||
class PagerAdapter(fragmentManager: FragmentManager): FragmentStatePagerAdapter(fragmentManager) {
|
|
||||||
override fun getCount() = 3
|
|
||||||
|
|
||||||
override fun getItem(position: Int) = when(position) {
|
|
||||||
0 -> OverviewFragment()
|
|
||||||
1 -> UninstallFragment()
|
|
||||||
2 -> AboutFragment()
|
|
||||||
else -> throw IllegalStateException()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,8 +25,8 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="0dp">
|
android:layout_height="0dp">
|
||||||
|
|
||||||
<androidx.viewpager.widget.ViewPager
|
<FrameLayout
|
||||||
android:id="@+id/pager"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="0dp">
|
android:layout_height="0dp">
|
||||||
|
|
||||||
<androidx.viewpager.widget.ViewPager
|
<FrameLayout
|
||||||
android:id="@+id/pager"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_height="0dp">
|
android:layout_height="0dp">
|
||||||
|
|
||||||
<androidx.viewpager.widget.ViewPager
|
<FrameLayout
|
||||||
android:id="@+id/pager"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue