Fix possible NPE when opening a story.
This commit is contained in:
parent
3e21fb77c7
commit
7c28d8ad51
1 changed files with 3 additions and 4 deletions
|
@ -60,8 +60,8 @@ class StoryImageLoader(
|
|||
|
||||
fun load() {
|
||||
val cacheValue = storyCache.getFromCache(imagePost.imageUri)
|
||||
if (cacheValue != null) {
|
||||
loadViaCache(cacheValue)
|
||||
if (cacheValue?.imageTarget != null) {
|
||||
loadViaCache(cacheValue.imageTarget)
|
||||
} else {
|
||||
loadViaGlide(storySize)
|
||||
}
|
||||
|
@ -77,10 +77,9 @@ class StoryImageLoader(
|
|||
blurLoader.clear()
|
||||
}
|
||||
|
||||
private fun loadViaCache(cacheValue: StoryCache.StoryCacheValue) {
|
||||
private fun loadViaCache(imageTarget: StoryCache.StoryCacheTarget) {
|
||||
Log.d(TAG, "Image in cache. Loading via cache...")
|
||||
|
||||
val imageTarget = cacheValue.imageTarget!!
|
||||
imageTarget.addListener(imageListener)
|
||||
fragment.viewLifecycleOwner.lifecycle.addObserver(OnDestroy { imageTarget.removeListener(imageListener) })
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue