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
|
@ -129,15 +129,15 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
override fun onSupportNavigateUp(): Boolean =
|
||||
findNavController(R.id.fragment_container).navigateUp()
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
PreferenceUtil.registerOnSharedPreferenceChangedListener(this)
|
||||
val expand = extra<Boolean>(EXPAND_PANEL).value ?: false
|
||||
val expand = intent?.extra<Boolean>(EXPAND_PANEL)?.value ?: false
|
||||
if (expand && PreferenceUtil.isExpandPanel) {
|
||||
fromNotification = true
|
||||
slidingPanel.bringToFront()
|
||||
expandPanel()
|
||||
intent.removeExtra(EXPAND_PANEL)
|
||||
intent?.removeExtra(EXPAND_PANEL)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import android.R
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
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
|
||||
}
|
||||
|
||||
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 {
|
||||
val value = intent?.extras?.get(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)
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.ContentUris
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.provider.BaseColumns
|
||||
import android.provider.MediaStore
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue