File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed
rxjava-contrib/rxjava-android/src/main/java/rx/android/schedulers Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change 21
21
import rx .Subscription ;
22
22
import rx .functions .Action0 ;
23
23
import rx .functions .Action1 ;
24
+ import rx .internal .schedulers .ScheduledAction ;
24
25
import rx .subscriptions .BooleanSubscription ;
25
26
import rx .subscriptions .CompositeSubscription ;
26
27
import rx .subscriptions .Subscriptions ;
@@ -70,27 +71,18 @@ public boolean isUnsubscribed() {
70
71
71
72
@ Override
72
73
public Subscription schedule (final Action0 action , long delayTime , TimeUnit unit ) {
73
- final Runnable runnable = new Runnable () {
74
- @ Override
75
- public void run () {
76
- if (isUnsubscribed ()) {
77
- return ;
78
- }
79
- action .call ();
80
- }
81
- };
82
- handler .postDelayed (runnable , unit .toMillis (delayTime ));
83
-
84
- final Subscription subscription = Subscriptions .create (new Action0 () {
74
+ final ScheduledAction scheduledAction = new ScheduledAction (action );
75
+ scheduledAction .addParent (mCompositeSubscription );
76
+ scheduledAction .add (Subscriptions .create (new Action0 () {
85
77
@ Override
86
78
public void call () {
87
- handler .removeCallbacks (runnable );
88
-
79
+ handler .removeCallbacks (scheduledAction );
89
80
}
90
- });
91
- mCompositeSubscription .add (subscription );
81
+ }));
82
+
83
+ handler .postDelayed (scheduledAction , unit .toMillis (delayTime ));
92
84
93
- return Subscriptions . empty () ;
85
+ return scheduledAction ;
94
86
}
95
87
96
88
@ Override
You can’t perform that action at this time.
0 commit comments