Skip to content

Commit e4cddc2

Browse files
authored
Merge pull request #292 from esensar/fix/291-startup-crash
Keep android material classes to prevent crash on lower SDKs
2 parents aee4057 + d82d6b7 commit e4cddc2

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

app/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
-keepclassmembers class * implements android.os.Parcelable {
22
static ** CREATOR;
33
}
4+
5+
-keep class com.google.android.material.** { *; }

app/src/main/kotlin/com/simplemobiletools/draw/pro/helpers/VectorFloodFiller.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import java.util.Queue
1212
class VectorFloodFiller(image: Bitmap) {
1313
val path = MyPath()
1414

15-
private var width = 0
16-
private var height = 0
17-
private var pixels: IntArray? = null
15+
private val width: Int
16+
private val height: Int
17+
private val pixels: IntArray
1818

1919
private lateinit var pixelsChecked: BooleanArray
2020
private lateinit var ranges: Queue<FloodFillRange>
@@ -29,12 +29,12 @@ class VectorFloodFiller(image: Bitmap) {
2929
width = image.width
3030
height = image.height
3131
pixels = IntArray(width * height)
32-
image.getPixels(pixels!!, 0, width, 0, 0, width, height)
32+
image.getPixels(pixels, 0, width, 0, 0, width, height)
3333
}
3434

3535
private fun prepare() {
3636
// Called before starting flood-fill
37-
pixelsChecked = BooleanArray(pixels!!.size)
37+
pixelsChecked = BooleanArray(pixels.size)
3838
ranges = LinkedList()
3939
}
4040

@@ -45,7 +45,7 @@ class VectorFloodFiller(image: Bitmap) {
4545
prepare()
4646

4747
// Get starting color.
48-
val startPixel = pixels!!.getOrNull(width * y + x) ?: return
48+
val startPixel = pixels.getOrNull(width * y + x) ?: return
4949
if (startPixel == fillColor) {
5050
// No-op.
5151
return
@@ -137,9 +137,9 @@ class VectorFloodFiller(image: Bitmap) {
137137

138138
// Sees if a pixel is within the color tolerance range.
139139
private fun isPixelColorWithinTolerance(px: Int): Boolean {
140-
val red = pixels!![px] ushr 16 and 0xff
141-
val green = pixels!![px] ushr 8 and 0xff
142-
val blue = pixels!![px] and 0xff
140+
val red = pixels[px] ushr 16 and 0xff
141+
val green = pixels[px] ushr 8 and 0xff
142+
val blue = pixels[px] and 0xff
143143
return red >= startColorRed - tolerance && red <= startColorRed + tolerance && green >= startColorGreen - tolerance && green <= startColorGreen + tolerance && blue >= startColorBlue - tolerance && blue <= startColorBlue + tolerance
144144
}
145145

0 commit comments

Comments
 (0)