summaryrefslogtreecommitdiffstats
path: root/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java')
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java38
1 files changed, 24 insertions, 14 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java
index 9b4304ed3..817b79eda 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ImageAdapter.java
@@ -14,6 +14,8 @@ package app.fedilab.android.mastodon.ui.drawer;
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
+import static app.fedilab.android.BaseMainActivity.currentAccount;
+
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
@@ -31,6 +33,7 @@ import app.fedilab.android.databinding.DrawerMediaBinding;
import app.fedilab.android.mastodon.activities.ContextActivity;
import app.fedilab.android.mastodon.activities.MediaActivity;
import app.fedilab.android.mastodon.client.entities.api.Attachment;
+import app.fedilab.android.mastodon.client.entities.app.CachedBundle;
import app.fedilab.android.mastodon.helper.Helper;
import app.fedilab.android.mastodon.ui.fragment.media.FragmentMediaProfile;
@@ -72,30 +75,37 @@ 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) {
- options = ActivityOptionsCompat
- .makeSceneTransitionAnimation((Activity) context, holder.binding.media, attachment.url);
- } else {
- return;
+ 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);
+ context.startActivity(mediaIntent, options.toBundle());
+ });
}
- // start the new activity
- context.startActivity(mediaIntent, options.toBundle());
});
holder.binding.media.setOnLongClickListener(v -> {
Intent intentContext = new Intent(context, ContextActivity.class);
+ Bundle args = new Bundle();
if (attachment != null) {
- intentContext.putExtra(Helper.ARG_STATUS, attachment.status);
+ args.putSerializable(Helper.ARG_STATUS, attachment.status);
} else {
return false;
}
- intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intentContext);
+ new CachedBundle(context).insertBundle(args, currentAccount, bundleId -> {
+ Bundle bundle = new Bundle();
+ bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
+ intentContext.putExtras(bundle);
+ intentContext.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(intentContext);
+ });
return false;
});
}