Instantly share code, notes, and snippets.

@illuzor /WallpaperFragment.kt Secret
Last active Oct 2, 2018

Embed
What would you like to do?
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
contentView = pv_wallpaper
if (model.state != PROGRESS && imageFile.exists()) {
loadFileToImageView()
} else {
checkData()
}
}
private fun checkData() {
if (view == null) return
when (model.state) {
CREATED -> {
showProgress()
model.setListener { checkData() }
model.load(relativeUrl, imageFile)
}
PROGRESS -> {
showProgress()
model.setListener { checkData() }
}
LOADED -> loadFileToImageView()
ERROR -> {
showError(R.string.unable_to_load) {
showProgress()
model.setListener { checkData() }
model.load(relativeUrl, imageFile)
}
}
}
}
private fun loadFileToImageView() {
showContent()
GlideApp.with(context!!)
.load(Uri.fromFile(imageFile))
.transition(DrawableTransitionOptions.withCrossFade())
.into(pv_wallpaper)
loaded = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment