From a113770868871426f5663c2b96eee0015ca959d1 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 30 Mar 2023 13:54:06 +0200 Subject: [PATCH] ui: use app resources instead of ctx for strings in callback Exception java.lang.IllegalStateException: at androidx.fragment.app.Fragment.requireContext (Fragment.java:967) at com.wireguard.android.fragment.TunnelListFragment$tunnelFileImportResultLauncher$1$1.invokeSuspend (TunnelListFragment.kt:64) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:104) at android.os.Handler.handleCallback (Handler.java:761) at android.os.Handler.dispatchMessage (Handler.java:98) at android.os.Looper.loop (Looper.java:156) at android.app.ActivityThread.main (ActivityThread.java:6617) at java.lang.reflect.Method.invoke at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:942) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:832) Signed-off-by: Jason A. Donenfeld --- .../java/com/wireguard/android/fragment/TunnelListFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt index 5f3d3950..e6270d0e 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelListFragment.kt @@ -62,7 +62,7 @@ class TunnelListFragment : BaseFragment() { TunnelImporter.importTunnel(parentFragmentManager, result.text) { showSnackbar(it) } } catch (e: Exception) { val error = ErrorMessages[e] - val message = requireContext().getString(R.string.import_error, error) + val message = Application.get().resources.getString(R.string.import_error, error) Log.e(TAG, message, e) showSnackbar(message) }