Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Dialog stores Entity instead of View

Signed-off-by: simonewebdesign <hello@simonewebdesign.it>
  • Loading branch information...
commit ac17612c6a93c088ff6d4ba6e0e581c376335c8e 1 parent 7614c4b
@simonewebdesign authored
View
2  src/com/example/todolist/ItemView.java
@@ -70,7 +70,7 @@ public boolean onLongClick(View v) {
// do something when the ItemView is longClicked
Log.v(TAG, "ItemView has been longClicked!");
- ItemViewDialogFragment dialog = new ItemViewDialogFragment((ItemView) v);
+ ItemViewDialogFragment dialog = new ItemViewDialogFragment(rowEntity);
dialog.show(((MainActivity) context).getSupportFragmentManager(), "dialog");
return false;
View
21 src/com/example/todolist/ItemViewDialogFragment.java
@@ -13,25 +13,21 @@
private final String TAG = "ItemViewDialogFragment";
// Use this instance of the interface to deliver action events
private ItemViewDialogListener mListener;
- private ItemView itemView;
-
- public ItemView getItemView() {
- return itemView;
- }
-
- public void setItemView(ItemView itemView) {
- this.itemView = itemView;
- }
+ private ToDoRow entity;
public ItemViewDialogFragment() {
super();
}
- public ItemViewDialogFragment(ItemView v) {
+ public ItemViewDialogFragment(ToDoRow row) {
super();
- itemView = v;
+ entity = row;
}
+ public ToDoRow getEntity() {
+ return entity;
+ }
+
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
@@ -81,7 +77,4 @@ public void onAttach(Activity activity) {
+ " must implement ItemViewDialogListener");
}
}
-
-
-
}
View
6 src/com/example/todolist/MainActivity.java
@@ -234,11 +234,11 @@ public void onDialogEditClick(DialogFragment dialog) {
@Override
public void onDialogDeleteClick(DialogFragment dialog) {
- // TODO Auto-generated method stub
+
Log.v(TAG, "onDialogDeleteClick");
- ItemView view = ((ItemViewDialogFragment) dialog).getItemView();
- todoRows.remove(view.getRowEntity());
+ ToDoRow row = ((ItemViewDialogFragment) dialog).getEntity();
+ todoRows.remove(row);
adapter.notifyDataSetChanged();
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.