Some fixes

This commit is contained in:
Thomas 2023-02-08 17:57:50 +01:00
parent 6434b154b4
commit 578161d604
3 changed files with 20 additions and 14 deletions

View File

@ -111,7 +111,7 @@ public class BottomMenu implements Serializable {
} }
public static ItemMenuType getType(BottomMenu bottomMenu, int position) { public static ItemMenuType getType(BottomMenu bottomMenu, int position) {
if (bottomMenu == null || bottomMenu.bottom_menu == null || bottomMenu.bottom_menu.size() < position) { if (bottomMenu == null || bottomMenu.bottom_menu == null || bottomMenu.bottom_menu.size() <= position) {
return null; return null;
} }
return bottomMenu.bottom_menu.get(position).item_menu_type; return bottomMenu.bottom_menu.get(position).item_menu_type;

View File

@ -2777,16 +2777,20 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
context.startActivity(intent, options.toBundle()); context.startActivity(intent, options.toBundle());
}); });
holder.bindingArt.artMedia.setOnClickListener(v -> { holder.bindingArt.artMedia.setOnClickListener(v -> {
Intent mediaIntent = new Intent(context, MediaActivity.class); if (status.art_attachment != null) {
Bundle b = new Bundle(); Intent mediaIntent = new Intent(context, MediaActivity.class);
b.putInt(Helper.ARG_MEDIA_POSITION, 1); Bundle b = new Bundle();
ArrayList<Attachment> attachments = new ArrayList<>(); b.putInt(Helper.ARG_MEDIA_POSITION, 1);
attachments.add(status.art_attachment); ArrayList<Attachment> attachments = new ArrayList<>();
b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments); attachments.add(status.art_attachment);
mediaIntent.putExtras(b); b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
ActivityOptionsCompat options = ActivityOptionsCompat mediaIntent.putExtras(b);
.makeSceneTransitionAnimation((Activity) context, holder.bindingArt.artMedia, status.art_attachment.url); ActivityOptionsCompat options = ActivityOptionsCompat
context.startActivity(mediaIntent, options.toBundle()); .makeSceneTransitionAnimation((Activity) context, holder.bindingArt.artMedia, status.art_attachment.url);
context.startActivity(mediaIntent, options.toBundle());
} else {
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}); });
holder.bindingArt.bottomBanner.setOnClickListener(v -> { holder.bindingArt.bottomBanner.setOnClickListener(v -> {
Intent intent = new Intent(context, ContextActivity.class); Intent intent = new Intent(context, ContextActivity.class);

View File

@ -753,7 +753,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
* @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll
*/ */
private void routeCommon(DIRECTION direction, boolean fetchingMissing, Status status) { private void routeCommon(DIRECTION direction, boolean fetchingMissing, Status status) {
if (binding == null || getActivity() == null || !isAdded()) { if (binding == null || !isAdded() || getActivity() == null) {
return; return;
} }
//Initialize with default params //Initialize with default params
@ -964,7 +964,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
* @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll * @param direction - DIRECTION null if first call, then is set to TOP or BOTTOM depending of scroll
*/ */
private void route(DIRECTION direction, boolean fetchingMissing, Status statusToUpdate) { private void route(DIRECTION direction, boolean fetchingMissing, Status statusToUpdate) {
if (binding == null || getActivity() == null || !isAdded()) { if (binding == null || !isAdded() || getActivity() == null) {
return; return;
} }
// --- HOME TIMELINE --- // --- HOME TIMELINE ---
@ -1083,7 +1083,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
initializeStatusesCommonView(otherStatuses); initializeStatusesCommonView(otherStatuses);
})); }));
} else { } else {
Toasty.error(requireActivity(), getString(R.string.toast_fetch_error), Toasty.LENGTH_LONG).show(); if (isAdded() && !requireActivity().isFinishing()) {
Toasty.error(requireActivity(), getString(R.string.toast_fetch_error), Toasty.LENGTH_LONG).show();
}
} }
} }
}); });