Skip to content

Commit

Permalink
Merge pull request #793 from hidroh/saved
Browse files Browse the repository at this point in the history
Revert "Render after data restoration"
  • Loading branch information
hidroh authored Dec 6, 2016
2 parents 237cc7d + be842ed commit 80d00a8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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", "\"\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<TestFavoriteActivity> 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() {
Expand Down

0 comments on commit 80d00a8

Please sign in to comment.