add transition animation for headlinesarticles activity

This commit is contained in:
Andrew Dolgov 2015-02-12 12:41:25 +03:00
parent 100ce3413e
commit 70056d68ac
4 changed files with 29 additions and 16 deletions

View File

@ -11,6 +11,8 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Parcelable; import android.os.Parcelable;
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.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
@ -467,7 +469,18 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
//intent.putParcelableArrayListExtra("articles", hf.getArticles()); //intent.putParcelableArrayListExtra("articles", hf.getArticles());
intent.putExtra("articles", (Parcelable)hf.getAllArticles()); intent.putExtra("articles", (Parcelable)hf.getAllArticles());
/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
startActivityForResult(intent, HEADLINES_REQUEST, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
} else {
startActivityForResult(intent, HEADLINES_REQUEST); 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 { } else {
invalidateOptionsMenu(); invalidateOptionsMenu();
} }

View File

@ -85,7 +85,11 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.headlines_fragment, new LoadingFragment(), null); 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.replace(R.id.article_fragment, new LoadingFragment(), null);
ft.commit(); ft.commit();
@ -97,21 +101,15 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
public void run() { public void run() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
HeadlinesFragment hf = new HeadlinesFragment();
hf.initialize(feed, article, true, m_articles);
hf.setSearchQuery(searchQuery);
ArticlePager af = new ArticlePager(); ArticlePager af = new ArticlePager();
af.initialize(article != null ? hf.getArticleById(article.id) : new Article(), feed, m_articles); af.initialize(article != null ? hf.getArticleById(article.id) : new Article(), feed, m_articles);
af.setSearchQuery(searchQuery); af.setSearchQuery(searchQuery);
ft.replace(R.id.headlines_fragment, hf, FRAG_HEADLINES);
ft.replace(R.id.article_fragment, af, FRAG_ARTICLE); ft.replace(R.id.article_fragment, af, FRAG_ARTICLE);
ft.commit(); ft.commit();
} }
}, 25); }, 100);
} }
} }
} }

View File

@ -22,6 +22,7 @@
<FrameLayout <FrameLayout
android:paddingRight="4dp" android:paddingRight="4dp"
android:id="@+id/headlines_fragment" android:id="@+id/headlines_fragment"
android:transitionName="TRANSITION:HEADLINES_LIST"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="0.4" android:layout_weight="0.4"

View File

@ -12,6 +12,7 @@
<ListView <ListView
android:id="@+id/headlines_list" android:id="@+id/headlines_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:transitionName="TRANSITION:HEADLINES_LIST"
android:layout_height="match_parent" > android:layout_height="match_parent" >
</ListView> </ListView>
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>