From 70056d68ac8ad96f97b984346a458f3ab2fa193e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 12 Feb 2015 12:41:25 +0300 Subject: [PATCH] add transition animation for headlinesarticles activity --- .../java/org/fox/ttrss/FeedsActivity.java | 17 ++++++++++-- .../java/org/fox/ttrss/HeadlinesActivity.java | 26 +++++++++---------- .../headlines_articles.xml | 1 + .../main/res/layout/headlines_fragment.xml | 1 + 4 files changed, 29 insertions(+), 16 deletions(-) mode change 100644 => 100755 org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java mode change 100644 => 100755 org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java mode change 100644 => 100755 org.fox.ttrss/src/main/res/layout-sw600dp-land/headlines_articles.xml diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java old mode 100644 new mode 100755 index abadb0be..ebde85c6 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/FeedsActivity.java @@ -11,6 +11,8 @@ import android.os.Bundle; import android.os.Handler; import android.os.Parcelable; 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.FragmentTransaction; import android.support.v4.widget.DrawerLayout; @@ -466,8 +468,19 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe intent.putExtra("searchQuery", hf.getSearchQuery()); //intent.putParcelableArrayListExtra("articles", hf.getArticles()); intent.putExtra("articles", (Parcelable)hf.getAllArticles()); - - startActivityForResult(intent, HEADLINES_REQUEST); + + /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + startActivityForResult(intent, HEADLINES_REQUEST, ActivityOptions.makeSceneTransitionAnimation(this).toBundle()); + } else { + startActivityForResult(intent, HEADLINES_REQUEST); + } */ + + View sharedList = hf.getView().findViewById(R.id.headlines_list); + + ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, sharedList, "TRANSITION:HEADLINES_LIST"); + + ActivityCompat.startActivityForResult(this, intent, HEADLINES_REQUEST, options.toBundle()); + } else { invalidateOptionsMenu(); } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java old mode 100644 new mode 100755 index 226ba5d1..1ea943ab --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesActivity.java @@ -32,8 +32,8 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL .getDefaultSharedPreferences(getApplicationContext()); setAppTheme(m_prefs); - - super.onCreate(savedInstanceState); + + super.onCreate(savedInstanceState); setContentView(R.layout.headlines_articles); @@ -85,10 +85,14 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.headlines_fragment, new LoadingFragment(), null); - ft.replace(R.id.article_fragment, new LoadingFragment(), null); - - ft.commit(); + final HeadlinesFragment hf = new HeadlinesFragment(); + hf.initialize(feed, article, true, m_articles); + hf.setSearchQuery(searchQuery); + + ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); + ft.replace(R.id.article_fragment, new LoadingFragment(), null); + + ft.commit(); setTitle(feed.title); @@ -97,21 +101,15 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL public void run() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - HeadlinesFragment hf = new HeadlinesFragment(); - hf.initialize(feed, article, true, m_articles); - hf.setSearchQuery(searchQuery); - ArticlePager af = new ArticlePager(); af.initialize(article != null ? hf.getArticleById(article.id) : new Article(), feed, m_articles); af.setSearchQuery(searchQuery); - ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES); ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); ft.commit(); - } - }, 25); - + } + }, 100); } } } diff --git a/org.fox.ttrss/src/main/res/layout-sw600dp-land/headlines_articles.xml b/org.fox.ttrss/src/main/res/layout-sw600dp-land/headlines_articles.xml old mode 100644 new mode 100755 index f4ff2c59..0abc2f5b --- a/org.fox.ttrss/src/main/res/layout-sw600dp-land/headlines_articles.xml +++ b/org.fox.ttrss/src/main/res/layout-sw600dp-land/headlines_articles.xml @@ -22,6 +22,7 @@