Don't send toast messages from the repository
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
davidoskky 2022-08-20 12:42:24 +02:00
parent 1290d3c4dd
commit 49abc081b6
2 changed files with 0 additions and 20 deletions

View File

@ -17,7 +17,6 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.core.view.doOnNextLayout import androidx.core.view.doOnNextLayout
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.* import androidx.recyclerview.widget.*
import androidx.room.Room import androidx.room.Room
import androidx.work.Constraints import androidx.work.Constraints
@ -179,12 +178,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
dataBase = AndroidDeviceDatabase(applicationContext) dataBase = AndroidDeviceDatabase(applicationContext)
lifecycleScope.launch {
repository.toastMessageState.collect {
Toast.makeText(baseContext, it, Toast.LENGTH_SHORT).show()
}
}
handleBottomBar() handleBottomBar()
handleDrawer() handleDrawer()

View File

@ -10,9 +10,6 @@ import com.russhwolf.settings.Settings
import io.github.aakira.napier.Napier import io.github.aakira.napier.Napier
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class Repository(private val api: SelfossApi, private val apiDetails: ApiDetailsService, val connectivityStatus: ConnectivityStatus) { class Repository(private val api: SelfossApi, private val apiDetails: ApiDetailsService, val connectivityStatus: ConnectivityStatus) {
@ -21,9 +18,6 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
var items = ArrayList<SelfossModel.Item>() var items = ArrayList<SelfossModel.Item>()
private val isConnectionAvailable = connectivityStatus.isNetworkConnected private val isConnectionAvailable = connectivityStatus.isNetworkConnected
private val _toastMessageState = MutableSharedFlow<String>(0)
val toastMessageState = _toastMessageState.asSharedFlow()
var baseUrl = apiDetails.getBaseUrl() var baseUrl = apiDetails.getBaseUrl()
lateinit var dateUtils: DateUtils lateinit var dateUtils: DateUtils
@ -50,13 +44,6 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
updateApiVersion() updateApiVersion()
dateUtils = DateUtils(apiMajorVersion) dateUtils = DateUtils(apiMajorVersion)
reloadBadges() reloadBadges()
isConnectionAvailable.asStateFlow().collect { connectionAvailable ->
if (!connectionAvailable) {
// TODO: Localize this string
_toastMessageState.emit("Network connection lost")
}
}
} }
} }