Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Handle rotation correctly
Browse files Browse the repository at this point in the history
fixes #15

Signed-off-by: Jonas Kalderstam <[email protected]>
  • Loading branch information
spacecowboy committed Apr 29, 2015
1 parent 3535459 commit 9857de8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project-wide Gradle settings.

VERSION_NAME=2.0.3
VERSION_CODE=13
VERSION_NAME=2.0.4
VERSION_CODE=14
GROUP=com.nononsenseapps

PROJECT_NAME=com.nononsenseapps:filepicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ protected FileItemAdapter<T> getDummyAdapter() {
public AbstractFilePickerFragment() {
checkedItems = new HashSet<>();
checkedVisibleViewHolders = new HashSet<>();

// Retain this fragment across configuration changes, to allow
// asynctasks and such to be used with ease.
setRetainInstance(true);
}

/**
Expand Down Expand Up @@ -236,9 +240,26 @@ public void onAttach(Activity activity) {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Retain this fragment across configuration changes.
setRetainInstance(true);

setHasOptionsMenu(true);
}

/**
* Called when the fragment's activity has been created and this
* fragment's view hierarchy instantiated. It can be used to do final
* initialization once these pieces are in place, such as retrieving
* views or restoring state. It is also useful for fragments that use
* {@link #setRetainInstance(boolean)} to retain their instance,
* as this callback tells the fragment when it is fully associated with
* the new activity instance. This is called after {@link #onCreateView}
* and before {@link #onViewStateRestored(Bundle)}.
*
* @param savedInstanceState If the fragment is being re-created from
* a previous saved state, this is the state.
*/
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Only if we have no state
if (currentPath == null) {
if (savedInstanceState != null) {
Expand Down Expand Up @@ -268,8 +289,6 @@ public void onCreate(Bundle savedInstanceState) {
}

refresh();

setHasOptionsMenu(true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
Expand All @@ -45,9 +46,9 @@ public void setListener(final OnNewFolderListener listener) {
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
setRetainInstance(true);
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
Expand Down
3 changes: 3 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2.0.4
Handle device rotation, fixes #15.

# 2.0.3
Fix a crash because of fauly view initiation.
Item layout's imageview now has fixed size.
Expand Down

0 comments on commit 9857de8

Please sign in to comment.