fix context crash

This commit is contained in:
k1zn
2022-10-13 21:44:37 +05:00
parent 4c5a1c5a17
commit 4a2e73d676
@@ -10,6 +10,7 @@ import static ru.vtosters.lite.ui.components.BackupManager.restoreBackup;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplication;
import static ru.vtosters.lite.utils.LifecycleUtils.restartApplicationWithTimer;
import static ru.vtosters.lite.utils.ThemesUtils.getTextAttr;
@@ -323,8 +324,17 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
AndroidUtils.getGlobalContext().getSharedPreferences("gcm", 0).edit().clear().apply();
OtherFragment.this.getListView().postDelayed(() -> {
PushSubscriber.e.a(true);
ToastUtils.a(requireContext().getString(R.string.fcmtokenget));
ToastUtils.a(requireContext().getString(R.string.fcmtokenfixed));
Context ctx;
try {
ctx = requireContext();
} catch (Exception unused) {
ctx = getGlobalContext();
}
ToastUtils.a(ctx.getString(R.string.fcmtokenget));
ToastUtils.a(ctx.getString(R.string.fcmtokenfixed));
}, 1000);
return true;
}