Compare commits
No commits in common. "9712f2846f78a19b509ff19957d326d151ef8bf7" and "014534981786ff9b7a162b57a28152d1ea16d5b9" have entirely different histories.
9712f2846f
...
0145349817
@ -17,7 +17,6 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.doOnNextLayout
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.*
|
||||
import androidx.room.Room
|
||||
import androidx.work.Constraints
|
||||
@ -179,12 +178,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
||||
|
||||
dataBase = AndroidDeviceDatabase(applicationContext)
|
||||
|
||||
lifecycleScope.launch {
|
||||
repository.toastMessageState.collect {
|
||||
Toast.makeText(baseContext, it, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
handleBottomBar()
|
||||
handleDrawer()
|
||||
|
||||
|
@ -10,9 +10,6 @@ import com.russhwolf.settings.Settings
|
||||
import io.github.aakira.napier.Napier
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.asSharedFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class Repository(private val api: SelfossApi, private val apiDetails: ApiDetailsService, connectivityStatus: ConnectivityStatus) {
|
||||
@ -21,9 +18,6 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
var items = ArrayList<SelfossModel.Item>()
|
||||
private val isConnectionAvailable = connectivityStatus.isNetworkConnected
|
||||
|
||||
private val _toastMessageState = MutableSharedFlow<String>(0)
|
||||
val toastMessageState = _toastMessageState.asSharedFlow()
|
||||
|
||||
var baseUrl = apiDetails.getBaseUrl()
|
||||
lateinit var dateUtils: DateUtils
|
||||
|
||||
@ -51,13 +45,6 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
updateApiVersion()
|
||||
dateUtils = DateUtils(apiMajorVersion)
|
||||
reloadBadges()
|
||||
|
||||
isConnectionAvailable.asStateFlow().collect { connectionAvailable ->
|
||||
if (!connectionAvailable) {
|
||||
// TODO: Localize this string
|
||||
_toastMessageState.emit("Network connection lost")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +65,7 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
items = ArrayList(fetchedItems)
|
||||
}
|
||||
} else {
|
||||
// TODO: Provide an error message if the connection is not available.
|
||||
// TODO: Get items from the database
|
||||
}
|
||||
return items
|
||||
@ -100,7 +88,7 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
appendItems(fetchedItems)
|
||||
}
|
||||
} else {
|
||||
// TODO: Get items from the database
|
||||
// TODO: Provide an error message
|
||||
}
|
||||
return items
|
||||
}
|
||||
@ -117,7 +105,6 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
null
|
||||
)
|
||||
} else {
|
||||
// TODO: Provide an error message
|
||||
null
|
||||
}
|
||||
}
|
||||
@ -199,6 +186,7 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
}
|
||||
|
||||
suspend fun unmarkAsRead(item: SelfossModel.Item): Boolean {
|
||||
// TODO: Check internet connection
|
||||
val success = unmarkAsReadById(item.id)
|
||||
|
||||
if (success) {
|
||||
@ -208,6 +196,7 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
||||
}
|
||||
|
||||
suspend fun unmarkAsReadById(id: Int): Boolean {
|
||||
// TODO: Check internet connection
|
||||
var success = false
|
||||
if (isConnectionAvailable.value && !offlineOverride) {
|
||||
success = api.unmarkAsRead(id.toString())?.isSuccess == true
|
||||
|
Loading…
Reference in New Issue
Block a user