Skip to content

Commit

Permalink
added async methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaflowski committed Mar 12, 2019
1 parent 96851b2 commit 214c76f
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.annotation.ColorInt;
import android.support.annotation.FloatRange;
import android.support.annotation.NonNull;
Expand Down Expand Up @@ -98,16 +99,27 @@ public MediaNotificationProcessor(Context context) {
this.context = context;
}

public void getPaletteAsync(OnPaletteLoadedListener onPaletteLoadedListener, Drawable drawable) {
public void getPaletteAsync(final OnPaletteLoadedListener onPaletteLoadedListener, Drawable drawable) {
this.drawable = drawable;
getMediaPalette();
onPaletteLoadedListener.onPaletteLoaded(this);
final Handler handler = new Handler();
new Thread(new Runnable() {
@Override
public void run() {
getMediaPalette();
handler.post(new Runnable() {
@Override
public void run() {
onPaletteLoadedListener.onPaletteLoaded(MediaNotificationProcessor.this);
}
});
}
}).start();

}

public void getPaletteAsync(OnPaletteLoadedListener onPaletteLoadedListener, Bitmap bitmap) {
this.drawable = new BitmapDrawable(context.getResources(), bitmap);
getMediaPalette();
onPaletteLoadedListener.onPaletteLoaded(this);
getPaletteAsync(onPaletteLoadedListener, this.drawable);
}


Expand Down

0 comments on commit 214c76f

Please sign in to comment.