Added warning before remove entry
This commit is contained in:
parent
7bcbe46d91
commit
93c8d65cfa
2 changed files with 52 additions and 15 deletions
app/src/main
|
@ -60,23 +60,57 @@ public class ElementFragment extends Fragment implements AsyncDatabaseConnector.
|
|||
return rootView;
|
||||
}
|
||||
|
||||
private void actionSave(){
|
||||
List<String> fields = listAdapter.getFieldArray();
|
||||
Static.asyncDatabaseConnector.setStringReturnListener(this);
|
||||
if(getArguments().getBoolean(EDIT_ELEMENT))
|
||||
Static.asyncDatabaseConnector.updateElement(tableName, fields, values, getNewValues());
|
||||
else
|
||||
Static.asyncDatabaseConnector.addNewElement(tableName, fields, getNewValues());
|
||||
}
|
||||
|
||||
private void actionRemove(){
|
||||
final List<String> fields = listAdapter.getFieldArray();
|
||||
Static.asyncDatabaseConnector.setStringReturnListener(this);
|
||||
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage(R.string.error_remove);
|
||||
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Static.asyncDatabaseConnector.removeElement(tableName, fields, values);
|
||||
// getActivity().finish();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
// Nothing to do just get back
|
||||
}
|
||||
});
|
||||
builder.setTitle(R.string.warning);
|
||||
builder.setIcon(R.drawable.ic_action_warning);
|
||||
builder.setCancelable(false); // There is no exit
|
||||
builder.create();
|
||||
builder.show();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
List<String> fields = listAdapter.getFieldArray();
|
||||
if(item.getItemId() == R.id.action_save ){
|
||||
Static.asyncDatabaseConnector.setStringReturnListener(this);
|
||||
if(getArguments().getBoolean(EDIT_ELEMENT))
|
||||
Static.asyncDatabaseConnector.updateElement(tableName, fields, values, getNewValues());
|
||||
else
|
||||
Static.asyncDatabaseConnector.addNewElement(tableName, fields, getNewValues());
|
||||
return true;
|
||||
} else if(item.getItemId() == R.id.action_remove) {
|
||||
Static.asyncDatabaseConnector.setStringReturnListener(this);
|
||||
Static.asyncDatabaseConnector.removeElement(tableName, fields, values);
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
switch (item.getItemId()){
|
||||
case R.id.action_save:
|
||||
actionSave();
|
||||
break;
|
||||
case R.id.action_remove:
|
||||
actionRemove();
|
||||
break;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initArguments() {
|
||||
|
@ -152,9 +186,10 @@ public class ElementFragment extends Fragment implements AsyncDatabaseConnector.
|
|||
}
|
||||
});*/
|
||||
builder.setTitle(R.string.status);
|
||||
builder.setIcon(R.drawable.ic_action_warning); //TODO Change Icon
|
||||
builder.setIcon(R.drawable.ic_action_warning);
|
||||
builder.setCancelable(false); // There is no exit
|
||||
builder.create();
|
||||
builder.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
<string name="status">Status</string>
|
||||
<string name="back">Back</string>
|
||||
<string name="action_remove">Remove</string>
|
||||
<string name="error_remove">This entry will be removed from database. This action <b>CAN NOT</b> be reversed! Would you like to continue?</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue