BugFix for crashing on start up due to creating two caches for videos.
This commit is contained in:
@@ -2,6 +2,7 @@ package com.vitorpamplona.amethyst
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
import android.util.Log
|
||||||
import coil.Coil
|
import coil.Coil
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.decode.GifDecoder
|
import coil.decode.GifDecoder
|
||||||
@@ -31,7 +32,10 @@ object ServiceManager {
|
|||||||
start(context)
|
start(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun start(context: Context) {
|
fun start(context: Context) {
|
||||||
|
Log.d("ServiceManager", "Starting Relay Services")
|
||||||
|
|
||||||
val myAccount = account
|
val myAccount = account
|
||||||
|
|
||||||
// Resets Proxy Use
|
// Resets Proxy Use
|
||||||
@@ -75,6 +79,8 @@ object ServiceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun pause() {
|
fun pause() {
|
||||||
|
Log.d("ServiceManager", "Pausing Relay Services")
|
||||||
|
|
||||||
NostrAccountDataSource.stop()
|
NostrAccountDataSource.stop()
|
||||||
NostrHomeDataSource.stop()
|
NostrHomeDataSource.stop()
|
||||||
NostrChannelDataSource.stop()
|
NostrChannelDataSource.stop()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ object VideoCache {
|
|||||||
|
|
||||||
lateinit var cacheDataSourceFactory: CacheDataSource.Factory
|
lateinit var cacheDataSourceFactory: CacheDataSource.Factory
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
fun init(context: Context) {
|
fun init(context: Context) {
|
||||||
if (!this::simpleCache.isInitialized) {
|
if (!this::simpleCache.isInitialized) {
|
||||||
exoDatabaseProvider = StandaloneDatabaseProvider(context)
|
exoDatabaseProvider = StandaloneDatabaseProvider(context)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.net.Network
|
|||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
import android.net.NetworkRequest
|
import android.net.NetworkRequest
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
@@ -108,9 +109,10 @@ class MainActivity : FragmentActivity() {
|
|||||||
// network is available for use
|
// network is available for use
|
||||||
override fun onAvailable(network: Network) {
|
override fun onAvailable(network: Network) {
|
||||||
super.onAvailable(network)
|
super.onAvailable(network)
|
||||||
|
Log.d("NETWORKCALLBACK", "onAvailable: Disconnecting and connecting again")
|
||||||
// Only starts after login
|
// Only starts after login
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
ServiceManager.pause()
|
||||||
ServiceManager.start(this@MainActivity)
|
ServiceManager.start(this@MainActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +128,7 @@ class MainActivity : FragmentActivity() {
|
|||||||
// lost network connection
|
// lost network connection
|
||||||
override fun onLost(network: Network) {
|
override fun onLost(network: Network) {
|
||||||
super.onLost(network)
|
super.onLost(network)
|
||||||
|
Log.d("NETWORKCALLBACK", "onLost: Disconnecting and pausing relay's connection")
|
||||||
// Only starts after login
|
// Only starts after login
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
ServiceManager.pause()
|
ServiceManager.pause()
|
||||||
|
|||||||
Reference in New Issue
Block a user