Commit 504e30c4 authored by Thomas's avatar Thomas
Browse files

Cached intent for media

parent 09a8b6c4
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -500,7 +500,7 @@ public class ProfileActivity extends BaseActivity {

        binding.accountPp.setOnClickListener(v -> {
            Intent intent = new Intent(ProfileActivity.this, MediaActivity.class);
            Bundle b = new Bundle();
            Bundle args = new Bundle();
            Attachment attachment = new Attachment();
            attachment.description = account.acct;
            attachment.preview_url = account.avatar;
@@ -509,14 +509,18 @@ public class ProfileActivity extends BaseActivity {
            attachment.type = "image";
            ArrayList<Attachment> attachments = new ArrayList<>();
            attachments.add(attachment);
            b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
            b.putInt(Helper.ARG_MEDIA_POSITION, 1);
            intent.putExtras(b);
            args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
            args.putInt(Helper.ARG_MEDIA_POSITION, 1);
            new CachedBundle(ProfileActivity.this).insertBundle(args, currentAccount, bundleId -> {
                Bundle bundle = new Bundle();
                bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                intent.putExtras(bundle);
                ActivityOptionsCompat options = ActivityOptionsCompat
                        .makeSceneTransitionAnimation(ProfileActivity.this, binding.accountPp, attachment.url);
                // start the new activity
                startActivity(intent, options.toBundle());
            });
        });


        binding.accountFollow.setOnClickListener(v -> {
+12 −8
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ public class AdminAccountActivity extends BaseActivity {
        MastodonHelper.loadPPMastodon(binding.accountPp, adminAccount.account);
        binding.accountPp.setOnClickListener(v -> {
            Intent intent = new Intent(AdminAccountActivity.this, MediaActivity.class);
            Bundle b = new Bundle();
            Bundle args = new Bundle();
            Attachment attachment = new Attachment();
            attachment.description = adminAccount.account.acct;
            attachment.preview_url = adminAccount.account.avatar;
@@ -353,14 +353,18 @@ public class AdminAccountActivity extends BaseActivity {
            attachment.type = "image";
            ArrayList<Attachment> attachments = new ArrayList<>();
            attachments.add(attachment);
            b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
            b.putInt(Helper.ARG_MEDIA_POSITION, 1);
            intent.putExtras(b);
            args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
            args.putInt(Helper.ARG_MEDIA_POSITION, 1);
            new CachedBundle(AdminAccountActivity.this).insertBundle(args, currentAccount, bundleId -> {
                Bundle bundle = new Bundle();
                bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                intent.putExtras(bundle);
                ActivityOptionsCompat options = ActivityOptionsCompat
                        .makeSceneTransitionAnimation(AdminAccountActivity.this, binding.accountPp, attachment.url);
                // start the new activity
                startActivity(intent, options.toBundle());
            });
        });


        binding.accountDate.setText(Helper.shortDateToString(adminAccount.created_at));
+11 −8
Original line number Diff line number Diff line
@@ -357,7 +357,7 @@ public class AdminReportActivity extends BaseBarActivity {
        MastodonHelper.loadPPMastodon(binding.accountPp, account);
        binding.accountPp.setOnClickListener(v -> {
            Intent intent = new Intent(AdminReportActivity.this, MediaActivity.class);
            Bundle b = new Bundle();
            Bundle args = new Bundle();
            Attachment attachment = new Attachment();
            attachment.description = account.acct;
            attachment.preview_url = account.avatar;
@@ -366,14 +366,17 @@ public class AdminReportActivity extends BaseBarActivity {
            attachment.type = "image";
            ArrayList<Attachment> attachments = new ArrayList<>();
            attachments.add(attachment);
            b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
            b.putInt(Helper.ARG_MEDIA_POSITION, 1);
            intent.putExtras(b);
            args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
            args.putInt(Helper.ARG_MEDIA_POSITION, 1);
            new CachedBundle(AdminReportActivity.this).insertBundle(args, currentAccount, bundleId -> {
                Bundle bundle = new Bundle();
                bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                intent.putExtras(bundle);
                ActivityOptionsCompat options = ActivityOptionsCompat
                        .makeSceneTransitionAnimation(AdminReportActivity.this, binding.accountPp, attachment.url);
            // start the new activity
                startActivity(intent, options.toBundle());
            });
        });


        binding.accountDate.setText(Helper.shortDateToString(account.created_at));
+11 −6
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ import app.fedilab.android.mastodon.client.entities.api.Poll;
import app.fedilab.android.mastodon.client.entities.api.Status;
import app.fedilab.android.mastodon.client.entities.api.Tag;
import app.fedilab.android.mastodon.client.entities.app.BaseAccount;
import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.client.entities.app.CamelTag;
import app.fedilab.android.mastodon.client.entities.app.Languages;
import app.fedilab.android.mastodon.client.entities.app.Quotes;
@@ -1366,15 +1367,19 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
                    }
                    drawerMediaListBinding.getRoot().setOnClickListener(v -> {
                        Intent mediaIntent = new Intent(context, MediaActivity.class);
                        Bundle b = new Bundle();
                        Bundle args = new Bundle();
                        ArrayList<Attachment> attachments = new ArrayList<>();
                        attachments.add(attachment);
                        b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
                        mediaIntent.putExtras(b);
                        args.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments);
                        new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
                            Bundle bundle = new Bundle();
                            bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                            mediaIntent.putExtras(bundle);
                            ActivityOptionsCompat options = ActivityOptionsCompat
                                    .makeSceneTransitionAnimation((Activity) context, drawerMediaListBinding.media, attachment.url);
                            context.startActivity(mediaIntent, options.toBundle());
                        });
                    });
                    holder.binding.simpleMedia.addView(drawerMediaListBinding.getRoot());

                }
+12 −11
Original line number Diff line number Diff line
@@ -75,20 +75,21 @@ public class ImageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
        }
        holder.binding.media.setOnClickListener(v -> {
            Intent mediaIntent = new Intent(context, MediaActivity.class);
            Bundle b = new Bundle();
            b.putInt(Helper.ARG_MEDIA_POSITION, position + 1);
            b.putBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, true);
            mediaIntent.putExtras(b);
            ActivityOptionsCompat options = null;
            Bundle args = new Bundle();
            args.putInt(Helper.ARG_MEDIA_POSITION, position + 1);
            args.putBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, true);
            if (attachment != null) {
                new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
                    Bundle bundle = new Bundle();
                    bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
                    mediaIntent.putExtras(bundle);
                    ActivityOptionsCompat options = null;
                    options = ActivityOptionsCompat
                            .makeSceneTransitionAnimation((Activity) context, holder.binding.media, attachment.url);
            } else {
                return;
            }
            // start the new activity
                    context.startActivity(mediaIntent, options.toBundle());
                });
            }
        });

        holder.binding.media.setOnLongClickListener(v -> {
            Intent intentContext = new Intent(context, ContextActivity.class);
Loading