From eba37705e2f55326617246e8235b0f922cea31da Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Sat, 23 Jan 2021 11:32:34 -0500 Subject: [PATCH] #583 --- .../fragments/CommentsViewerFragment.java | 9 +++++--- .../fragments/FollowViewerFragment.java | 21 +++++++++++++------ .../NotificationsViewerFragment.java | 14 +++++++++---- .../fragments/StoryViewerFragment.java | 7 +++++-- .../instagrabber/webservices/BaseService.java | 1 + 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java index 338300dd..18cc9762 100644 --- a/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java @@ -99,9 +99,12 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl @Override public void onFailure(Throwable t) { - Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); - binding.swipeRefreshLayout.setRefreshing(false); - stopCurrentExecutor(); + try { + Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + binding.swipeRefreshLayout.setRefreshing(false); + stopCurrentExecutor(); + } + catch(Throwable e) {} } }; diff --git a/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java index 11ee076c..115f5849 100644 --- a/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java @@ -83,8 +83,11 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh @Override public void onFailure(final Throwable t) { - binding.swipeRefreshLayout.setRefreshing(false); - Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + try { + binding.swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + } + catch(Throwable e) {} Log.e(TAG, "Error fetching list (double, following)", t); } }; @@ -109,8 +112,11 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh @Override public void onFailure(final Throwable t) { - binding.swipeRefreshLayout.setRefreshing(false); - Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + try { + binding.swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + } + catch(Throwable e) {} Log.e(TAG, "Error fetching list (double, follower)", t); } }; @@ -221,8 +227,11 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh @Override public void onFailure(final Throwable t) { - binding.swipeRefreshLayout.setRefreshing(false); - Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + try { + binding.swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + } + catch(Throwable e) {} Log.e(TAG, "Error fetching list (single)", t); } }; diff --git a/app/src/main/java/awais/instagrabber/fragments/NotificationsViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/NotificationsViewerFragment.java index 1b372ea1..34dc5922 100644 --- a/app/src/main/java/awais/instagrabber/fragments/NotificationsViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/NotificationsViewerFragment.java @@ -271,8 +271,11 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe @Override public void onFailure(Throwable t) { - binding.swipeRefreshLayout.setRefreshing(false); - Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + try { + binding.swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + } + catch(Throwable e) {} } }).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); break; @@ -287,8 +290,11 @@ public final class NotificationsViewerFragment extends Fragment implements Swipe @Override public void onFailure(final Throwable t) { - binding.swipeRefreshLayout.setRefreshing(false); - Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + try { + binding.swipeRefreshLayout.setRefreshing(false); + Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); + } + catch(Throwable e) {} } }); break; diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index accf2b06..337f2754 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -236,8 +236,11 @@ public class StoryViewerFragment extends Fragment { @Override public void onFailure(@NonNull final Call call, @NonNull final Throwable t) { - Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); - Log.e(TAG, "onFailure: ", t); + try { + Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show(); + Log.e(TAG, "onFailure: ", t); + } + catch(Throwable e) {} } }); } catch (UnsupportedEncodingException e) { diff --git a/app/src/main/java/awais/instagrabber/webservices/BaseService.java b/app/src/main/java/awais/instagrabber/webservices/BaseService.java index ca850400..e30aa992 100644 --- a/app/src/main/java/awais/instagrabber/webservices/BaseService.java +++ b/app/src/main/java/awais/instagrabber/webservices/BaseService.java @@ -35,6 +35,7 @@ public abstract class BaseService { final Gson gson = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(Caption.class, new Caption.CaptionDeserializer()) + .setLenient() .create(); builder = new Retrofit.Builder() .addConverterFactory(ScalarsConverterFactory.create())