|
@ -17,10 +17,6 @@ import java.io.IOException |
|
|
|
|
|
|
|
|
object BitmapUtils { |
|
|
object BitmapUtils { |
|
|
private val bitmapMemoryCache: LruCache<String, Bitmap> |
|
|
private val bitmapMemoryCache: LruCache<String, Bitmap> |
|
|
|
|
|
|
|
|
// private val appExecutors = AppExecutors |
|
|
|
|
|
// private val callbackHandlers = Executors |
|
|
|
|
|
// .newCachedThreadPool { r: Runnable? -> Thread(r, "bm-load-callback-handler#" + random(0, 100)) } |
|
|
|
|
|
const val THUMBNAIL_SIZE = 200f |
|
|
const val THUMBNAIL_SIZE = 200f |
|
|
|
|
|
|
|
|
@JvmStatic |
|
|
@JvmStatic |
|
@ -53,7 +49,6 @@ object BitmapUtils { |
|
|
* @param reqWidth Required width |
|
|
* @param reqWidth Required width |
|
|
* @param reqHeight Required height |
|
|
* @param reqHeight Required height |
|
|
* @param addToCache true if the loaded bitmap should be added to the mem cache |
|
|
* @param addToCache true if the loaded bitmap should be added to the mem cache |
|
|
// * @param callback Bitmap load callback |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
suspend fun loadBitmap( |
|
|
suspend fun loadBitmap( |
|
|
contentResolver: ContentResolver?, |
|
|
contentResolver: ContentResolver?, |
|
@ -70,7 +65,6 @@ object BitmapUtils { |
|
|
* @param uri Uri from where Bitmap will be loaded |
|
|
* @param uri Uri from where Bitmap will be loaded |
|
|
* @param maxDimenSize Max size of the largest side of the image |
|
|
* @param maxDimenSize Max size of the largest side of the image |
|
|
* @param addToCache true if the loaded bitmap should be added to the mem cache |
|
|
* @param addToCache true if the loaded bitmap should be added to the mem cache |
|
|
// * @param callback Bitmap load callback |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
suspend fun loadBitmap( |
|
|
suspend fun loadBitmap( |
|
|
contentResolver: ContentResolver?, |
|
|
contentResolver: ContentResolver?, |
|
@ -88,7 +82,6 @@ object BitmapUtils { |
|
|
* @param reqHeight Required height (set to -1 if maxDimenSize provided) |
|
|
* @param reqHeight Required height (set to -1 if maxDimenSize provided) |
|
|
* @param maxDimenSize Max size of the largest side of the image (set to -1 if setting reqWidth and reqHeight) |
|
|
* @param maxDimenSize Max size of the largest side of the image (set to -1 if setting reqWidth and reqHeight) |
|
|
* @param addToCache true if the loaded bitmap should be added to the mem cache |
|
|
* @param addToCache true if the loaded bitmap should be added to the mem cache |
|
|
// * @param callback Bitmap load callback |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
private suspend fun loadBitmap( |
|
|
private suspend fun loadBitmap( |
|
|
contentResolver: ContentResolver?, |
|
|
contentResolver: ContentResolver?, |
|
@ -227,16 +220,6 @@ object BitmapUtils { |
|
|
|
|
|
|
|
|
class BitmapResult(var bitmap: Bitmap?, var width: Int, var height: Int) |
|
|
class BitmapResult(var bitmap: Bitmap?, var width: Int, var height: Int) |
|
|
|
|
|
|
|
|
interface ThumbnailLoadCallback { |
|
|
|
|
|
/** |
|
|
|
|
|
* @param bitmap Resulting bitmap |
|
|
|
|
|
* @param width width of the bitmap (Only correct if loadBitmap was called or -1) |
|
|
|
|
|
* @param height height of the bitmap (Only correct if loadBitmap was called or -1) |
|
|
|
|
|
*/ |
|
|
|
|
|
fun onLoad(bitmap: Bitmap, width: Int, height: Int) |
|
|
|
|
|
fun onFailure(t: Throwable) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
init { |
|
|
// Get max available VM memory, exceeding this amount will throw an |
|
|
// Get max available VM memory, exceeding this amount will throw an |
|
|
// OutOfMemory exception. Stored in kilobytes as LruCache takes an |
|
|
// OutOfMemory exception. Stored in kilobytes as LruCache takes an |
|
|