Compare commits
No commits in common. "767805981fd93d3d1b71963c2d83228003302d96" and "49abc081b64687d6b973915dacf5f65569afc01e" have entirely different histories.
767805981f
...
49abc081b6
@ -1017,6 +1017,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener, DIAwar
|
|||||||
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
|
||||||
// TODO: Use Dispatchers.IO
|
// TODO: Use Dispatchers.IO
|
||||||
CoroutineScope(Dispatchers.Main).launch {
|
CoroutineScope(Dispatchers.Main).launch {
|
||||||
|
repository.offlineOverride = false
|
||||||
val updatedRemote = repository.updateRemote()
|
val updatedRemote = repository.updateRemote()
|
||||||
if (updatedRemote) {
|
if (updatedRemote) {
|
||||||
// TODO: Send toast messages from the repository
|
// TODO: Send toast messages from the repository
|
||||||
|
@ -178,9 +178,13 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun markAsReadById(id: Int): Boolean =
|
suspend fun markAsReadById(id: Int): Boolean {
|
||||||
isNetworkAvailable() && api.markAsRead(id.toString())?.isSuccess == true
|
var success = false
|
||||||
|
if (isNetworkAvailable()) {
|
||||||
|
success = api.markAsRead(id.toString())?.isSuccess == true
|
||||||
|
}
|
||||||
|
return success
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun unmarkAsRead(item: SelfossModel.Item): Boolean {
|
suspend fun unmarkAsRead(item: SelfossModel.Item): Boolean {
|
||||||
val success = unmarkAsReadById(item.id)
|
val success = unmarkAsReadById(item.id)
|
||||||
@ -191,8 +195,13 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun unmarkAsReadById(id: Int): Boolean =
|
suspend fun unmarkAsReadById(id: Int): Boolean {
|
||||||
isNetworkAvailable() && api.unmarkAsRead(id.toString())?.isSuccess == true
|
var success = false
|
||||||
|
if (isNetworkAvailable()) {
|
||||||
|
success = api.unmarkAsRead(id.toString())?.isSuccess == true
|
||||||
|
}
|
||||||
|
return success
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun starr(item: SelfossModel.Item): Boolean {
|
suspend fun starr(item: SelfossModel.Item): Boolean {
|
||||||
val success = starrById(item.id)
|
val success = starrById(item.id)
|
||||||
@ -203,8 +212,13 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun starrById(id: Int): Boolean =
|
suspend fun starrById(id: Int): Boolean {
|
||||||
isNetworkAvailable() && api.starr(id.toString())?.isSuccess == true
|
var success = false
|
||||||
|
if (isNetworkAvailable()) {
|
||||||
|
success = api.starr(id.toString())?.isSuccess == true
|
||||||
|
}
|
||||||
|
return success
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun unstarr(item: SelfossModel.Item): Boolean {
|
suspend fun unstarr(item: SelfossModel.Item): Boolean {
|
||||||
val success = unstarrById(item.id)
|
val success = unstarrById(item.id)
|
||||||
@ -215,15 +229,22 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun unstarrById(id: Int): Boolean =
|
suspend fun unstarrById(id: Int): Boolean {
|
||||||
isNetworkAvailable() && api.unstarr(id.toString())?.isSuccess == true
|
var success = false
|
||||||
|
if (isNetworkAvailable()) {
|
||||||
|
success = api.unstarr(id.toString())?.isSuccess == true
|
||||||
|
}
|
||||||
|
return success
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
suspend fun markAllAsRead(items: ArrayList<SelfossModel.Item>): Boolean {
|
suspend fun markAllAsRead(items: ArrayList<SelfossModel.Item>): Boolean {
|
||||||
var success = false
|
var success = false
|
||||||
|
if (isNetworkAvailable()) {
|
||||||
|
success = api.markAllAsRead(items.map { it.id.toString() })?.isSuccess == true
|
||||||
|
}
|
||||||
|
|
||||||
if (isNetworkAvailable() && api.markAllAsRead(items.map { it.id.toString() })?.isSuccess == true) {
|
if (success) {
|
||||||
success = true
|
|
||||||
for (item in items) {
|
for (item in items) {
|
||||||
markAsReadLocally(item)
|
markAsReadLocally(item)
|
||||||
}
|
}
|
||||||
@ -298,8 +319,13 @@ class Repository(private val api: SelfossApi, private val apiDetails: ApiDetails
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun updateRemote(): Boolean =
|
suspend fun updateRemote(): Boolean {
|
||||||
isNetworkAvailable() && api.update()?.isSuccess == true
|
var response = false
|
||||||
|
if (isConnectionAvailable.value) {
|
||||||
|
response = api.update()?.isSuccess == true
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
suspend fun login(): Boolean {
|
suspend fun login(): Boolean {
|
||||||
var result = false
|
var result = false
|
||||||
|
Loading…
Reference in New Issue
Block a user