From 6b036aedbe0027401ad7605b4ac5e0fc44770bcc Mon Sep 17 00:00:00 2001 From: Ha Duy Trung Date: Tue, 6 Dec 2016 20:55:26 +0800 Subject: [PATCH 1/2] Revert "Render after data restoration" This reverts commit 7b6c0b0bd8864aafbc2eac6dda78d5875aaa0847. --- .../hidroh/materialistic/BaseListFragment.java | 6 +----- .../hidroh/materialistic/FavoriteFragment.java | 15 +-------------- .../materialistic/FavoriteActivityTest.java | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/github/hidroh/materialistic/BaseListFragment.java b/app/src/main/java/io/github/hidroh/materialistic/BaseListFragment.java index 5f0c819e1..a58fa6e1a 100644 --- a/app/src/main/java/io/github/hidroh/materialistic/BaseListFragment.java +++ b/app/src/main/java/io/github/hidroh/materialistic/BaseListFragment.java @@ -85,15 +85,11 @@ public void getItemOffsets(Rect outRect, View view, RecyclerView parent, public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getAdapter().setCustomTabsDelegate(mCustomTabsDelegate); - setAdapter(savedInstanceState); + mRecyclerView.setAdapter(getAdapter()); mScrollableHelper = new KeyDelegate.RecyclerViewHelper(mRecyclerView, KeyDelegate.RecyclerViewHelper.SCROLL_PAGE); } - protected void setAdapter(Bundle savedInstanceState) { - mRecyclerView.setAdapter(getAdapter()); - } - @Override protected void createOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_list, menu); diff --git a/app/src/main/java/io/github/hidroh/materialistic/FavoriteFragment.java b/app/src/main/java/io/github/hidroh/materialistic/FavoriteFragment.java index d7f62fe06..9214282fb 100644 --- a/app/src/main/java/io/github/hidroh/materialistic/FavoriteFragment.java +++ b/app/src/main/java/io/github/hidroh/materialistic/FavoriteFragment.java @@ -53,7 +53,6 @@ public class FavoriteFragment extends BaseListFragment @Inject AlertDialogBuilder mAlertDialogBuilder; private View mEmptySearchView; private View mEmptyView; - private boolean mLoaded; @Override public void onCreate(Bundle savedInstanceState) { @@ -150,13 +149,6 @@ public void filter(String query) { mFavoriteManager.attach(getActivity(), getLoaderManager(), this, mFilter); } - @Override - protected void setAdapter(Bundle savedInstanceState) { - if (savedInstanceState == null || mLoaded) { - super.setAdapter(savedInstanceState); - } - } - @Override protected ListRecyclerViewAdapter getAdapter() { return mAdapter; @@ -185,12 +177,7 @@ public void stopActionMode() { @Override public void onChanged() { - if (!mLoaded) { - mLoaded = true; - setAdapter(null); - } else { - mAdapter.notifyChanged(); - } + mAdapter.notifyChanged(); if (!isDetached()) { toggleEmptyView(mAdapter.getItemCount() == 0, mFilter); getActivity().supportInvalidateOptionsMenu(); diff --git a/app/src/test/java/io/github/hidroh/materialistic/FavoriteActivityTest.java b/app/src/test/java/io/github/hidroh/materialistic/FavoriteActivityTest.java index 563253aaf..7334536e2 100644 --- a/app/src/test/java/io/github/hidroh/materialistic/FavoriteActivityTest.java +++ b/app/src/test/java/io/github/hidroh/materialistic/FavoriteActivityTest.java @@ -8,6 +8,7 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Build; +import android.os.Bundle; import android.support.design.widget.AppBarLayout; import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager; @@ -260,6 +261,23 @@ public void testFilter() { any(LocalItemManager.Observer.class), eq("ask")); } + @Test + public void testSaveState() { + Bundle outState = new Bundle(); + controller.saveInstanceState(outState); + ActivityController controller = Robolectric + .buildActivity(TestFavoriteActivity.class) + .create(outState) + .postCreate(outState) + .start() + .resume() + .visible(); + assertEquals(2, ((RecyclerView) controller.get().findViewById(R.id.recycler_view)) + .getAdapter().getItemCount()); + controller.pause().stop().destroy(); + reset(keyDelegate); + } + @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Test public void testVoteItem() { From be842eda4b35c0eabad937be9863b5fac901a2b9 Mon Sep 17 00:00:00 2001 From: Ha Duy Trung Date: Tue, 6 Dec 2016 20:55:43 +0800 Subject: [PATCH 2/2] Bump up version --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index a6f45f95d..0b3274dde 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ android { applicationId "io.github.hidroh.materialistic" minSdkVersion 9 targetSdkVersion 25 // TODO http://b.android.com/212316 - versionCode 68 + versionCode 69 versionName "3.1" buildConfigField "int", "LATEST_RELEASE", "62" buildConfigField "String", "GITHUB_TOKEN", "\"\""