Skip to content

Commit

Permalink
progressDialog
Browse files Browse the repository at this point in the history
show a progress dialog to avoid user inadvertantly killing the process while the task is running
  • Loading branch information
forrestguice committed Dec 7, 2018
1 parent e8e3d61 commit 6a3fce1
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import android.app.Activity;
import android.app.AlertDialog;

import android.app.ProgressDialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ContentResolver;
Expand Down Expand Up @@ -463,17 +464,30 @@ private static boolean runCalendarTask(final Activity activity, boolean enabled)
}
calendarTask.setTaskListener(new SuntimesCalendarTask.SuntimesCalendarTaskListener()
{
private ProgressDialog progress;

@Override
public void onStarted(boolean flag_clear)
{
if (!flag_clear) {
Toast.makeText(activity, activity.getString(R.string.calendars_notification_adding), Toast.LENGTH_SHORT).show();
if (!flag_clear)
{
//Toast.makeText(activity, activity.getString(R.string.calendars_notification_adding), Toast.LENGTH_SHORT).show();

progress = new ProgressDialog(activity);
progress.setIndeterminate(true);
progress.setMessage(activity.getString(R.string.calendars_notification_adding));
progress.setCanceledOnTouchOutside(false);
progress.show();
}
}

@Override
public void onSuccess(boolean flag_clear)
{
if (progress != null) {
progress.dismiss();
}

if (!flag_clear)
Toast.makeText(activity, activity.getString(R.string.calendars_notification_added), Toast.LENGTH_SHORT).show();
else Toast.makeText(activity, activity.getString(R.string.calendars_notification_cleared), Toast.LENGTH_SHORT).show();
Expand All @@ -482,6 +496,10 @@ public void onSuccess(boolean flag_clear)
@Override
public void onFailed(final String errorMsg)
{
if (progress != null) {
progress.dismiss();
}

super.onFailed(errorMsg);
AlertDialog.Builder errorDialog = new AlertDialog.Builder(activity);
errorDialog.setTitle(activity.getString(R.string.calendars_notification_adding_failed))
Expand Down

0 comments on commit 6a3fce1

Please sign in to comment.