package com.zoblak.farm;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class PeriodicalPingReceiver extends BroadcastReceiver {
    public PeriodicalPingReceiver() {
    }

    @Override
    public void onReceive(Context context, Intent intent)  {

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        String controllers = prefs.getString("controllers", null);
        Boolean isAlarmOn = prefs.getBoolean("alarm_set", false);

        if(isAlarmOn && controllers != null) {
            AlarmPollingService.startActionPing(context, controllers);
        }
    }
}
