From f46552126ab8dff2d857f1b5df6278e3ba368896 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 12 Feb 2015 10:48:50 +0300 Subject: [PATCH] add shared element transition for article images pager --- .../org/fox/ttrss/ArticleImagesPagerActivity.java | 6 +++++- .../main/java/org/fox/ttrss/HeadlinesFragment.java | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleImagesPagerActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleImagesPagerActivity.java index 577265e2..d92aeefa 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleImagesPagerActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/ArticleImagesPagerActivity.java @@ -10,6 +10,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.view.PagerAdapter; +import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; import android.util.Log; @@ -126,8 +127,10 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur } }); + if (position == 0) + ViewCompat.setTransitionName(imgView, "TRANSITION:ARTICLE_IMAGES_PAGER"); + registerForContextMenu(imgView); - getSupportActionBar().hide(); DisplayImageOptions options = new DisplayImageOptions.Builder() .cacheInMemory(true) @@ -241,6 +244,7 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur setContentView(R.layout.article_images_pager); getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().hide(); if (savedInstanceState == null) { m_title = getIntent().getStringExtra("title"); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index 25a5dee8..66c728f8 100644 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -14,7 +14,10 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.Fragment; +import android.support.v4.view.ViewCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.text.Html; import android.util.DisplayMetrics; @@ -901,6 +904,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, .cacheOnDisk(true) .build(); + ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_IMAGES_PAGER"); + holder.flavorImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { @@ -910,7 +915,14 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, intent.putExtra("title", article.title); intent.putExtra("content", article.content); - startActivityForResult(intent, 0); + ActivityOptionsCompat options = + ActivityOptionsCompat.makeSceneTransitionAnimation(m_activity, + holder.flavorImageView, // The view which starts the transition + "TRANSITION:ARTICLE_IMAGES_PAGER" // The transitionName of the view we’re transitioning to + ); + ActivityCompat.startActivity(m_activity, intent, options.toBundle()); + + //startActivityForResult(intent, 0); } });