Skip to content
Snippets Groups Projects
SedentaryStimulus.java 1.58 KiB
Newer Older
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 {
    public SedentaryStimulus(Context context){
        this.context = context;
    public SedentaryStimulus(Context context, StimulusStrategy s){
        this.context = context;
        chooseStrategy(s);
    }


    public void chooseStrategy(StimulusStrategy s) {
        if(s != null){
            strategy = s;
        } else{
            //can no longer have default strategy in interface as strategies require context
        Intent intent = new Intent(this.context, strategy.getClass());
        this.context.startService(intent);
    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.
        //For clock-based detection/alarm setting needs to be restarted here.

        //chooseStrategy(context.);