Prevent alarm cancellation from triggering null value exception, remove unused function, remove unnecessary imports.

This commit is contained in:
Timothy Allen 2014-04-20 23:04:32 +02:00
parent 2bb2bdc3bc
commit 7810231e19
4 changed files with 1 additions and 19 deletions

View File

@ -1,13 +1,9 @@
package za.org.treehouse.hypoalarm; package za.org.treehouse.hypoalarm;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service; import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.PowerManager; import android.os.PowerManager;
@ -23,12 +19,12 @@ public class AlarmService extends Service {
private static PowerManager.WakeLock wl; private static PowerManager.WakeLock wl;
private static Intent alarmServiceIntent, alertActivityIntent, notifyIntent; private static Intent alarmServiceIntent, alertActivityIntent, notifyIntent;
private static Boolean alarmStarted = false; private static Boolean alarmStarted = false;
public static volatile String alarmStatus; // Register ALARM_DISMISSED and its brethren here
public static final String ALARM_RUNNING = "ALARM_RUNNING"; public static final String ALARM_RUNNING = "ALARM_RUNNING";
public static final String ALARM_DISMISSED = "ALARM_DISMISSED"; public static final String ALARM_DISMISSED = "ALARM_DISMISSED";
public static final String ALARM_IGNORED = "ALARM_IGNORED"; public static final String ALARM_IGNORED = "ALARM_IGNORED";
public static final String ALARM_SNOOZED = "ALARM_SNOOZED"; public static final String ALARM_SNOOZED = "ALARM_SNOOZED";
public static final String ALARM_SNOOZE_RUNNING = "ALARM_SNOOZE_RUNNING"; public static final String ALARM_SNOOZE_RUNNING = "ALARM_SNOOZE_RUNNING";
public static volatile String alarmStatus = ALARM_DISMISSED; // Register ALARM_DISMISSED and its brethren here
public static long graceEndTime; public static long graceEndTime;
@Override @Override

View File

@ -1,12 +1,9 @@
package za.org.treehouse.hypoalarm; package za.org.treehouse.hypoalarm;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;

View File

@ -1,7 +1,5 @@
package za.org.treehouse.hypoalarm; package za.org.treehouse.hypoalarm;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;

View File

@ -712,15 +712,6 @@ public class MainActivity extends ActionBarActivity {
return remMinutes + minStr; return remMinutes + minStr;
} }
// TODO remove this function?
public static Calendar minutesAgo(int minutes) {
// Negate number to get minutes in the past.
minutes = minutes * -1;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MINUTE, minutes);
return cal;
}
public static String debugDate(Calendar cal) { public static String debugDate(Calendar cal) {
SimpleDateFormat print = new SimpleDateFormat("dd-MM-yyyy HH:mm:ssZ"); SimpleDateFormat print = new SimpleDateFormat("dd-MM-yyyy HH:mm:ssZ");
return print.format(cal.getTime()); return print.format(cal.getTime());