From 605ddd363598c5b79b4771e2cfc2073c50d190c4 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 23 Feb 2021 22:34:50 -0500 Subject: [PATCH] oop --- .../fragments/CommentsViewerFragment.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java index af9af998..6fa829a1 100644 --- a/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java @@ -94,12 +94,12 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl commentsViewModel.getList().postValue(list); } binding.swipeRefreshLayout.setRefreshing(false); - stopCurrentExecutor(false); + stopCurrentExecutor(null); } @Override public void onFailure(Throwable t) { - stopCurrentExecutor(true); + stopCurrentExecutor(t); } }; @@ -222,7 +222,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl endCursor = null; lazyLoader.resetState(); commentsViewModel.getList().postValue(Collections.emptyList()); - stopCurrentExecutor(false); + stopCurrentExecutor(null); currentlyRunning = new CommentsFetcher(shortCode, "", fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } @@ -271,7 +271,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl endCursor = null; }); binding.rvComments.addOnScrollListener(lazyLoader); - stopCurrentExecutor(false); + stopCurrentExecutor(null); onRefresh(); } @@ -457,7 +457,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl NavHostFragment.findNavController(this).navigate(action); } - private void stopCurrentExecutor(@NonNull final boolean failed) { + private void stopCurrentExecutor(final Throwable t) { if (currentlyRunning != null) { try { currentlyRunning.cancel(true); @@ -465,7 +465,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl if (BuildConfig.DEBUG) Log.e(TAG, "", e); } } - if (failed) { + if (t != null) { try { Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show(); binding.swipeRefreshLayout.setRefreshing(false);