Skip to content

Commit 0687e98

Browse files
committed
add log printer for image getter
1 parent 69e3807 commit 0687e98

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies {
3434

3535
implementation "com.jakewharton:butterknife:$butterknife_version"
3636
kapt "com.jakewharton:butterknife-compiler:$butterknife_version"
37-
implementation 'com.github.bumptech.glide:glide:4.5.0'
37+
implementation 'com.github.bumptech.glide:glide:4.8.0'
3838
annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
3939

4040

utils/src/main/java/com/haoge/easyandroid/easy/EasyImageGetter.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable
2222
import android.os.AsyncTask
2323
import android.os.Build
2424
import android.text.Html
25+
import android.util.Log
2526
import android.widget.TextView
2627
import com.bumptech.glide.Glide
2728
import com.haoge.easyandroid.EasyAndroid
@@ -111,14 +112,19 @@ class EasyImageGetter:Html.ImageGetter {
111112

112113
val url = params[0]?:throw RuntimeException("URL is null")
113114
// 先使用用户设置的loader进行加载
114-
val result = loader?.invoke(url)
115-
if (result != null) return result
115+
try {
116+
val result = loader?.invoke(url)
117+
if (result != null) return result
118+
} catch (e:Exception) {
119+
Log.e("EasyImageGetter", "A error occurs with loader:[${loader?.javaClass?.canonicalName}]", e)
120+
}
121+
116122
// 当用户设置的loader加载失败时(返回null), 则使用内部机制进行drawable获取
117123
if (glideSupport.not()) throw RuntimeException("Internal loader requires glide to load drawable!")
118124
val context = container.get()?.context?:throw RuntimeException("Fetch context failed from container")
119125
return Glide.with(context).load(url).submit().get()
120126
} catch (e:Exception) {
121-
e.printStackTrace()
127+
Log.e("EasyImageGetter", "A error occurs with internal loader", e)
122128
return null
123129
}
124130
}

0 commit comments

Comments
 (0)