31
31
import com .simplecity .amp_library .utils .PlaceholderProvider ;
32
32
import com .simplecity .amp_library .utils .PlaylistUtils ;
33
33
import io .reactivex .android .schedulers .AndroidSchedulers ;
34
+ import io .reactivex .disposables .CompositeDisposable ;
34
35
import io .reactivex .schedulers .Schedulers ;
35
36
import java .util .ConcurrentModificationException ;
36
37
@@ -48,6 +49,8 @@ public class MusicNotificationHelper extends NotificationHelper {
48
49
49
50
private Handler handler ;
50
51
52
+ private CompositeDisposable compositeDisposable = new CompositeDisposable ();
53
+
51
54
public MusicNotificationHelper (Context context ) {
52
55
super (context );
53
56
@@ -106,7 +109,7 @@ public void notify(Context context, @NonNull Song song, boolean isPlaying, @NonN
106
109
notification = getBuilder (context , song , mediaSessionToken , bitmap , isPlaying , isFavorite ).build ();
107
110
notify (NOTIFICATION_ID , notification );
108
111
109
- PlaylistUtils .isFavorite (song )
112
+ compositeDisposable . add ( PlaylistUtils .isFavorite (song )
110
113
.first (false )
111
114
.subscribeOn (Schedulers .io ())
112
115
.observeOn (AndroidSchedulers .mainThread ())
@@ -116,7 +119,7 @@ public void notify(Context context, @NonNull Song song, boolean isPlaying, @NonN
116
119
notify (notification );
117
120
}, error -> {
118
121
LogUtils .logException (TAG , "MusicNotificationHelper failed to present notification" , error );
119
- });
122
+ })) ;
120
123
121
124
handler .post (() -> Glide .with (context )
122
125
.load (song )
@@ -172,4 +175,8 @@ public void notify(Notification notification) {
172
175
public void cancel () {
173
176
super .cancel (NOTIFICATION_ID );
174
177
}
178
+
179
+ public void tearDown () {
180
+ compositeDisposable .clear ();
181
+ }
175
182
}
0 commit comments