mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix issue #21 - Media click position always open the first one
This commit is contained in:
parent
28fe8dd584
commit
0e7c5cb946
2 changed files with 16 additions and 12 deletions
|
@ -802,7 +802,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
holder.binding.mediaContainer.setVisibility(View.VISIBLE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.GONE);
|
||||
} else { //Several media
|
||||
|
||||
int mediaPosition = 1;
|
||||
for (Attachment attachment : statusToDeal.media_attachments) {
|
||||
LayoutMediaBinding layoutMediaBinding = LayoutMediaBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);
|
||||
RelativeLayout.LayoutParams lp;
|
||||
|
@ -834,14 +834,15 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
Helper.changeDrawableColor(context, layoutMediaBinding.viewHide, R.color.white);
|
||||
}
|
||||
layoutMediaBinding.media.setLayoutParams(lp);
|
||||
int finalMediaPosition = mediaPosition;
|
||||
layoutMediaBinding.media.setOnClickListener(v -> {
|
||||
Intent mediaIntent = new Intent(context, MediaActivity.class);
|
||||
Bundle b = new Bundle();
|
||||
b.putInt(Helper.ARG_MEDIA_POSITION, 1);
|
||||
b.putInt(Helper.ARG_MEDIA_POSITION, finalMediaPosition);
|
||||
b.putSerializable(Helper.ARG_MEDIA_ARRAY, new ArrayList<>(statusToDeal.media_attachments));
|
||||
mediaIntent.putExtras(b);
|
||||
ActivityOptionsCompat options = ActivityOptionsCompat
|
||||
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(0).url);
|
||||
.makeSceneTransitionAnimation((Activity) context, layoutMediaBinding.media, statusToDeal.media_attachments.get(finalMediaPosition - 1).url);
|
||||
// start the new activity
|
||||
context.startActivity(mediaIntent, options.toBundle());
|
||||
});
|
||||
|
@ -850,6 +851,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
adapter.notifyItemChanged(getPositionAsync(notificationList, statusList, statusToDeal));
|
||||
});
|
||||
holder.binding.attachmentsList.addView(layoutMediaBinding.getRoot());
|
||||
mediaPosition++;
|
||||
}
|
||||
holder.binding.mediaContainer.setVisibility(View.GONE);
|
||||
holder.binding.attachmentsListContainer.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -147,6 +147,7 @@ public class FragmentMedia extends Fragment {
|
|||
new CustomTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull final Bitmap resource, Transition<? super Bitmap> transition) {
|
||||
if (binding != null) {
|
||||
binding.loader.setVisibility(View.GONE);
|
||||
if (binding.mediaPicture.getScale() < 1.1) {
|
||||
binding.mediaPicture.setImageBitmap(resource);
|
||||
|
@ -158,6 +159,7 @@ public class FragmentMedia extends Fragment {
|
|||
binding.messageReady.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
|
Loading…
Reference in a new issue