add shared element transition for article images pager

This commit is contained in:
Andrew Dolgov 2015-02-12 10:48:50 +03:00
parent abc9c4cbf6
commit f46552126a
2 changed files with 18 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.util.Log; 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); registerForContextMenu(imgView);
getSupportActionBar().hide();
DisplayImageOptions options = new DisplayImageOptions.Builder() DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheInMemory(true) .cacheInMemory(true)
@ -241,6 +244,7 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
setContentView(R.layout.article_images_pager); setContentView(R.layout.article_images_pager);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().hide();
if (savedInstanceState == null) { if (savedInstanceState == null) {
m_title = getIntent().getStringExtra("title"); m_title = getIntent().getStringExtra("title");

View File

@ -14,7 +14,10 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; 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.app.Fragment;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.text.Html; import android.text.Html;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -901,6 +904,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
.cacheOnDisk(true) .cacheOnDisk(true)
.build(); .build();
ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_IMAGES_PAGER");
holder.flavorImageView.setOnClickListener(new OnClickListener() { holder.flavorImageView.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -910,7 +915,14 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
intent.putExtra("title", article.title); intent.putExtra("title", article.title);
intent.putExtra("content", article.content); 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 were transitioning to
);
ActivityCompat.startActivity(m_activity, intent, options.toBundle());
//startActivityForResult(intent, 0);
} }
}); });