Items in repository.
This commit is contained in:
parent
47265c10d0
commit
9ed9bf07fc
@ -30,6 +30,8 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
||||
|
||||
private lateinit var binding: ActivityReaderBinding
|
||||
|
||||
private var allItems: ArrayList<SelfossModel.Item> = ArrayList()
|
||||
|
||||
override val di by closestDI()
|
||||
private val repository: Repository by instance()
|
||||
private val appSettingsService: AppSettingsService by instance()
|
||||
@ -61,12 +63,14 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
||||
if (allItems.isEmpty()) {
|
||||
currentItem = intent.getIntExtra("currentItem", 0)
|
||||
|
||||
allItems = repository.getReaderItems()
|
||||
|
||||
if (allItems.isEmpty() || currentItem > allItems.size) {
|
||||
finish()
|
||||
}
|
||||
|
||||
currentItem = intent.getIntExtra("currentItem", 0)
|
||||
|
||||
readItem(allItems[currentItem])
|
||||
|
||||
binding.pager.adapter = ScreenSlidePagerAdapter(this)
|
||||
@ -214,8 +218,4 @@ class ReaderActivity : AppCompatActivity(), DIAware {
|
||||
startActivity(intent)
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
|
||||
companion object {
|
||||
var allItems: ArrayList<SelfossModel.Item> = ArrayList()
|
||||
}
|
||||
}
|
||||
|
@ -132,8 +132,8 @@ class ItemCardAdapter(
|
||||
|
||||
private fun handleLinkOpening() {
|
||||
binding.root.setOnClickListener {
|
||||
repository.setReaderItems(items)
|
||||
c.openItemUrl(
|
||||
items,
|
||||
bindingAdapterPosition,
|
||||
items[bindingAdapterPosition].getLinkDecoded(),
|
||||
appSettingsService.isArticleViewerEnabled(),
|
||||
|
@ -84,8 +84,8 @@ class ItemListAdapter(
|
||||
|
||||
private fun handleLinkOpening() {
|
||||
binding.root.setOnClickListener {
|
||||
repository.setReaderItems(items)
|
||||
c.openItemUrl(
|
||||
items,
|
||||
bindingAdapterPosition,
|
||||
items[bindingAdapterPosition].getLinkDecoded(),
|
||||
appSettingsService.isArticleViewerEnabled(),
|
||||
|
@ -18,7 +18,6 @@ import bou.amine.apps.readerforselfossv2.utils.toStringUriWithHttp
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
|
||||
fun Context.openItemUrl(
|
||||
allItems: ArrayList<SelfossModel.Item>,
|
||||
currentItem: Int,
|
||||
linkDecoded: String,
|
||||
articleViewer: Boolean,
|
||||
@ -33,7 +32,6 @@ fun Context.openItemUrl(
|
||||
).show()
|
||||
} else {
|
||||
if (articleViewer) {
|
||||
ReaderActivity.allItems = allItems
|
||||
val intent = Intent(this, ReaderActivity::class.java)
|
||||
intent.putExtra("currentItem", currentItem)
|
||||
app.startActivity(intent)
|
||||
|
@ -47,6 +47,8 @@ class Repository(
|
||||
private var fetchedSources = false
|
||||
private var fetchedTags = false
|
||||
|
||||
private var _readerItems = ArrayList<SelfossModel.Item>()
|
||||
|
||||
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
||||
// TODO: Use the updatedSince parameter
|
||||
var fetchedItems: StatusAndData<List<SelfossModel.Item>> = StatusAndData.error()
|
||||
@ -558,4 +560,12 @@ class Repository(
|
||||
fun setSourceFilter(source: SelfossModel.Source?) {
|
||||
_sourceFilter.value = source
|
||||
}
|
||||
|
||||
fun setReaderItems(readerItems: ArrayList<SelfossModel.Item>) {
|
||||
_readerItems = readerItems
|
||||
}
|
||||
|
||||
fun getReaderItems(): ArrayList<SelfossModel.Item> {
|
||||
return _readerItems
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user