diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-20 14:59:37 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-09-20 15:01:35 +0200 |
commit | d5c07374ff97fe425371452acde32445bd2fd3bc (patch) | |
tree | 858e6c0f334df2989392cb0e39cdf3fb4db7d155 /ui/src/main/java/com/wireguard/android | |
parent | 378575236458a19f0d986c76cc153bdc66c8ecbe (diff) |
BaseFragment: avoid using requireContext() in permission result callback
java.lang.IllegalStateException:
at androidx.fragment.app.Fragment.requireContext (Fragment.java:17)
at com.wireguard.android.fragment.BaseFragment$setTunnelStateWithPermissionsResult$1.invokeSuspend (BaseFragment.java:4)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (BaseContinuationImpl.java:2)
at kotlinx.coroutines.UndispatchedCoroutine.afterResume (UndispatchedCoroutine.java:19)
at kotlinx.coroutines.AbstractCoroutine.resumeWith (AbstractCoroutine.java:13)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (BaseContinuationImpl.java:2)
at kotlinx.coroutines.UndispatchedCoroutine.afterResume (UndispatchedCoroutine.java:19)
at kotlinx.coroutines.AbstractCoroutine.resumeWith (AbstractCoroutine.java:13)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (BaseContinuationImpl.java:2)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.java:2)
at android.os.Handler.handleCallback (Handler.java:790)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:7025)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt index 7c588c1a..10239e6e 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/BaseFragment.kt @@ -92,14 +92,14 @@ abstract class BaseFragment : Fragment(), OnSelectedTunnelChangedListener { } catch (e: Throwable) { val error = ErrorMessages[e] val messageResId = if (checked) R.string.error_up else R.string.error_down - val message = requireContext().getString(messageResId, error) + val message = getString(messageResId, error) val view = view if (view != null) Snackbar.make(view, message, Snackbar.LENGTH_LONG) .setAnchorView(view.findViewById(R.id.create_fab)) .show() else - Toast.makeText(requireContext(), message, Toast.LENGTH_LONG).show() + Toast.makeText(activity ?: Application.get(), message, Toast.LENGTH_LONG).show() Log.e(TAG, message, e) } } |