Skip to content

Commit

Permalink
fix: forgotten uncle onRestart (#244)
Browse files Browse the repository at this point in the history
* fix: forgotten uncle onRestart

It functions a lot like onResume, but assumes that onCreate ran and the user navigated away from the activity completely.

* fix: don't change to the current tab
  • Loading branch information
TwistedUmbrellaX authored Mar 14, 2024
1 parent f0040b8 commit 41eea66
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions app/src/main/java/ani/dantotsu/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.SharedPreferenceBooleanLiveData
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.util.Logger
import com.google.android.material.snackbar.BaseTransientBottomBar
import com.google.android.material.snackbar.Snackbar
import eu.kanade.domain.source.service.SourcePreferences
Expand Down Expand Up @@ -208,6 +207,7 @@ class MainActivity : AppCompatActivity() {

binding.root.doOnAttach {
initActivity(this)
window.navigationBarColor = getColor(android.R.color.transparent)
selectedOption = if (fragment != null) {
when (fragment) {
AnimeFragment::class.java.name -> 0
Expand Down Expand Up @@ -272,12 +272,14 @@ class MainActivity : AppCompatActivity() {
mainViewPager.setCurrentItem(newIndex, false)
}
})
navbar.selectTabAt(selectedOption)
mainViewPager.post {
mainViewPager.setCurrentItem(
selectedOption,
false
)
if (mainViewPager.getCurrentItem() != selectedOption) {
navbar.selectTabAt(selectedOption)
mainViewPager.post {
mainViewPager.setCurrentItem(
selectedOption,
false
)
}
}
} else {
binding.mainProgressBar.visibility = View.GONE
Expand Down Expand Up @@ -355,9 +357,8 @@ class MainActivity : AppCompatActivity() {
}
}

override fun onResume() {
super.onResume()
initActivity(this)
override fun onRestart() {
super.onRestart()
window.navigationBarColor = getColor(android.R.color.transparent)
}

Expand Down

0 comments on commit 41eea66

Please sign in to comment.