Skip to content

Commit

Permalink
Merge pull request #43 from NightscoutFoundation/tzachi-remove-snooze…
Browse files Browse the repository at this point in the history
…-dialog

Automatically close the remote snooze confirmation dialog after 120 seconds if it is not confirmed or cancelled.
  • Loading branch information
jamorham committed Dec 13, 2016
2 parents 1d190d1 + e005607 commit 72ead4b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion app/src/main/java/com/eveningoutpost/dexdrip/GcmActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
Expand Down Expand Up @@ -383,8 +384,29 @@ public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
final AlertDialog alert = builder.create();
alert.show();
// Hide after some seconds
final Handler handler = new Handler();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (alert.isShowing()) {
alert.dismiss();
}
}
};

alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
handler.removeCallbacks(runnable);
}
});

handler.postDelayed(runnable, 120000);


}

public static void sendMotionUpdate(final long timestamp, final int activity) {
Expand Down

0 comments on commit 72ead4b

Please sign in to comment.