Browse Source

close #717 and fix looper toast issue

renovate/org.robolectric-robolectric-4.x
Austin Huang 4 years ago
parent
commit
20d9a3935b
No known key found for this signature in database GPG Key ID: 84C23AA04587A91F
  1. 22
      app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java
  2. 5
      app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java
  3. 25
      app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java

22
app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java

@ -94,17 +94,12 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
commentsViewModel.getList().postValue(list);
}
binding.swipeRefreshLayout.setRefreshing(false);
stopCurrentExecutor();
stopCurrentExecutor(false);
}
@Override
public void onFailure(Throwable t) {
try {
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
binding.swipeRefreshLayout.setRefreshing(false);
stopCurrentExecutor();
}
catch(Throwable e) {}
stopCurrentExecutor(true);
}
};
@ -227,7 +222,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
endCursor = null;
lazyLoader.resetState();
commentsViewModel.getList().postValue(Collections.emptyList());
stopCurrentExecutor();
stopCurrentExecutor(false);
currentlyRunning = new CommentsFetcher(shortCode, "", fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@ -276,7 +271,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
endCursor = null;
});
binding.rvComments.addOnScrollListener(lazyLoader);
stopCurrentExecutor();
stopCurrentExecutor(false);
onRefresh();
}
@ -462,7 +457,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
NavHostFragment.findNavController(this).navigate(action);
}
private void stopCurrentExecutor() {
private void stopCurrentExecutor(@NonNull final boolean failed) {
if (currentlyRunning != null) {
try {
currentlyRunning.cancel(true);
@ -470,6 +465,13 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
}
}
if (failed) {
try {
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
binding.swipeRefreshLayout.setRefreshing(false);
}
catch(Throwable e) {}
}
}
@Nullable

5
app/src/main/java/awais/instagrabber/fragments/FollowViewerFragment.java

@ -348,16 +348,17 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh
loading = false;
final ArrayList<ExpandableGroup> groups = new ArrayList<>(1);
if (isCompare) {
if (isCompare && followingModels != null && followersModels != null && allFollowing != null) {
if (followingModels != null && followingModels.size() > 0)
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_following, username), followingModels));
if (followersModels != null && followersModels.size() > 0)
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_follower, namePost), followersModels));
if (allFollowing != null && allFollowing.size() > 0)
groups.add(new ExpandableGroup(resources.getString(R.string.followers_both_following), allFollowing));
} else {
} else if (followModels != null) {
groups.add(new ExpandableGroup(type, followModels));
}
else return;
adapter = new FollowAdapter(clickListener, groups);
adapter.toggleGroup(0);
binding.rvFollow.setAdapter(adapter);

25
app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java

@ -91,7 +91,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
private boolean hasStories = false;
private boolean opening = false;
private String hashtag;
private HashtagModel hashtagModel;
private HashtagModel hashtagModel = null;
private ActionMode actionMode;
private StoriesService storiesService;
private AsyncTask<?, ?, ?> currentlyExecuting;
@ -373,22 +373,12 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
public void onResult(final HashtagModel result) {
hashtagModel = result;
binding.swipeRefreshLayout.setRefreshing(false);
final Context context = getContext();
if (context == null) return;
if (hashtagModel == null) {
Toast.makeText(context, R.string.error_loading_hashtag, Toast.LENGTH_SHORT).show();
binding.swipeRefreshLayout.setEnabled(false);
return;
}
setTitle();
setHashtagDetails();
setupPosts();
fetchStories();
}
@Override
public void onFailure(Throwable t) {
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
setHashtagDetails();
}
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@ -406,6 +396,17 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
}
private void setHashtagDetails() {
if (hashtagModel == null) {
try {
Toast.makeText(getContext(), R.string.error_loading_hashtag, Toast.LENGTH_SHORT).show();
binding.swipeRefreshLayout.setEnabled(false);
}
catch (Exception ignored) {}
return;
}
setTitle();
setupPosts();
fetchStories();
if (isLoggedIn) {
hashtagDetailsBinding.btnFollowTag.setVisibility(View.VISIBLE);
hashtagDetailsBinding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow);

Loading…
Cancel
Save