prevent restoring latest fragment when rotating

This commit is contained in:
tobiasKaminsky 2017-05-05 14:42:08 +02:00
parent 9211578a55
commit 3735cec70c
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 13 additions and 4 deletions

View file

@ -93,7 +93,7 @@ public class ExtendedListFragment extends Fragment
private static final String KEY_IS_GRID_VISIBLE = "IS_GRID_VISIBLE"; private static final String KEY_IS_GRID_VISIBLE = "IS_GRID_VISIBLE";
protected SwipeRefreshLayout mRefreshListLayout; protected SwipeRefreshLayout mRefreshListLayout;
private SwipeRefreshLayout mRefreshGridLayout; protected SwipeRefreshLayout mRefreshGridLayout;
protected SwipeRefreshLayout mRefreshEmptyLayout; protected SwipeRefreshLayout mRefreshEmptyLayout;
protected LinearLayout mEmptyListContainer; protected LinearLayout mEmptyListContainer;
protected TextView mEmptyListMessage; protected TextView mEmptyListMessage;

View file

@ -666,7 +666,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putParcelable(KEY_FILE, mFile); outState.putParcelable(KEY_FILE, mFile);
outState.putParcelable(KEY_CURRENT_SEARCH_TYPE, Parcels.wrap(currentSearchType)); if (searchFragment) {
outState.putParcelable(KEY_CURRENT_SEARCH_TYPE, Parcels.wrap(currentSearchType));
}
mMultiChoiceModeListener.storeStateIn(outState); mMultiChoiceModeListener.storeStateIn(outState);
} }
@ -1242,6 +1244,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
setTitle(R.string.default_display_name_for_root_folder); setTitle(R.string.default_display_name_for_root_folder);
} }
getActivity().getIntent().removeExtra(OCFileListFragment.SEARCH_EVENT);
getArguments().putParcelable(OCFileListFragment.SEARCH_EVENT, null);
setFabEnabled(true); setFabEnabled(true);
} }
@ -1468,10 +1473,14 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
@Override @Override
public void onRefresh() { public void onRefresh() {
super.onRefresh();
if (searchEvent != null && searchFragment) { if (searchEvent != null && searchFragment) {
onMessageEvent(searchEvent); onMessageEvent(searchEvent);
mRefreshListLayout.setRefreshing(false);
mRefreshGridLayout.setRefreshing(false);
mRefreshEmptyLayout.setRefreshing(false);
} else {
super.onRefresh();
} }
} }