1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00

Wrap navigate calls with try catch to prevent double click exceptions. Closes austinhuang0131/barinsta#1132, austinhuang0131/barinsta#1150, austinhuang0131/barinsta#1156

This commit is contained in:
Ammar Githam 2021-04-25 16:08:43 +09:00
parent 627b1bfe76
commit 7658cacbc2
4 changed files with 27 additions and 13 deletions

View File

@ -613,7 +613,11 @@ public class PostViewV2Fragment extends SharedElementTransitionDialogFragment im
bundle.putString("shortCode", media.getCode());
bundle.putString("postId", media.getPk());
bundle.putLong("postUserId", user.getPk());
navController.navigate(R.id.action_global_commentsViewerFragment, bundle);
try {
navController.navigate(R.id.action_global_commentsViewerFragment, bundle);
} catch (Exception e) {
Log.e(TAG, "setupComment: ", e);
}
});
binding.comment.setOnLongClickListener(v -> {
Utils.displayToastAboveView(context, v, getString(R.string.comment));

View File

@ -41,7 +41,7 @@ import awais.instagrabber.webservices.ServiceCallback;
import static awais.instagrabber.utils.Utils.settingsHelper;
public class SavedCollectionsFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private static final String TAG = "SavedCollectionsFragment";
private static final String TAG = SavedCollectionsFragment.class.getSimpleName();
public static boolean pleaseRefresh = false;
private MainActivity fragmentActivity;
@ -147,13 +147,16 @@ public class SavedCollectionsFragment extends Fragment implements SwipeRefreshLa
if (isSaving) {
setNavControllerResult(navController, topicCluster.getId());
navController.navigateUp();
}
else {
final FragmentNavigator.Extras.Builder builder = new FragmentNavigator.Extras.Builder()
.addSharedElement(cover, "collection-" + topicCluster.getId());
final SavedCollectionsFragmentDirections.ActionSavedCollectionsFragmentToCollectionPostsFragment action = SavedCollectionsFragmentDirections
.actionSavedCollectionsFragmentToCollectionPostsFragment(topicCluster, titleColor, backgroundColor);
navController.navigate(action, builder.build());
} else {
try {
final FragmentNavigator.Extras.Builder builder = new FragmentNavigator.Extras.Builder()
.addSharedElement(cover, "collection-" + topicCluster.getId());
final SavedCollectionsFragmentDirections.ActionSavedCollectionsFragmentToCollectionPostsFragment action = SavedCollectionsFragmentDirections
.actionSavedCollectionsFragmentToCollectionPostsFragment(topicCluster, titleColor, backgroundColor);
navController.navigate(action, builder.build());
} catch (Exception e) {
Log.e(TAG, "setupTopics: ", e);
}
}
});
binding.topicsRecyclerView.setAdapter(adapter);

View File

@ -456,7 +456,7 @@ public class StoryViewerFragment extends Fragment {
.setView(R.layout.dialog_opening_post)
.create();
alertDialog.show();
mediaService.fetch(Long.valueOf(mediaId), new ServiceCallback<Media>() {
mediaService.fetch(Long.parseLong(mediaId), new ServiceCallback<Media>() {
@Override
public void onSuccess(final Media feedModel) {
final PostViewV2Fragment fragment = PostViewV2Fragment
@ -1136,7 +1136,6 @@ public class StoryViewerFragment extends Fragment {
});
}
private void openProfile(final String username) {
final ActionBar actionBar = fragmentActivity.getSupportActionBar();
if (actionBar != null) {

View File

@ -139,7 +139,11 @@ public class DirectMessageInboxFragment extends Fragment implements SwipeRefresh
public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
if (item.getItemId() == R.id.pending_requests) {
final NavDirections directions = DirectMessageInboxFragmentDirections.actionInboxToPendingInbox();
NavHostFragment.findNavController(this).navigate(directions);
try {
NavHostFragment.findNavController(this).navigate(directions);
} catch (Exception e) {
Log.e(TAG, "onOptionsItemSelected: ", e);
}
return true;
}
return super.onOptionsItemSelected(item);
@ -251,7 +255,11 @@ public class DirectMessageInboxFragment extends Fragment implements SwipeRefresh
if (isAdded()) {
final DirectMessageInboxFragmentDirections.ActionInboxToThread directions = DirectMessageInboxFragmentDirections
.actionInboxToThread(thread.getThreadId(), thread.getThreadTitle());
NavHostFragment.findNavController(this).navigate(directions);
try {
NavHostFragment.findNavController(this).navigate(directions);
} catch (Exception e) {
Log.e(TAG, "init: ", e);
}
}
navigating = false;
});