mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
close #717 and fix looper toast issue
This commit is contained in:
parent
60ec1f5936
commit
20d9a3935b
@ -94,17 +94,12 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
commentsViewModel.getList().postValue(list);
|
commentsViewModel.getList().postValue(list);
|
||||||
}
|
}
|
||||||
binding.swipeRefreshLayout.setRefreshing(false);
|
binding.swipeRefreshLayout.setRefreshing(false);
|
||||||
stopCurrentExecutor();
|
stopCurrentExecutor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
try {
|
stopCurrentExecutor(true);
|
||||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
|
||||||
binding.swipeRefreshLayout.setRefreshing(false);
|
|
||||||
stopCurrentExecutor();
|
|
||||||
}
|
|
||||||
catch(Throwable e) {}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -227,7 +222,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
endCursor = null;
|
endCursor = null;
|
||||||
lazyLoader.resetState();
|
lazyLoader.resetState();
|
||||||
commentsViewModel.getList().postValue(Collections.emptyList());
|
commentsViewModel.getList().postValue(Collections.emptyList());
|
||||||
stopCurrentExecutor();
|
stopCurrentExecutor(false);
|
||||||
currentlyRunning = new CommentsFetcher(shortCode, "", fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
currentlyRunning = new CommentsFetcher(shortCode, "", fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +271,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
endCursor = null;
|
endCursor = null;
|
||||||
});
|
});
|
||||||
binding.rvComments.addOnScrollListener(lazyLoader);
|
binding.rvComments.addOnScrollListener(lazyLoader);
|
||||||
stopCurrentExecutor();
|
stopCurrentExecutor(false);
|
||||||
onRefresh();
|
onRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +457,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
NavHostFragment.findNavController(this).navigate(action);
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopCurrentExecutor() {
|
private void stopCurrentExecutor(@NonNull final boolean failed) {
|
||||||
if (currentlyRunning != null) {
|
if (currentlyRunning != null) {
|
||||||
try {
|
try {
|
||||||
currentlyRunning.cancel(true);
|
currentlyRunning.cancel(true);
|
||||||
@ -470,6 +465,13 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
if (BuildConfig.DEBUG) Log.e(TAG, "", e);
|
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
|
@Nullable
|
||||||
|
@ -348,16 +348,17 @@ public final class FollowViewerFragment extends Fragment implements SwipeRefresh
|
|||||||
loading = false;
|
loading = false;
|
||||||
final ArrayList<ExpandableGroup> groups = new ArrayList<>(1);
|
final ArrayList<ExpandableGroup> groups = new ArrayList<>(1);
|
||||||
|
|
||||||
if (isCompare) {
|
if (isCompare && followingModels != null && followersModels != null && allFollowing != null) {
|
||||||
if (followingModels != null && followingModels.size() > 0)
|
if (followingModels != null && followingModels.size() > 0)
|
||||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_following, username), followingModels));
|
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_following, username), followingModels));
|
||||||
if (followersModels != null && followersModels.size() > 0)
|
if (followersModels != null && followersModels.size() > 0)
|
||||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_follower, namePost), followersModels));
|
groups.add(new ExpandableGroup(resources.getString(R.string.followers_not_follower, namePost), followersModels));
|
||||||
if (allFollowing != null && allFollowing.size() > 0)
|
if (allFollowing != null && allFollowing.size() > 0)
|
||||||
groups.add(new ExpandableGroup(resources.getString(R.string.followers_both_following), allFollowing));
|
groups.add(new ExpandableGroup(resources.getString(R.string.followers_both_following), allFollowing));
|
||||||
} else {
|
} else if (followModels != null) {
|
||||||
groups.add(new ExpandableGroup(type, followModels));
|
groups.add(new ExpandableGroup(type, followModels));
|
||||||
}
|
}
|
||||||
|
else return;
|
||||||
adapter = new FollowAdapter(clickListener, groups);
|
adapter = new FollowAdapter(clickListener, groups);
|
||||||
adapter.toggleGroup(0);
|
adapter.toggleGroup(0);
|
||||||
binding.rvFollow.setAdapter(adapter);
|
binding.rvFollow.setAdapter(adapter);
|
||||||
|
@ -91,7 +91,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
private boolean hasStories = false;
|
private boolean hasStories = false;
|
||||||
private boolean opening = false;
|
private boolean opening = false;
|
||||||
private String hashtag;
|
private String hashtag;
|
||||||
private HashtagModel hashtagModel;
|
private HashtagModel hashtagModel = null;
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private StoriesService storiesService;
|
private StoriesService storiesService;
|
||||||
private AsyncTask<?, ?, ?> currentlyExecuting;
|
private AsyncTask<?, ?, ?> currentlyExecuting;
|
||||||
@ -373,22 +373,12 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
public void onResult(final HashtagModel result) {
|
public void onResult(final HashtagModel result) {
|
||||||
hashtagModel = result;
|
hashtagModel = result;
|
||||||
binding.swipeRefreshLayout.setRefreshing(false);
|
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();
|
setHashtagDetails();
|
||||||
setupPosts();
|
|
||||||
fetchStories();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
|
setHashtagDetails();
|
||||||
}
|
}
|
||||||
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
@ -406,6 +396,17 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setHashtagDetails() {
|
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) {
|
if (isLoggedIn) {
|
||||||
hashtagDetailsBinding.btnFollowTag.setVisibility(View.VISIBLE);
|
hashtagDetailsBinding.btnFollowTag.setVisibility(View.VISIBLE);
|
||||||
hashtagDetailsBinding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow);
|
hashtagDetailsBinding.btnFollowTag.setText(hashtagModel.getFollowing() ? R.string.unfollow : R.string.follow);
|
||||||
|
Loading…
Reference in New Issue
Block a user