Fixed MainActivity restart when opening activity from notification & widget
This commit is contained in:
parent
367718fadd
commit
56100cab0a
4 changed files with 13 additions and 10 deletions
|
@ -38,7 +38,8 @@
|
||||||
android:name=".activities.MainActivity"
|
android:name=".activities.MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/SplashTheme">
|
android:theme="@style/SplashTheme"
|
||||||
|
android:launchMode="singleTop">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<action android:name="android.intent.action.MUSIC_PLAYER" />
|
<action android:name="android.intent.action.MUSIC_PLAYER" />
|
||||||
|
|
|
@ -129,15 +129,15 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
||||||
override fun onSupportNavigateUp(): Boolean =
|
override fun onSupportNavigateUp(): Boolean =
|
||||||
findNavController(R.id.fragment_container).navigateUp()
|
findNavController(R.id.fragment_container).navigateUp()
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
super.onResume()
|
super.onNewIntent(intent)
|
||||||
PreferenceUtil.registerOnSharedPreferenceChangedListener(this)
|
PreferenceUtil.registerOnSharedPreferenceChangedListener(this)
|
||||||
val expand = extra<Boolean>(EXPAND_PANEL).value ?: false
|
val expand = intent?.extra<Boolean>(EXPAND_PANEL)?.value ?: false
|
||||||
if (expand && PreferenceUtil.isExpandPanel) {
|
if (expand && PreferenceUtil.isExpandPanel) {
|
||||||
fromNotification = true
|
fromNotification = true
|
||||||
slidingPanel.bringToFront()
|
slidingPanel.bringToFront()
|
||||||
expandPanel()
|
expandPanel()
|
||||||
intent.removeExtra(EXPAND_PANEL)
|
intent?.removeExtra(EXPAND_PANEL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
*/
|
*/
|
||||||
package code.name.monkey.retromusic.extensions
|
package code.name.monkey.retromusic.extensions
|
||||||
|
|
||||||
import android.R
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.content.Intent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.annotation.DimenRes
|
import androidx.annotation.DimenRes
|
||||||
|
@ -33,6 +33,11 @@ inline fun <reified T : Any> Activity.extra(key: String, default: T? = null) = l
|
||||||
if (value is T) value else default
|
if (value is T) value else default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun <reified T : Any> Intent.extra(key: String, default: T? = null) = lazy {
|
||||||
|
val value = extras?.get(key)
|
||||||
|
if (value is T) value else default
|
||||||
|
}
|
||||||
|
|
||||||
inline fun <reified T : Any> Activity.extraNotNull(key: String, default: T? = null) = lazy {
|
inline fun <reified T : Any> Activity.extraNotNull(key: String, default: T? = null) = lazy {
|
||||||
val value = intent?.extras?.get(key)
|
val value = intent?.extras?.get(key)
|
||||||
requireNotNull(if (value is T) value else default) { key }
|
requireNotNull(if (value is T) value else default) { key }
|
||||||
|
@ -42,4 +47,4 @@ fun Activity.dip(@DimenRes id: Int): Int {
|
||||||
return resources.getDimensionPixelSize(id)
|
return resources.getDimensionPixelSize(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline val Activity.rootView: View get() = findViewById<ViewGroup>(R.id.content).getChildAt(0)
|
inline val Activity.rootView: View get() = findViewById<ViewGroup>(android.R.id.content).getChildAt(0)
|
|
@ -1,20 +1,17 @@
|
||||||
package code.name.monkey.retromusic.util
|
package code.name.monkey.retromusic.util
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.content.ContentUris
|
import android.content.ContentUris
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.provider.BaseColumns
|
import android.provider.BaseColumns
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue