Skip to content

Commit

Permalink
bitmap config error fix, sdk version changed to 19
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitjain240595 committed Jan 3, 2020
1 parent 5c66bbc commit 21d6d05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "29.0.1"
defaultConfig {
applicationId "com.app.trymosaic"
minSdkVersion 21
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
Expand Down
16 changes: 13 additions & 3 deletions mosaic/src/main/java/com/matrixdev/mosaic/MosaicView.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
import android.widget.Toast;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;

Expand Down Expand Up @@ -350,7 +354,8 @@ public static Bitmap createPlaceholder(int width, int height, int color) {
}

private Bitmap addRoundCorners(Bitmap bmp, int padding_y) {
Bitmap bmpWithBorder = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight() + padding_y, bmp.getConfig());

Bitmap bmpWithBorder = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight() + padding_y, bmp.getConfig()==null? Bitmap.Config.ARGB_8888 : bmp.getConfig());

RectF rect = new RectF();
rect.set(0, padding_y, bmp.getWidth(), bmp.getHeight() + padding_y);
Expand Down Expand Up @@ -545,9 +550,9 @@ public <T extends UrlContainer> void prepareFromUrl(ArrayList<T> objects, ItemCh
Glide.with(context)
.asBitmap()
.load(objects.get(i).toUrl())
.into(new SimpleTarget<Bitmap>() {
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
Log.d("----", "loaded" + finalI);
if (isRoundedEdges) {
Bitmap rounded = addRoundCorners(resource, random.get(finalI));
Expand All @@ -557,6 +562,11 @@ public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transiti
}
invalidate();
}

@Override
public void onLoadCleared(@Nullable Drawable placeholder) {

}
});
bitmapObjectClass.setGenericObject(objects.get(i));
bitmapObjectClasses.add(bitmapObjectClass);
Expand Down

0 comments on commit 21d6d05

Please sign in to comment.