mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-09-20 07:31:40 +02:00
Catch crashes, but things will still break
This commit is contained in:
parent
fa7c728071
commit
bc623f740e
@ -16,11 +16,14 @@
|
||||
*/
|
||||
package com.pitchedapps.frost.kotlin
|
||||
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
@ -64,8 +67,11 @@ class Flyweight<K, V>(
|
||||
completeExceptionally(result.exceptionOrNull()!!)
|
||||
}
|
||||
|
||||
private val errHandler = CoroutineExceptionHandler { _, throwable -> L.d { "FbAuth failed ${throwable.message}" } }
|
||||
|
||||
init {
|
||||
job = scope.launch(Dispatchers.IO) {
|
||||
job =
|
||||
scope.launch(Dispatchers.IO + SupervisorJob() + errHandler) {
|
||||
launch {
|
||||
while (isActive) {
|
||||
select<Unit> {
|
||||
|
@ -27,9 +27,12 @@ import com.pitchedapps.frost.contracts.FrostContentContainer
|
||||
import com.pitchedapps.frost.contracts.FrostContentCore
|
||||
import com.pitchedapps.frost.contracts.FrostContentParent
|
||||
import com.pitchedapps.frost.fragments.RecyclerContentContract
|
||||
import com.pitchedapps.frost.utils.L
|
||||
import com.pitchedapps.frost.utils.Prefs
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
|
||||
/**
|
||||
* Created by Allan Wang on 2017-05-29.
|
||||
@ -74,7 +77,14 @@ class FrostRecyclerView @JvmOverloads constructor(
|
||||
if (Prefs.animate) fadeOut(onFinish = onReloadClear)
|
||||
scope.launch {
|
||||
parent.refreshChannel.offer(true)
|
||||
val loaded = recyclerContract.reload { parent.progressChannel.offer(it) }
|
||||
// TODO figure out how to avoid cancelling parent
|
||||
try {
|
||||
supervisorScope {
|
||||
recyclerContract.reload { parent.progressChannel.offer(it) }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
parent.progressChannel.offer(100)
|
||||
parent.refreshChannel.offer(false)
|
||||
if (Prefs.animate) circularReveal()
|
||||
|
Loading…
Reference in New Issue
Block a user