3131import com .simplecity .amp_library .utils .PlaceholderProvider ;
3232import com .simplecity .amp_library .utils .PlaylistUtils ;
3333import io .reactivex .android .schedulers .AndroidSchedulers ;
34+ import io .reactivex .disposables .CompositeDisposable ;
3435import io .reactivex .schedulers .Schedulers ;
3536import java .util .ConcurrentModificationException ;
3637
@@ -48,6 +49,8 @@ public class MusicNotificationHelper extends NotificationHelper {
4849
4950 private Handler handler ;
5051
52+ private CompositeDisposable compositeDisposable = new CompositeDisposable ();
53+
5154 public MusicNotificationHelper (Context context ) {
5255 super (context );
5356
@@ -106,7 +109,7 @@ public void notify(Context context, @NonNull Song song, boolean isPlaying, @NonN
106109 notification = getBuilder (context , song , mediaSessionToken , bitmap , isPlaying , isFavorite ).build ();
107110 notify (NOTIFICATION_ID , notification );
108111
109- PlaylistUtils .isFavorite (song )
112+ compositeDisposable . add ( PlaylistUtils .isFavorite (song )
110113 .first (false )
111114 .subscribeOn (Schedulers .io ())
112115 .observeOn (AndroidSchedulers .mainThread ())
@@ -116,7 +119,7 @@ public void notify(Context context, @NonNull Song song, boolean isPlaying, @NonN
116119 notify (notification );
117120 }, error -> {
118121 LogUtils .logException (TAG , "MusicNotificationHelper failed to present notification" , error );
119- });
122+ })) ;
120123
121124 handler .post (() -> Glide .with (context )
122125 .load (song )
@@ -172,4 +175,8 @@ public void notify(Notification notification) {
172175 public void cancel () {
173176 super .cancel (NOTIFICATION_ID );
174177 }
178+
179+ public void tearDown () {
180+ compositeDisposable .clear ();
181+ }
175182}
0 commit comments