Skip to content

Commit

Permalink
Prompt for failure to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
renyuneyun committed May 20, 2018
1 parent a2e4f30 commit 5da3a16
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,17 @@ protected void onDestroy() {
protected boolean persistChange() {
try {
boolean success;
if (purpose == EditDataProto.Purpose.delete)
if (purpose == EditDataProto.Purpose.delete) {
success = storage.delete(oldName);
else {
if (success) {
setResult(RESULT_OK);
Logger.d("Successfully deleted " + TAG_DATA_TYPE);
finish();
} else {
Logger.e("Failed to delete " + TAG_DATA_TYPE);
Toast.makeText(this, getString(R.string.prompt_delete_failed), Toast.LENGTH_SHORT).show();
}
} else {
try {
T newData = saveToData();
if (newData == null || !newData.isValid()) {
Expand All @@ -162,14 +170,14 @@ protected boolean persistChange() {
Toast.makeText(this, getString(R.string.prompt_data_illegal), Toast.LENGTH_LONG).show();
return false;
}
}
if (success) {
setResult(RESULT_OK);
Logger.d("Successfully altered " + TAG_DATA_TYPE);
finish();
} else {
Logger.e("Failed to alter " + TAG_DATA_TYPE);
Toast.makeText(this, getString(R.string.prompt_save_failed), Toast.LENGTH_SHORT).show();
if (success) {
setResult(RESULT_OK);
Logger.d("Successfully saved " + TAG_DATA_TYPE);
finish();
} else {
Logger.e("Failed to save " + TAG_DATA_TYPE);
Toast.makeText(this, getString(R.string.prompt_save_failed), Toast.LENGTH_SHORT).show();
}
}
return success;
} catch (IOException e) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@
<string name="hint_condition_title">狀況名</string>
<string name="text_use_condition">使用狀況</string>
<string name="pref_restart_after_upgrade_title">更新後自動重啓服務</string>
<string name="prompt_delete_failed">刪除失敗。請檢查此物是否被使用。</string>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

<string name="prompt_save_failed">Failed to save</string>
<string name="prompt_delete">Are you sure to delete: %s</string>
<string name="prompt_delete_failed">Failed to delete. Check if this item is being used.</string>
<string name="prompt_data_illegal">Prevented saving data with invalid field(s). Please recheck your choices / inputs.</string>

<string name="prompt_prevented_for_permission">Easer needs permission &lt;%s&gt; for this function.</string>
Expand Down

0 comments on commit 5da3a16

Please sign in to comment.