From 63dc69e13c807611deac7cae6b2a67ae8cabb7b6 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Mon, 3 May 2021 21:10:46 +0900 Subject: [PATCH] Fix for Looper.prepare() --- .../webservices/interceptors/IgErrorsInterceptor.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java b/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java index cd5068fb..104a9ad5 100644 --- a/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java +++ b/app/src/main/java/awais/instagrabber/webservices/interceptors/IgErrorsInterceptor.java @@ -14,6 +14,7 @@ import java.io.IOException; import awais.instagrabber.R; import awais.instagrabber.activities.MainActivity; import awais.instagrabber.dialogs.ConfirmDialogFragment; +import awais.instagrabber.utils.AppExecutors; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.TextUtils; import okhttp3.Interceptor; @@ -105,7 +106,13 @@ public class IgErrorsInterceptor implements Interceptor { if (mainActivity == null) return; // final View view = mainActivity.getRootView(); // if (view == null) return; - Toast.makeText(mainActivity.getApplicationContext(), message, Toast.LENGTH_LONG).show(); + try { + AppExecutors.getInstance() + .mainThread() + .execute(() -> Toast.makeText(mainActivity.getApplicationContext(), message, Toast.LENGTH_LONG).show()); + } catch (Exception e) { + Log.e(TAG, "showSnackbar: ", e); + } } @NonNull