-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
133 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
core/src/main/java/de/danoeh/antennapod/core/glide/PaletteBitmap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.danoeh.antennapod.core.glide; | ||
|
||
import android.graphics.Bitmap; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.palette.graphics.Palette; | ||
|
||
public class PaletteBitmap { | ||
public final Palette palette; | ||
public final Bitmap bitmap; | ||
|
||
public PaletteBitmap(@NonNull Bitmap bitmap, Palette palette) { | ||
this.bitmap = bitmap; | ||
this.palette = palette; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
core/src/main/java/de/danoeh/antennapod/core/glide/PaletteBitmapResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package de.danoeh.antennapod.core.glide; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.bumptech.glide.load.engine.Resource; | ||
import com.bumptech.glide.util.Util; | ||
|
||
public class PaletteBitmapResource implements Resource<PaletteBitmap> { | ||
private final PaletteBitmap paletteBitmap; | ||
|
||
public PaletteBitmapResource(@NonNull PaletteBitmap paletteBitmap) { | ||
this.paletteBitmap = paletteBitmap; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Class<PaletteBitmap> getResourceClass() { | ||
return PaletteBitmap.class; | ||
} | ||
|
||
@NonNull | ||
@Override public PaletteBitmap get() { | ||
return paletteBitmap; | ||
} | ||
|
||
@Override public int getSize() { | ||
return Util.getBitmapByteSize(paletteBitmap.bitmap); | ||
} | ||
|
||
@Override public void recycle() { | ||
paletteBitmap.bitmap.recycle(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
core/src/main/java/de/danoeh/antennapod/core/glide/PaletteBitmapTranscoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.danoeh.antennapod.core.glide; | ||
|
||
import android.graphics.Bitmap; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.palette.graphics.Palette; | ||
|
||
import com.bumptech.glide.load.Options; | ||
import com.bumptech.glide.load.engine.Resource; | ||
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder; | ||
|
||
import de.danoeh.antennapod.core.preferences.UserPreferences; | ||
|
||
public class PaletteBitmapTranscoder implements ResourceTranscoder<Bitmap, PaletteBitmap> { | ||
|
||
@Nullable | ||
@Override | ||
public Resource<PaletteBitmap> transcode(@NonNull Resource<Bitmap> toTranscode, @NonNull Options options) { | ||
Bitmap bitmap = toTranscode.get(); | ||
Palette palette = null; | ||
if (UserPreferences.shouldShowSubscriptionTitle()) { | ||
palette = new Palette.Builder(bitmap).generate(); | ||
} | ||
PaletteBitmap result = new PaletteBitmap(bitmap, palette); | ||
return new PaletteBitmapResource(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters