From 55bf3e4b5b4af5baa3c230ca82f74988608971a3 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 6 Aug 2019 00:49:58 -0700 Subject: Format kotlin --- .../frost/fragments/RecyclerFragmentBase.kt | 73 +++++++++++----------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt index 9f2d704c..71c27dd2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/RecyclerFragmentBase.kt @@ -50,23 +50,24 @@ abstract class RecyclerFragment> : BaseFragment(), Recycle } } - final override suspend fun reload(progress: (Int) -> Unit): Boolean = withContext(Dispatchers.IO) { - val data = try { - reloadImpl(progress) - } catch (e: Exception) { - L.e(e) { "Recycler reload fail $baseUrl" } - null - } - withMainContext { - if (data == null) { - valid = false - false - } else { - adapter.setNewList(data) - true + final override suspend fun reload(progress: (Int) -> Unit): Boolean = + withContext(Dispatchers.IO) { + val data = try { + reloadImpl(progress) + } catch (e: Exception) { + L.e(e) { "Recycler reload fail $baseUrl" } + null + } + withMainContext { + if (data == null) { + valid = false + false + } else { + adapter.setNewList(data) + true + } } } - } protected abstract suspend fun reloadImpl(progress: (Int) -> Unit): List? } @@ -95,7 +96,8 @@ abstract class GenericRecyclerFragment> : RecyclerFragment open fun getAdapter(): FastAdapter> = fastAdapter(this.adapter) } -abstract class FrostParserFragment> : RecyclerFragment() { +abstract class FrostParserFragment> : + RecyclerFragment() { /** * The parser to make this all happen @@ -125,24 +127,25 @@ abstract class FrostParserFragment> : Recycler */ open fun getAdapter(): FastAdapter> = fastAdapter(this.adapter) - override suspend fun reloadImpl(progress: (Int) -> Unit): List? = withContext(Dispatchers.IO) { - progress(10) - val cookie = FbCookie.webCookie - val doc = getDoc(cookie) - progress(60) - val response = try { - parser.parse(cookie, doc) - } catch (ignored: Exception) { - null - } - if (response == null) { - L.i { "RecyclerFragment failed for ${baseEnum.name}" } - L._d { "Cookie used: $cookie" } - return@withContext null + override suspend fun reloadImpl(progress: (Int) -> Unit): List? = + withContext(Dispatchers.IO) { + progress(10) + val cookie = FbCookie.webCookie + val doc = getDoc(cookie) + progress(60) + val response = try { + parser.parse(cookie, doc) + } catch (ignored: Exception) { + null + } + if (response == null) { + L.i { "RecyclerFragment failed for ${baseEnum.name}" } + L._d { "Cookie used: $cookie" } + return@withContext null + } + progress(80) + val items = toItems(response) + progress(97) + return@withContext items } - progress(80) - val items = toItems(response) - progress(97) - return@withContext items - } } -- cgit v1.2.3