Prevent potential crashes after introducing errors

This commit is contained in:
EdgarPi 2024-07-23 23:06:44 +02:00
parent 4f833ebd90
commit 0085177067
2 changed files with 7 additions and 4 deletions

View file

@ -576,7 +576,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
} }
//private var mCastSession: CastSession? = null //private var mCastSession: CastSession? = null
lateinit var mSessionManager: SessionManager private var mSessionManager: SessionManager? = null
private val mSessionManagerListener: SessionManagerListener<Session> by lazy { SessionManagerListenerImpl() } private val mSessionManagerListener: SessionManagerListener<Session> by lazy { SessionManagerListenerImpl() }
private inner class SessionManagerListenerImpl : SessionManagerListener<Session> { private inner class SessionManagerListenerImpl : SessionManagerListener<Session> {
@ -616,8 +616,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
setActivityInstance(this) setActivityInstance(this)
try { try {
if (isCastApiAvailable()) { if (isCastApiAvailable()) {
//mCastSession = mSessionManager.currentCastSession mSessionManager?.addSessionManagerListener(mSessionManagerListener)
mSessionManager.addSessionManagerListener(mSessionManagerListener)
} }
} catch (e: Exception) { } catch (e: Exception) {
logError(e) logError(e)
@ -633,7 +632,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
} }
try { try {
if (isCastApiAvailable()) { if (isCastApiAvailable()) {
mSessionManager.removeSessionManagerListener(mSessionManagerListener) mSessionManager?.removeSessionManagerListener(mSessionManagerListener)
//mCastSession = null //mCastSession = null
} }
} catch (e: Exception) { } catch (e: Exception) {

View file

@ -68,6 +68,10 @@ abstract class Plugin {
*/ */
var resources: Resources? = null var resources: Resources? = null
/** Full file path to the plugin. */ /** Full file path to the plugin. */
@Deprecated("Renamed to `filename` to follow conventions", replaceWith = ReplaceWith("filename"))
var __filename: String?
get() = filename
set(value) {filename = value}
var filename: String? = null var filename: String? = null
/** /**