Skip to content

Commit

Permalink
Fix: Fixed the goBackToSettings function.
Browse files Browse the repository at this point in the history
  • Loading branch information
CreativeCodeCat committed Nov 29, 2024
1 parent 74b021c commit 59e0ded
Showing 1 changed file with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.NavOptions
import androidx.navigation.findNavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
Expand Down Expand Up @@ -285,19 +285,51 @@ class MainActivity : AppCompatActivity() {

private fun goBackToSettings() {
navController = findNavController(R.id.nav_host_fragment_content_main)
val fragmentManager: FragmentManager = supportFragmentManager
when (navController.currentDestination?.id) {
R.id.SettingsFragment,
R.id.SettingsFeaturesFragment,
R.id.SettingsLookFeelFragment,
R.id.SettingsAdvancedFragment,
R.id.FavoriteFragment,
R.id.HiddenFragment,
R.id.SettingsAdvancedFragment -> {
fragmentManager.popBackStack()
R.id.HiddenFragment -> {
val actionTypeNavOptions: NavOptions? =
if (preferenceHelper.disableAnimations) null
else appHelper.getActionType(Constants.Swipe.Up)

Handler(Looper.getMainLooper()).post {
navController.navigate(
R.id.SettingsFragment,
null,
actionTypeNavOptions
)
}
}

R.id.SettingsFragment -> {
val actionTypeNavOptions: NavOptions? =
if (preferenceHelper.disableAnimations) null
else appHelper.getActionType(Constants.Swipe.Up)

Handler(Looper.getMainLooper()).post {
navController.navigate(
R.id.HomeFragment,
null,
actionTypeNavOptions
)
}
}

else -> {
navController.navigate(R.id.HomeFragment)
val actionTypeNavOptions: NavOptions? =
if (preferenceHelper.disableAnimations) null
else appHelper.getActionType(Constants.Swipe.Up)

Handler(Looper.getMainLooper()).post {
navController.navigate(
R.id.HomeFragment,
null,
actionTypeNavOptions
)
}
}
}
}
Expand Down

0 comments on commit 59e0ded

Please sign in to comment.