Fix some crashes

This commit is contained in:
Thomas 2023-03-09 17:44:22 +01:00
parent 6a1a144ca3
commit 915841aa04
2 changed files with 15 additions and 14 deletions

View file

@ -1631,8 +1631,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
int finalMediaPosition = mediaPosition; int finalMediaPosition = mediaPosition;
layoutMediaBinding.mediaVideo.setOnClickListener(v -> { layoutMediaBinding.mediaVideo.setOnClickListener(v -> {
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5); final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
if (status.sensitive && !expand_media) { if (statusToDeal.sensitive && !expand_media) {
status.sensitive = false; statusToDeal.sensitive = false;
int position = holder.getBindingAdapterPosition(); int position = holder.getBindingAdapterPosition();
adapter.notifyItemChanged(position); adapter.notifyItemChanged(position);
@ -1642,7 +1642,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
} }
public void onFinish() { public void onFinish() {
status.sensitive = true; statusToDeal.sensitive = true;
adapter.notifyItemChanged(position); adapter.notifyItemChanged(position);
} }
}.start(); }.start();
@ -1652,15 +1652,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent mediaIntent = new Intent(context, MediaActivity.class); Intent mediaIntent = new Intent(context, MediaActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition); b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments)); b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
mediaIntent.putExtras(b); mediaIntent.putExtras(b);
ActivityOptionsCompat options = ActivityOptionsCompat ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, status.media_attachments.get(0).url); .makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
// start the new activity // start the new activity
context.startActivity(mediaIntent, options.toBundle()); context.startActivity(mediaIntent, options.toBundle());
}); });
layoutMediaBinding.viewHide.setOnClickListener(v -> { layoutMediaBinding.viewHide.setOnClickListener(v -> {
status.sensitive = !status.sensitive; statusToDeal.sensitive = !statusToDeal.sensitive;
adapter.notifyItemChanged(holder.getBindingAdapterPosition()); adapter.notifyItemChanged(holder.getBindingAdapterPosition());
}); });
} else { } else {
@ -1695,8 +1695,8 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
int finalMediaPosition = mediaPosition; int finalMediaPosition = mediaPosition;
layoutMediaBinding.mediaVideo.setOnClickListener(v -> { layoutMediaBinding.mediaVideo.setOnClickListener(v -> {
final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5); final int timeout = sharedpreferences.getInt(context.getString(R.string.SET_NSFW_TIMEOUT), 5);
if (status.sensitive && !expand_media) { if (statusToDeal.sensitive && !expand_media) {
status.sensitive = false; statusToDeal.sensitive = false;
int position = holder.getBindingAdapterPosition(); int position = holder.getBindingAdapterPosition();
adapter.notifyItemChanged(position); adapter.notifyItemChanged(position);
@ -1706,7 +1706,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
} }
public void onFinish() { public void onFinish() {
status.sensitive = true; statusToDeal.sensitive = true;
adapter.notifyItemChanged(position); adapter.notifyItemChanged(position);
} }
}.start(); }.start();
@ -1716,15 +1716,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
Intent mediaIntent = new Intent(context, MediaActivity.class); Intent mediaIntent = new Intent(context, MediaActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition); b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(status.media_attachments)); b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
mediaIntent.putExtras(b); mediaIntent.putExtras(b);
ActivityOptionsCompat options = ActivityOptionsCompat ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, status.media_attachments.get(0).url); .makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
// start the new activity // start the new activity
context.startActivity(mediaIntent, options.toBundle()); context.startActivity(mediaIntent, options.toBundle());
}); });
layoutMediaBinding.viewHide.setOnClickListener(v -> { layoutMediaBinding.viewHide.setOnClickListener(v -> {
status.sensitive = !status.sensitive; statusToDeal.sensitive = !statusToDeal.sensitive;
adapter.notifyItemChanged(holder.getBindingAdapterPosition()); adapter.notifyItemChanged(holder.getBindingAdapterPosition());
}); });
} else { } else {

View file

@ -2,7 +2,7 @@ Added:
- Add a button to fetch remote media when it fails - Add a button to fetch remote media when it fails
- Add a settings to automatically fetch remote media when it fails (default: disabled) - Add a settings to automatically fetch remote media when it fails (default: disabled)
- Display on profiles & list of accounts if users have requested to follow you - Display on profiles & list of accounts if users have requested to follow you
- Warn before boosting a message having no media description (default: enabled) - Warn before boosting a message having no media descriptions (default: enabled)
Changed: Changed:
- Warn when there are missing descriptions enabled by default - Warn when there are missing descriptions enabled by default
@ -10,4 +10,5 @@ Changed:
Fixed: Fixed:
- Some settings not properly restored (multiple choices) - Some settings not properly restored (multiple choices)
- Cancel a follow request - Cancel a follow request
- Media with a lot of height in landscape - Media with a lot of height in landscape
- Some crashes