diff --git a/bubblepicker/build.gradle b/bubblepicker/build.gradle index 478f33d..6585ebd 100644 --- a/bubblepicker/build.gradle +++ b/bubblepicker/build.gradle @@ -32,10 +32,10 @@ dependencies { implementation 'com.android.support:appcompat-v7:27.1.1' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.github.bumptech.glide:glide:3.8.0' implementation files('libs/jbox2d-library-2.1.2.2.jar') implementation files('libs/slf4j-api-1.7.22.jar') + implementation files('libs/universal-image-loader-1.9.5.jar') testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' diff --git a/bubblepicker/libs/universal-image-loader-1.9.5.jar b/bubblepicker/libs/universal-image-loader-1.9.5.jar new file mode 100644 index 0000000..520dac3 Binary files /dev/null and b/bubblepicker/libs/universal-image-loader-1.9.5.jar differ diff --git a/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/Item.kt b/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/Item.kt index 80fe9fb..b0e82c0 100755 --- a/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/Item.kt +++ b/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/Item.kt @@ -1,7 +1,6 @@ package com.kienht.bubblepicker.rendering import android.content.Context -import android.content.res.Resources import android.graphics.* import android.graphics.drawable.BitmapDrawable import android.opengl.GLES20.* @@ -10,7 +9,6 @@ import android.text.Layout import android.text.StaticLayout import android.text.TextPaint import android.text.TextUtils -import com.bumptech.glide.Glide import com.kienht.bubblepicker.model.BubbleGradient import com.kienht.bubblepicker.model.PickerItem import com.kienht.bubblepicker.physics.CircleBody @@ -19,8 +17,14 @@ import com.kienht.bubblepicker.toTexture import org.jbox2d.common.Vec2 import java.lang.ref.WeakReference import android.graphics.Bitmap -import com.bumptech.glide.load.engine.DiskCacheStrategy import com.kienht.bubblepicker.resizeBitmap +import com.nostra13.universalimageloader.core.ImageLoader +import com.nostra13.universalimageloader.core.ImageLoaderConfiguration +import com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache +import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer +import com.nostra13.universalimageloader.core.assist.ImageScaleType +import com.nostra13.universalimageloader.core.DisplayImageOptions +import com.nostra13.universalimageloader.core.assist.ImageSize /** @@ -84,14 +88,25 @@ data class Item(val context: WeakReference, private fun createBitmap(isSelected: Boolean): Bitmap { var bitmap = if (!TextUtils.isEmpty(pickerItem.imgUrl) && pickerItem.isUseImgUrl) { - val bmLoaded = Glide.with(context.get()) - .load(pickerItem.imgUrl) - .asBitmap() - .skipMemoryCache(true) - .into(bitmapSize.toInt() / 2, bitmapSize.toInt() / 2) - .get() - - bmLoaded.resizeBitmap(bitmapSize.toInt(), bitmapSize.toInt()) + + val imageLoader = ImageLoader.getInstance() + + val defaultOptions = DisplayImageOptions.Builder() + .cacheInMemory(true) + .imageScaleType(ImageScaleType.EXACTLY) + .bitmapConfig(Bitmap.Config.RGB_565) + .build() + + val config = ImageLoaderConfiguration.Builder(context.get()) + .defaultDisplayImageOptions(defaultOptions) + .memoryCache(WeakMemoryCache()) + .build() + + imageLoader.init(config) + + val bmp = imageLoader.loadImageSync(pickerItem.imgUrl, ImageSize(bitmapSize.toInt() / 2, bitmapSize.toInt() /2)) + + bmp.resizeBitmap(bitmapSize.toInt(), bitmapSize.toInt()) } else { Bitmap.createBitmap(bitmapSize.toInt(), bitmapSize.toInt(), Bitmap.Config.ARGB_4444) } @@ -108,6 +123,7 @@ data class Item(val context: WeakReference, drawBackground(canvas, isSelected) drawIcon(canvas) drawText(canvas) + return bitmap } diff --git a/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/PickerRenderer.kt b/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/PickerRenderer.kt index e7dfe00..f2d2509 100755 --- a/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/PickerRenderer.kt +++ b/bubblepicker/src/main/java/com/kienht/bubblepicker/rendering/PickerRenderer.kt @@ -5,8 +5,6 @@ import android.opengl.GLES20.* import android.opengl.GLSurfaceView import android.util.Log import android.view.View -import com.bumptech.glide.Glide -import com.bumptech.glide.RequestManager import com.kienht.bubblepicker.* import com.kienht.bubblepicker.model.Color import com.kienht.bubblepicker.model.PickerItem diff --git a/bubblepicker/src/main/res/drawable/test.jpg b/bubblepicker/src/main/res/drawable/test.jpg deleted file mode 100644 index e6377f0..0000000 Binary files a/bubblepicker/src/main/res/drawable/test.jpg and /dev/null differ