Skip to content

Commit

Permalink
fixed crush on rotation change when displaying action dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mickey946 committed Mar 16, 2014
1 parent 3a171d6 commit ccabf51
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 10 deletions.
Binary file modified TodoListManager/bin/TodoListManager.apk
Binary file not shown.
Binary file modified TodoListManager/bin/classes.dex
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified TodoListManager/bin/resources.ap_
Binary file not shown.
6 changes: 3 additions & 3 deletions TodoListManager/res/layout/activity_add_new_todo_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin" />

<View
android:layout_width="fill_parent"
android:layout_height="1dp"
Expand All @@ -43,7 +43,7 @@
android:id="@+id/btnCancel"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:onClick="cancel"
android:text="@string/dialog_cancel_button" />
Expand All @@ -52,7 +52,7 @@
android:id="@+id/btnOK"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:onClick="add"
android:text="@string/action_add_todo_task" />
Expand Down
10 changes: 9 additions & 1 deletion TodoListManager/src/il/ac/huji/todolist/ActionTaskDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.ListAdapter;

/**
Expand All @@ -33,6 +32,8 @@ public ActionTaskDialog(int pos, String task) {
super();
_pos = pos;
_task = task;

setRetainInstance(true);
}

public int getPos() {
Expand Down Expand Up @@ -106,6 +107,13 @@ public void onClick(DialogInterface dialog, int id) {
// Create the AlertDialog object and return it
return builder.create();
}

@Override
public void onDestroyView() {
if (getDialog() != null && getRetainInstance())
getDialog().setDismissMessage(null);
super.onDestroyView();
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
public class TodoListManagerActivity extends Activity implements DeleteTaskDialogListener {

private RetainedFragment<ArrayList<Pair<String, Long>>> _dataFragment;

ArrayAdapter<Pair<String, Long>> _adapter;
ArrayList<Pair<String, Long>> _listItems;//= new ArrayList<Pair<String, Long>>();

private ArrayAdapter<Pair<String, Long>> _adapter;
private ArrayList<Pair<String, Long>> _listItems;

private ActionTaskDialog _actionTaskDialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -66,8 +66,8 @@ protected void onCreate(Bundle savedInstanceState) {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("NewApi")
public boolean onItemLongClick(AdapterView<?> parent, View child, int pos, long id) {
ActionTaskDialog actionTaskDialog = new ActionTaskDialog(pos, _listItems.get(pos).first);
actionTaskDialog.show(getFragmentManager(), "actionTask");
_actionTaskDialog = new ActionTaskDialog(pos, _listItems.get(pos).first);
_actionTaskDialog.show(getFragmentManager(), "actionTask");
return true;
}
});
Expand Down

0 comments on commit ccabf51

Please sign in to comment.