Skip to content

Instantly share code, notes, and snippets.

@zzuummaa
Last active August 23, 2018 17:45
Show Gist options
  • Save zzuummaa/5f4b6bdef6ddf958100b6f197e50675b to your computer and use it in GitHub Desktop.
Save zzuummaa/5f4b6bdef6ddf958100b6f197e50675b to your computer and use it in GitHub Desktop.
fun loadPageData(categoty: String = "technics") {
launchPrintThrowable {
runOnUiThread {
// Косяк
productList.clear()
productAdapter.notifyDataSetChanged()
}
val productsHits = CommiApi.instance
.getProductsHits(categoty)
.unwrapCall()
if (productsHits == null) {
toastUI("Контент не был загружен с сервера")
return@launchPrintThrowable
}
if (productsHits.offers == null) {
toastUI("Сервер не вернул нужный контент")
return@launchPrintThrowable
}
productList.addAll(productsHits.offers!!)
runOnUiThread {
productAdapter.notifyDataSetChanged()
}
ImageService.loadImages (
idContainers = productsHits.offers!!,
extractor = { it -> it.product?.iconId },
onImage = { it, img -> it.product?.icon = img },
onSuccess = { runOnUiThread { productAdapter.notifyDataSetChanged() } },
onFailure = { cause -> toastUI(cause) }
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment