Skip to content

Commit 0b38daa

Browse files
committed
Fixed IconPack.getIconDrawable not using icon.drawable
1 parent 117b2cc commit 0b38daa

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

lib/src/main/kotlin/com/maltaisn/icondialog/pack/IconDrawableLoader.kt

+4-5
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ import java.nio.ByteOrder
3333
* Class use to load icon drawables.
3434
* @param context Any context, needed to get resources.
3535
*/
36-
open class IconDrawableLoader(context: Context) {
36+
class IconDrawableLoader(context: Context) {
3737

3838
private val context = context.applicationContext
3939

4040
/**
4141
* Create the vector drawable for an [icon] and set it.
4242
*/
4343
@SuppressLint("DiscouragedPrivateApi,PrivateApi")
44-
open fun loadDrawable(icon: Icon): Drawable? {
44+
fun loadDrawable(icon: Icon) {
4545
if (icon.drawable != null) {
4646
// Icon drawable is already loaded.
47-
return icon.drawable
47+
return
4848
}
4949

5050
val drawable: Drawable?
@@ -74,11 +74,10 @@ open class IconDrawableLoader(context: Context) {
7474
} catch (e: Exception) {
7575
// Could not load icon.
7676
Log.e(TAG, "Could not create vector drawable for icon ID ${icon.id}.", e)
77-
return null
77+
return
7878
}
7979

8080
icon.drawable = drawable
81-
return icon.drawable
8281
}
8382

8483
companion object {

lib/src/main/kotlin/com/maltaisn/icondialog/pack/IconPack.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class IconPack(val parent: IconPack? = null,
8383
* or if the drawable couldn't be loaded with the [loader].
8484
*/
8585
fun getIconDrawable(id: Int, loader: IconDrawableLoader): Drawable? {
86-
return loader.loadDrawable(getIcon(id) ?: return null)
86+
val icon = getIcon(id) ?: return null
87+
loader.loadDrawable(icon)
88+
return icon.drawable
8789
}
8890

8991
/**

0 commit comments

Comments
 (0)