Accept article IDs as Int in the Repository
It's cleaner to accept ints and not strings, because the ID is internally stored as an Int
This commit is contained in:
parent
b14a6427da
commit
c0137ea5e7
@ -114,7 +114,7 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
||||
private fun readItem(item: SelfossModel.Item) {
|
||||
if (markOnScroll) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.markAsRead(item.id.toString())
|
||||
repository.markAsRead(item.id)
|
||||
// TODO: Handle failure
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
|
||||
private fun readItemAtIndex(position: Int, showSnackbar: Boolean = true) {
|
||||
val i = items[position]
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.markAsRead(i.id.toString())
|
||||
repository.markAsRead(i.id)
|
||||
// TODO: update db
|
||||
|
||||
}
|
||||
@ -102,7 +102,7 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
|
||||
|
||||
private fun unreadItemAtIndex(position: Int, showSnackbar: Boolean = true) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.unmarkAsRead(items[position].id.toString())
|
||||
repository.unmarkAsRead(items[position].id)
|
||||
// Todo: SharedItems.unreadItem(app, api, db, items[position])
|
||||
// TODO: update db
|
||||
|
||||
|
@ -170,7 +170,7 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
R.id.unread_action -> if (context != null) {
|
||||
if (this@ArticleFragment.item.unread) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.markAsRead(this@ArticleFragment.item.id.toString())
|
||||
repository.markAsRead(this@ArticleFragment.item.id)
|
||||
}
|
||||
this@ArticleFragment.item.unread = false
|
||||
Toast.makeText(
|
||||
@ -180,7 +180,7 @@ class ArticleFragment : Fragment(), DIAware {
|
||||
).show()
|
||||
} else {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
repository.unmarkAsRead(this@ArticleFragment.item.id.toString())
|
||||
repository.unmarkAsRead(this@ArticleFragment.item.id)
|
||||
}
|
||||
this@ArticleFragment.item.unread = true
|
||||
Toast.makeText(
|
||||
|
@ -17,11 +17,11 @@ interface Repository {
|
||||
fun getTags(): List<SelfossModel.Tag>
|
||||
suspend fun getSpouts(): Map<String, SelfossModel.Spout>?
|
||||
suspend fun getSources(): ArrayList<SelfossModel.Source>?
|
||||
suspend fun markAsRead(id: String): Boolean
|
||||
suspend fun unmarkAsRead(id: String): Boolean
|
||||
suspend fun markAsRead(id: Int): Boolean
|
||||
suspend fun unmarkAsRead(id: Int): Boolean
|
||||
suspend fun starr(id: Int): Boolean
|
||||
suspend fun unstarr(id: Int): Boolean
|
||||
fun markAllAsRead(ids: List<String>): Boolean
|
||||
fun markAllAsRead(ids: List<Int>): Boolean
|
||||
suspend fun createSource(title: String,
|
||||
url: String,
|
||||
spout: String,
|
||||
|
@ -47,15 +47,15 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
||||
return api.sources()
|
||||
}
|
||||
|
||||
override suspend fun markAsRead(id: String): Boolean {
|
||||
override suspend fun markAsRead(id: Int): Boolean {
|
||||
// TODO: Check success, store in DB
|
||||
api.markAsRead(id)
|
||||
api.markAsRead(id.toString())
|
||||
return true
|
||||
}
|
||||
|
||||
override suspend fun unmarkAsRead(id: String): Boolean {
|
||||
override suspend fun unmarkAsRead(id: Int): Boolean {
|
||||
// TODO: Check success, store in DB
|
||||
api.unmarkAsRead(id)
|
||||
api.unmarkAsRead(id.toString())
|
||||
return true }
|
||||
|
||||
override suspend fun starr(id: Int): Boolean {
|
||||
@ -70,7 +70,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
||||
return true
|
||||
}
|
||||
|
||||
override fun markAllAsRead(ids: List<String>): Boolean {
|
||||
override fun markAllAsRead(ids: List<Int>): Boolean {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user