package me.jaxbot.wear.leafstatus;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

/**
 * Created by jonathan on 9/27/14.
 */
public class AlarmSetter {
    public static void setAlarm(Context context)
    {
        SharedPreferences settings = context.getSharedPreferences("U", 0);

        if (!settings.getBoolean("autoupdate", true)) return;

        Intent intent = new Intent(context, AlarmReceiver.class);
        PendingIntent sender = PendingIntent.getBroadcast(context, 2, intent, 0);

        int interval = (settings.getInt("interval", 0) + 15) * 60 * 1000;
        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + interval, interval, sender);

    }

    public static void setAlarmTemp(Context context, long time)
    {
        Intent intent = new Intent(context, AlarmReceiver.class);
        PendingIntent sender = PendingIntent.getBroadcast(context, 2, intent, 0);

        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        am.set(AlarmManager.RTC_WAKEUP, time, sender);
    }

    public static void cancelAlarm(Context context)
    {
        Intent intent = new Intent(context, AlarmReceiver.class);
        PendingIntent sender = PendingIntent.getBroadcast(context, 2, intent, 0);

        AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        am.cancel(sender);
    }
}

@@ -1022,32 +1022,157 @@
 eceiver.class);%0A
+        // Note the different requestCode%0A        // This allows us to run separate alarms for the schedule and the catch up%0A
         PendingI
@@ -1214,33 +1214,33 @@
 adcast(context, 
-2
+3
 , intent, 0);%0A%0A 

Change requestCode for temp alarms