package com.example.stimulus;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.example.notification.Notification;
import com.example.notification.SedentaryNotification;
import com.example.stimulusStrategy.StimulusStrategy;

import java.util.Observable;

/**
 * Created by pharmacy on 09/01/2018.
 */

class SedentaryStimulus extends BroadcastReceiver implements Stimulus {

    private StimulusStrategy strategy;

    public SedentaryStimulus(){
      //  this.context = context;
        chooseStrategy(null);
    }

    public SedentaryStimulus(StimulusStrategy s){
     //   this.context = context;
        chooseStrategy(s);
    }

    public Notification createNotification() {
        Notification notification = new SedentaryNotification();
        //Either further define this notification here or change to one line;
        return notification;
    }

    public void chooseStrategy(StimulusStrategy s) {
        if(s != null){
            strategy = s;
        } else{
           // strategy = defaultStrategy;
            //can no longer have default strategy in interface as strategies require context
        }
        //Should be context.startService('selectedstrategy') but require context here first? 
        strategy.monitor();
    }




    @Override
    public void onReceive(Context context, Intent intent) {
        //If a condition - such as time elapsed since last notification or not night time
        //Intent data used here to configure notification?? Intent would need to be configured properly for this.
        context.startService(intent);

    }

}