Remove unused repository interface
This commit is contained in:
parent
7fb7e45093
commit
00ef93f0c5
@ -13,7 +13,6 @@ import bou.amine.apps.readerforselfossv2.DI.networkModule
|
|||||||
import bou.amine.apps.readerforselfossv2.android.utils.Config
|
import bou.amine.apps.readerforselfossv2.android.utils.Config
|
||||||
import bou.amine.apps.readerforselfossv2.android.utils.glide.loadMaybeBasicAuth
|
import bou.amine.apps.readerforselfossv2.android.utils.glide.loadMaybeBasicAuth
|
||||||
import bou.amine.apps.readerforselfossv2.repository.Repository
|
import bou.amine.apps.readerforselfossv2.repository.Repository
|
||||||
import bou.amine.apps.readerforselfossv2.repository.RepositoryImpl
|
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
import com.ftinc.scoop.Scoop
|
import com.ftinc.scoop.Scoop
|
||||||
@ -21,13 +20,12 @@ import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
|
|||||||
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
import com.mikepenz.materialdrawer.util.DrawerImageLoader
|
||||||
import com.russhwolf.settings.Settings
|
import com.russhwolf.settings.Settings
|
||||||
import org.kodein.di.*
|
import org.kodein.di.*
|
||||||
import java.util.UUID.randomUUID
|
|
||||||
|
|
||||||
class MyApp : MultiDexApplication(), DIAware {
|
class MyApp : MultiDexApplication(), DIAware {
|
||||||
|
|
||||||
override val di by DI.lazy {
|
override val di by DI.lazy {
|
||||||
import(networkModule)
|
import(networkModule)
|
||||||
bind<Repository>() with singleton { RepositoryImpl(instance(), instance()) }
|
bind<Repository>() with singleton { Repository(instance(), instance()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var config: Config
|
private lateinit var config: Config
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
package bou.amine.apps.readerforselfossv2.repository
|
|
||||||
|
|
||||||
import bou.amine.apps.readerforselfossv2.rest.SelfossModel
|
|
||||||
import bou.amine.apps.readerforselfossv2.utils.DateUtils
|
|
||||||
import bou.amine.apps.readerforselfossv2.utils.ItemType
|
|
||||||
|
|
||||||
interface Repository {
|
|
||||||
|
|
||||||
// TODO: remove the items variables in favor of storing everything in the database
|
|
||||||
var items: ArrayList<SelfossModel.Item>
|
|
||||||
var baseUrl: String
|
|
||||||
var dateUtils: DateUtils
|
|
||||||
|
|
||||||
var displayedItems: ItemType
|
|
||||||
|
|
||||||
// Settings
|
|
||||||
var itemsCaching: Boolean
|
|
||||||
|
|
||||||
// API
|
|
||||||
var apiMajorVersion: Int
|
|
||||||
var badgeUnread: Int
|
|
||||||
var badgeAll: Int
|
|
||||||
var badgeStarred: Int
|
|
||||||
|
|
||||||
var tagFilter: SelfossModel.Tag?
|
|
||||||
var sourceFilter: SelfossModel.Source?
|
|
||||||
var searchFilter: String?
|
|
||||||
|
|
||||||
suspend fun getNewerItems(): ArrayList<SelfossModel.Item>
|
|
||||||
suspend fun getOlderItems(): ArrayList<SelfossModel.Item>
|
|
||||||
suspend fun allItems(itemType: ItemType): List<SelfossModel.Item>?
|
|
||||||
suspend fun reloadBadges(): Boolean
|
|
||||||
suspend fun getTags(): List<SelfossModel.Tag>?
|
|
||||||
suspend fun getSpouts(): Map<String, SelfossModel.Spout>?
|
|
||||||
suspend fun getSources(): ArrayList<SelfossModel.Source>?
|
|
||||||
suspend fun markAsRead(id: Int): Boolean
|
|
||||||
suspend fun unmarkAsRead(id: Int): Boolean
|
|
||||||
suspend fun starr(id: Int): Boolean
|
|
||||||
suspend fun unstarr(id: Int): Boolean
|
|
||||||
suspend fun markAllAsRead(ids: List<Int>): Boolean
|
|
||||||
suspend fun createSource(title: String,
|
|
||||||
url: String,
|
|
||||||
spout: String,
|
|
||||||
tags: String,
|
|
||||||
filter: String): Boolean
|
|
||||||
suspend fun deleteSource(id: Int): Boolean
|
|
||||||
suspend fun updateRemote(): Boolean
|
|
||||||
suspend fun login(): Boolean
|
|
||||||
fun refreshLoginInformation(url: String, login: String, password: String,
|
|
||||||
httpLogin: String, httpPassword: String,
|
|
||||||
isSelfSignedCert: Boolean)
|
|
||||||
}
|
|
@ -11,28 +11,28 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDetailsService) : Repository {
|
class Repository(private val api: SelfossApi, private val apiDetails: ApiDetailsService) {
|
||||||
val settings = Settings()
|
val settings = Settings()
|
||||||
|
|
||||||
override var items = ArrayList<SelfossModel.Item>()
|
var items = ArrayList<SelfossModel.Item>()
|
||||||
|
|
||||||
override var baseUrl = apiDetails.getBaseUrl()
|
var baseUrl = apiDetails.getBaseUrl()
|
||||||
override lateinit var dateUtils: DateUtils
|
lateinit var dateUtils: DateUtils
|
||||||
|
|
||||||
override var displayedItems = ItemType.UNREAD
|
var displayedItems = ItemType.UNREAD
|
||||||
|
|
||||||
override var tagFilter: SelfossModel.Tag? = null
|
var tagFilter: SelfossModel.Tag? = null
|
||||||
override var sourceFilter: SelfossModel.Source? = null
|
var sourceFilter: SelfossModel.Source? = null
|
||||||
override var searchFilter: String? = null
|
var searchFilter: String? = null
|
||||||
|
|
||||||
override var itemsCaching = settings.getBoolean("items_caching", false)
|
var itemsCaching = settings.getBoolean("items_caching", false)
|
||||||
|
|
||||||
override var apiMajorVersion = 0
|
var apiMajorVersion = 0
|
||||||
override var badgeUnread = 0
|
var badgeUnread = 0
|
||||||
set(value) {field = if (value < 0) { 0 } else { value } }
|
set(value) {field = if (value < 0) { 0 } else { value } }
|
||||||
override var badgeAll = 0
|
var badgeAll = 0
|
||||||
set(value) {field = if (value < 0) { 0 } else { value } }
|
set(value) {field = if (value < 0) { 0 } else { value } }
|
||||||
override var badgeStarred = 0
|
var badgeStarred = 0
|
||||||
set(value) {field = if (value < 0) { 0 } else { value } }
|
set(value) {field = if (value < 0) { 0 } else { value } }
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -44,7 +44,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
||||||
// TODO: Check connectivity, use the updatedSince parameter
|
// TODO: Check connectivity, use the updatedSince parameter
|
||||||
val fetchedItems = api.getItems(displayedItems.type,
|
val fetchedItems = api.getItems(displayedItems.type,
|
||||||
settings.getString("prefer_api_items_number", "200").toInt(),
|
settings.getString("prefer_api_items_number", "200").toInt(),
|
||||||
@ -60,7 +60,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getOlderItems(): ArrayList<SelfossModel.Item> {
|
suspend fun getOlderItems(): ArrayList<SelfossModel.Item> {
|
||||||
// TODO: Check connectivity
|
// TODO: Check connectivity
|
||||||
val offset = items.size
|
val offset = items.size
|
||||||
val fetchedItems = api.getItems(displayedItems.type,
|
val fetchedItems = api.getItems(displayedItems.type,
|
||||||
@ -77,7 +77,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun allItems(itemType: ItemType): List<SelfossModel.Item>? =
|
suspend fun allItems(itemType: ItemType): List<SelfossModel.Item>? =
|
||||||
api.getItems(itemType.type, 200, 0, tagFilter?.tag, sourceFilter?.id?.toLong(), searchFilter, null)
|
api.getItems(itemType.type, 200, 0, tagFilter?.tag, sourceFilter?.id?.toLong(), searchFilter, null)
|
||||||
|
|
||||||
private fun appendItems(fetchedItems: List<SelfossModel.Item>) {
|
private fun appendItems(fetchedItems: List<SelfossModel.Item>) {
|
||||||
@ -93,7 +93,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
items.sortByDescending { dateUtils.parseDate(it.datetime) }
|
items.sortByDescending { dateUtils.parseDate(it.datetime) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun reloadBadges(): Boolean {
|
suspend fun reloadBadges(): Boolean {
|
||||||
// TODO: Check connectivity, calculate from DB
|
// TODO: Check connectivity, calculate from DB
|
||||||
var success = false
|
var success = false
|
||||||
val response = api.stats()
|
val response = api.stats()
|
||||||
@ -106,22 +106,22 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getTags(): List<SelfossModel.Tag>? {
|
suspend fun getTags(): List<SelfossModel.Tag>? {
|
||||||
// TODO: Check success, store in DB
|
// TODO: Check success, store in DB
|
||||||
return api.tags()
|
return api.tags()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getSpouts(): Map<String, SelfossModel.Spout>? {
|
suspend fun getSpouts(): Map<String, SelfossModel.Spout>? {
|
||||||
// TODO: Check success, store in DB
|
// TODO: Check success, store in DB
|
||||||
return api.spouts()
|
return api.spouts()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getSources(): ArrayList<SelfossModel.Source>? {
|
suspend fun getSources(): ArrayList<SelfossModel.Source>? {
|
||||||
// TODO: Check success
|
// TODO: Check success
|
||||||
return api.sources()
|
return api.sources()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun markAsRead(id: Int): Boolean {
|
suspend fun markAsRead(id: Int): Boolean {
|
||||||
// TODO: Check internet connection
|
// TODO: Check internet connection
|
||||||
val success = api.markAsRead(id.toString())?.isSuccess == true
|
val success = api.markAsRead(id.toString())?.isSuccess == true
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun unmarkAsRead(id: Int): Boolean {
|
suspend fun unmarkAsRead(id: Int): Boolean {
|
||||||
// TODO: Check internet connection
|
// TODO: Check internet connection
|
||||||
val success = api.unmarkAsRead(id.toString())?.isSuccess == true
|
val success = api.unmarkAsRead(id.toString())?.isSuccess == true
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun starr(id: Int): Boolean {
|
suspend fun starr(id: Int): Boolean {
|
||||||
// TODO: Check success, store in DB
|
// TODO: Check success, store in DB
|
||||||
val success = api.starr(id.toString())?.isSuccess == true
|
val success = api.starr(id.toString())?.isSuccess == true
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun unstarr(id: Int): Boolean {
|
suspend fun unstarr(id: Int): Boolean {
|
||||||
// TODO: Check internet connection
|
// TODO: Check internet connection
|
||||||
val success = api.unstarr(id.toString())?.isSuccess == true
|
val success = api.unstarr(id.toString())?.isSuccess == true
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun markAllAsRead(ids: List<Int>): Boolean {
|
suspend fun markAllAsRead(ids: List<Int>): Boolean {
|
||||||
// TODO: Check Internet connectivity, store in DB
|
// TODO: Check Internet connectivity, store in DB
|
||||||
|
|
||||||
val success = api.markAllAsRead(ids.map { it.toString() })?.isSuccess == true
|
val success = api.markAllAsRead(ids.map { it.toString() })?.isSuccess == true
|
||||||
@ -207,7 +207,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun createSource(
|
suspend fun createSource(
|
||||||
title: String,
|
title: String,
|
||||||
url: String,
|
url: String,
|
||||||
spout: String,
|
spout: String,
|
||||||
@ -227,7 +227,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return response != null
|
return response != null
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun deleteSource(id: Int): Boolean {
|
suspend fun deleteSource(id: Int): Boolean {
|
||||||
// TODO: Check connectivity, store in DB
|
// TODO: Check connectivity, store in DB
|
||||||
var success = false
|
var success = false
|
||||||
val response = api.deleteSource(id)
|
val response = api.deleteSource(id)
|
||||||
@ -238,13 +238,13 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun updateRemote(): Boolean {
|
suspend fun updateRemote(): Boolean {
|
||||||
// TODO: Handle connectivity issues
|
// TODO: Handle connectivity issues
|
||||||
val response = api.update()
|
val response = api.update()
|
||||||
return response?.isSuccess ?: false
|
return response?.isSuccess ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun login(): Boolean {
|
suspend fun login(): Boolean {
|
||||||
var result = false
|
var result = false
|
||||||
try {
|
try {
|
||||||
val response = api.login()
|
val response = api.login()
|
||||||
@ -257,7 +257,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refreshLoginInformation(url: String, login: String, password: String,
|
fun refreshLoginInformation(url: String, login: String, password: String,
|
||||||
httpLogin: String, httpPassword: String,
|
httpLogin: String, httpPassword: String,
|
||||||
isSelfSignedCert: Boolean) {
|
isSelfSignedCert: Boolean) {
|
||||||
settings.putString("url", url)
|
settings.putString("url", url)
|
||||||
|
Loading…
Reference in New Issue
Block a user