mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-25 13:12:16 +03:00
Handle also UnknownHostException in GenericListModel
This commit is contained in:
parent
005c1cb8f7
commit
0500bd5e88
@ -11,6 +11,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import java.net.ConnectException
|
||||
import java.net.UnknownHostException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
@ -91,12 +92,18 @@ open class GenericListModel(application: Application) :
|
||||
try {
|
||||
load(isOffline, useId3Tags, musicService, refresh, bundle)
|
||||
} catch (exception: ConnectException) {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
CommunicationErrorHandler.handleError(exception, swipe.context)
|
||||
}
|
||||
handleException(exception, swipe.context)
|
||||
} catch (exception: UnknownHostException) {
|
||||
handleException(exception, swipe.context)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleException(exception: Exception, context: Context) {
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
CommunicationErrorHandler.handleError(exception, context)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the central function you need to implement if you want to extend this class
|
||||
*/
|
||||
|
@ -20,12 +20,12 @@ import android.os.Looper
|
||||
import android.os.PowerManager
|
||||
import android.os.PowerManager.PARTIAL_WAKE_LOCK
|
||||
import android.os.PowerManager.WakeLock
|
||||
import org.koin.core.component.KoinApiExtension
|
||||
import java.io.File
|
||||
import java.net.URLEncoder
|
||||
import java.util.Locale
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import org.koin.core.component.KoinApiExtension
|
||||
import org.moire.ultrasonic.audiofx.EqualizerController
|
||||
import org.moire.ultrasonic.audiofx.VisualizerController
|
||||
import org.moire.ultrasonic.data.ActiveServerProvider.Companion.isOffline
|
||||
|
Loading…
x
Reference in New Issue
Block a user