Skip to content

Instantly share code, notes, and snippets.

@Nonda95
Created April 5, 2018 10:42
Show Gist options
  • Save Nonda95/145c9cfae9780a85d8a3f60c35853aed to your computer and use it in GitHub Desktop.
Save Nonda95/145c9cfae9780a85d8a3f60c35853aed to your computer and use it in GitHub Desktop.
Add loading image only from cache
override fun onCreate(savedInstanceState: Bundle?) {
...
detailImage.load(url, loadOnlyFromCache = true) {
supportStartPostponedEnterTransition()
}
}
fun ImageView.load(url: String, loadOnlyFromCache: Boolean = false, onLoadingFinished: () -> Unit = {}) {
...
val requestOptions = RequestOptions.placeholderOf(R.drawable.placeholder)
.dontTransform()
.onlyRetrieveFromCache(loadOnlyFromCache)
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment