Moved intent reading into loadIntentData()

This commit is contained in:
GilesMunn 2022-11-05 19:16:28 +00:00
parent a2c1c9121a
commit 7a31d9d931
2 changed files with 11 additions and 16 deletions

View File

@ -108,17 +108,6 @@ class MainActivity : BaseActivity() {
// navigate to the default fragment
navController.navigate(startFragmentId)
// open appropriate fragment from shortcut
when (intent.extras?.getString("fragmentToOpen")) {
"subscriptions" ->
navController.navigate(R.id.subscriptionsFragment)
"library" ->
navController.navigate(R.id.libraryFragment)
else -> {
return
}
}
binding.bottomNav.setOnApplyWindowInsetsListener(null)
binding.bottomNav.setOnItemSelectedListener {
@ -360,6 +349,12 @@ class MainActivity : BaseActivity() {
intent?.getStringExtra(IntentData.videoId)?.let {
loadVideo(it, intent?.getLongExtra(IntentData.timeStamp, 0L))
}
when (intent?.getStringExtra("fragmentToOpen")) {
"subscriptions" ->
navController.navigate(R.id.subscriptionsFragment)
"library" ->
navController.navigate(R.id.libraryFragment)
}
}
private fun loadVideo(videoId: String, timeStamp: Long?) {

View File

@ -9,7 +9,7 @@
android:shortcutShortLabel="@string/startpage">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.github.libretube.debug"
android:targetPackage="com.github.libretube"
android:targetClass="com.github.libretube.ui.activities.MainActivity" />
</shortcut>
<shortcut
@ -19,9 +19,9 @@
android:shortcutShortLabel="@string/subscriptions">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.github.libretube.debug"
android:targetPackage="com.github.libretube"
android:targetClass="com.github.libretube.ui.activities.MainActivity">
<extra android:name="fragmentToOpen" android:value="subscriptions"/>
<extra android:name="fragmentToOpen" android:value="subscriptions" />
</intent>
</shortcut>
<shortcut
@ -31,9 +31,9 @@
android:shortcutShortLabel="@string/library">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="com.github.libretube.debug"
android:targetPackage="com.github.libretube"
android:targetClass="com.github.libretube.ui.activities.MainActivity">
<extra android:name="fragmentToOpen" android:value="library"/>
<extra android:name="fragmentToOpen" android:value="library" />
</intent>
</shortcut>
</shortcuts>