Fixed: Reader screen was showing twice when pressing the back button after opening a page from the history, bookmarks, or notes screens in custom apps.

This commit is contained in:
MohitMaliFtechiz 2024-10-29 15:16:33 +05:30
parent d3f40f2219
commit 5a47a7ba94

View File

@ -40,6 +40,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.NavDirections
import androidx.navigation.NavOptions
import com.google.android.material.navigation.NavigationView
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -393,6 +394,10 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
navController.navigate(fragmentId, bundle)
}
fun navigate(fragmentId: Int, bundle: Bundle, navOptions: NavOptions) {
navController.navigate(fragmentId, bundle, navOptions)
}
private fun openSettings() {
handleDrawerOnNavigation()
navigate(settingsFragmentResId)
@ -435,13 +440,18 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
if (zimReaderSource != null) {
zimFileUri = zimReaderSource.toDatabase()
}
val navOptions = NavOptions.Builder()
.setLaunchSingleTop(true)
.setPopUpTo(readerFragmentResId, inclusive = true)
.build()
navigate(
readerFragmentResId,
bundleOf(
PAGE_URL_KEY to pageUrl,
ZIM_FILE_URI_KEY to zimFileUri,
SHOULD_OPEN_IN_NEW_TAB to shouldOpenInNewTab
)
),
navOptions
)
}