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 // navigate to the default fragment
navController.navigate(startFragmentId) 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.setOnApplyWindowInsetsListener(null)
binding.bottomNav.setOnItemSelectedListener { binding.bottomNav.setOnItemSelectedListener {
@ -360,6 +349,12 @@ class MainActivity : BaseActivity() {
intent?.getStringExtra(IntentData.videoId)?.let { intent?.getStringExtra(IntentData.videoId)?.let {
loadVideo(it, intent?.getLongExtra(IntentData.timeStamp, 0L)) 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?) { private fun loadVideo(videoId: String, timeStamp: Long?) {

View File

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