diff --git a/app/build.gradle b/app/build.gradle index bd9d28f..1deb6d8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/mosaic/src/main/java/com/matrixdev/mosaic/MosaicView.java b/mosaic/src/main/java/com/matrixdev/mosaic/MosaicView.java index 6f58b28..21a0b3b 100644 --- a/mosaic/src/main/java/com/matrixdev/mosaic/MosaicView.java +++ b/mosaic/src/main/java/com/matrixdev/mosaic/MosaicView.java @@ -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; @@ -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); @@ -545,9 +550,9 @@ public void prepareFromUrl(ArrayList objects, ItemCh Glide.with(context) .asBitmap() .load(objects.get(i).toUrl()) - .into(new SimpleTarget() { + .into(new CustomTarget() { @Override - public void onResourceReady(Bitmap resource, Transition transition) { + public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition transition) { Log.d("----", "loaded" + finalI); if (isRoundedEdges) { Bitmap rounded = addRoundCorners(resource, random.get(finalI)); @@ -557,6 +562,11 @@ public void onResourceReady(Bitmap resource, Transition transiti } invalidate(); } + + @Override + public void onLoadCleared(@Nullable Drawable placeholder) { + + } }); bitmapObjectClass.setGenericObject(objects.get(i)); bitmapObjectClasses.add(bitmapObjectClass);