Last active
August 23, 2018 17:45
-
-
Save zzuummaa/5f4b6bdef6ddf958100b6f197e50675b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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