Skip to content

Commit

Permalink
Delete All Data operation after deleting data individually in Logged …
Browse files Browse the repository at this point in the history
…Data

Fixes - issue fossasia#2172
Changes - When a user deletes all the data individually and then click "Delete All Data" in the menu in Data Logger Activity then a alert dialog appears showing the message "No Logged Data Found" with a button "Ok" which dismisses the dialog.
  • Loading branch information
kartikeysaran committed Jan 27, 2021
1 parent a9382a4 commit b396991
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
41 changes: 27 additions & 14 deletions app/src/main/java/io/pslab/activity/DataLoggerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,33 @@ public boolean onOptionsItemSelected(MenuItem item) {
break;
case R.id.delete_all:
Context context = DataLoggerActivity.this;
new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.delete))
.setMessage(context.getString(R.string.delete_all_message))
.setPositiveButton(context.getString(R.string.delete), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteAllProgressBar.setVisibility(View.VISIBLE);
new DeleteAllTask().execute();
}
}).setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create().show();
if(categoryData.size()>0){
new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.delete))
.setMessage(context.getString(R.string.delete_all_message))
.setPositiveButton(context.getString(R.string.delete), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
deleteAllProgressBar.setVisibility(View.VISIBLE);
new DeleteAllTask().execute();
}
}).setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create().show();
}
else{
new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.no_log_data_found))
.setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
DataLoggerActivity.this.toolbar.getMenu().findItem(R.id.delete_all).setVisible(false);
}
}).create().show();
}
break;
}
return super.onOptionsItemSelected(item);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1053,4 +1053,7 @@
<string name="github_developers_link">https://github.com/fossasia/pslab-android/graphs/contributors</string>
<string name="limit_dangerous">\"Dangerous\"</string>
<string name="limit_average">Average</string>

<string name="no_log_data_found">No Logged Data Found</string>

</resources>

0 comments on commit b396991

Please sign in to comment.