diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/EventHelper.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/EventHelper.java index fb9b986..0789fe6 100644 --- a/WhenRobo/src/main/java/houtbecke/rs/when/robo/EventHelper.java +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/EventHelper.java @@ -18,6 +18,8 @@ import houtbecke.rs.when.robo.act.event.InvalidateMenus; import houtbecke.rs.when.robo.condition.event.ActivityPause; +import houtbecke.rs.when.robo.condition.event.ActivityPostPause; +import houtbecke.rs.when.robo.condition.event.ActivityPostResume; import houtbecke.rs.when.robo.condition.event.ActivityResume; import houtbecke.rs.when.robo.condition.event.FragmentPause; import houtbecke.rs.when.robo.condition.event.FragmentResume; @@ -65,6 +67,7 @@ public void onResume(Activity a) { bus.post(new ActivityResume(a)); bus.register(this); bus.register(a); + bus.register(new ActivityPostResume(a)); } public void onResume(Fragment f) { @@ -77,6 +80,7 @@ public void onPause(Activity a) { bus.post(new ActivityPause(a)); bus.unregister(this); bus.unregister(a); + bus.post(new ActivityPostPause(a)); } public void onPause(Fragment f) { diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/Active.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/Active.java index c162fa9..ed4cbfa 100644 --- a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/Active.java +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/Active.java @@ -10,6 +10,6 @@ public class Active extends BaseActive { @Inject public Active(Bus bus) { - super(bus, true, false); + super(bus, true, false, false, false); } } diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/BaseActive.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/BaseActive.java index f1e4edd..fc0d804 100644 --- a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/BaseActive.java +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/BaseActive.java @@ -8,6 +8,8 @@ import houtbecke.rs.when.BasePushCondition; import houtbecke.rs.when.robo.condition.event.ActivityPause; +import houtbecke.rs.when.robo.condition.event.ActivityPostPause; +import houtbecke.rs.when.robo.condition.event.ActivityPostResume; import houtbecke.rs.when.robo.condition.event.ActivityResume; import houtbecke.rs.when.robo.condition.event.FragmentPause; import houtbecke.rs.when.robo.condition.event.FragmentResume; @@ -19,13 +21,15 @@ public abstract class BaseActive extends BasePushCondition { // maybe use a weakhashmap to track behaviour for multiple object of same classes etc. - final boolean onPause, onResume; + final boolean onPause, onResume, onPostPause, onPostResume; @Inject - public BaseActive(Bus bus, Boolean onResume, Boolean onPause) { + public BaseActive(Bus bus, Boolean onResume, Boolean onPause, Boolean onPostResume, Boolean onPostPause) { subscriber = new Subscriber(bus); this.onResume = onResume; this.onPause = onPause; + this.onPostResume = onPostResume; + this.onPostPause = onPostPause; } final Subscriber subscriber; @@ -46,6 +50,16 @@ public void onActivityEvent(ActivityPause event) { onPause(event); } + @Subscribe + public void onActivityEvent(ActivityPostPause event) { + onPostPause(event); + } + + @Subscribe + public void onActivityEvent(ActivityPostResume event) { + onPostResume(event); + } + @Subscribe public void onFragmentEvent(FragmentResume event) { onResume(event); @@ -69,5 +83,16 @@ void onResume(ResumeEvent resume) { stickForThing(resume.getResourceId(),onResume); } + void onPostPause(PauseEvent pause) { + stickForThing(pause.getSourceClass(), onPostPause); + stickForThing(pause.getObject(), onPostPause); + stickForThing(pause.getResourceId(), onPostPause); + } + + void onPostResume(ResumeEvent resume) { + stickForThing(resume.getSourceClass(),onPostResume); + stickForThing(resume.getObject(),onPostResume); + stickForThing(resume.getResourceId(),onPostResume); + } } diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/NotActive.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/NotActive.java index 5887df7..ed5c3f0 100644 --- a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/NotActive.java +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/NotActive.java @@ -20,7 +20,7 @@ public class NotActive extends BaseActive { @Inject public NotActive(Bus bus) { - super(bus, false, true); + super(bus, false, true, false, false); } } diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/NotPostActive.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/NotPostActive.java new file mode 100644 index 0000000..65bb393 --- /dev/null +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/NotPostActive.java @@ -0,0 +1,16 @@ +package houtbecke.rs.when.robo.condition; + +import com.squareup.otto.Bus; + +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +public class NotPostActive extends BaseActive { + + @Inject + public NotPostActive(Bus bus) { + super(bus, false, false, false, true); + } + +} diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/PostActive.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/PostActive.java new file mode 100644 index 0000000..25140eb --- /dev/null +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/PostActive.java @@ -0,0 +1,15 @@ +package houtbecke.rs.when.robo.condition; + +import com.squareup.otto.Bus; + +import javax.inject.Inject; +import javax.inject.Singleton; + +@Singleton +public class PostActive extends BaseActive { + + @Inject + public PostActive(Bus bus) { + super(bus, true, false, false, false); + } +} diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/event/ActivityPostPause.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/event/ActivityPostPause.java new file mode 100644 index 0000000..9d9e54b --- /dev/null +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/event/ActivityPostPause.java @@ -0,0 +1,11 @@ +package houtbecke.rs.when.robo.condition.event; + +import android.app.Activity; + +import houtbecke.rs.when.robo.event.PauseEvent; + +public class ActivityPostPause extends ActivityEvent implements PauseEvent { + public ActivityPostPause(Activity activity) { + super(activity); + } +} diff --git a/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/event/ActivityPostResume.java b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/event/ActivityPostResume.java new file mode 100644 index 0000000..a45c022 --- /dev/null +++ b/WhenRobo/src/main/java/houtbecke/rs/when/robo/condition/event/ActivityPostResume.java @@ -0,0 +1,12 @@ +package houtbecke.rs.when.robo.condition.event; + +import android.app.Activity; + +import houtbecke.rs.when.robo.event.ResumeEvent; + +public class ActivityPostResume extends ActivityEvent implements ResumeEvent { + + public ActivityPostResume(Activity activity) { + super(activity); + } +}