|
@@ -45,9 +45,9 @@ class ImageGetterAsyncTask(
|
45
|
45
|
try {
|
46
|
46
|
k = URL(source).content as InputStream
|
47
|
47
|
val options = BitmapFactory.Options()
|
48
|
|
- options.inSampleSize = 1/4
|
49
|
|
- // this makes 1/2 of origin image size from width and height.
|
50
|
|
- // it alleviates the memory for API16-API19 especially
|
|
48
|
+ options.inSampleSize = 1
|
|
49
|
+ // Putting 2 makes 1/2 of origin image size from width and height.
|
|
50
|
+ // it alleviates the memory and CPU too for weak devices.
|
51
|
51
|
pic = BitmapFactory.decodeStream(k, null, options)
|
52
|
52
|
k.close()
|
53
|
53
|
} catch (e: IOException) {
|
|
@@ -67,15 +67,14 @@ class ImageGetterAsyncTask(
|
67
|
67
|
val size = Point()
|
68
|
68
|
(context as Activity).windowManager.defaultDisplay.getSize(size)
|
69
|
69
|
// Lets calculate the ratio according to the screen width in px
|
70
|
|
- val multiplier: Int = size.x / bitmap!!.width
|
71
|
|
- //Log.d(LOG_CAT, "multiplier: $multiplier")
|
|
70
|
+ val multiplier: Double = (size.x).toDouble() / (bitmap!!.width.toDouble())
|
72
|
71
|
levelListDrawable.addLevel(1, 1, d)
|
73
|
72
|
// Set bounds width and height according to the bitmap resized size
|
74
|
73
|
levelListDrawable.setBounds(
|
75
|
74
|
0,
|
76
|
75
|
0,
|
77
|
|
- bitmap.width * multiplier,
|
78
|
|
- bitmap.height * multiplier
|
|
76
|
+ (bitmap.width.toDouble() * multiplier).toInt(),
|
|
77
|
+ (bitmap.height.toDouble() * multiplier).toInt()
|
79
|
78
|
)
|
80
|
79
|
levelListDrawable.level = 1
|
81
|
80
|
t!!.text = t!!.text // invalidate() doesn't work correctly...
|