mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Moved stuff to R.strings and fixed reloading the page
This commit is contained in:
parent
30dbd3920e
commit
7053d77ca1
3 changed files with 19 additions and 13 deletions
|
@ -21,6 +21,7 @@ import com.lagradost.cloudstream3.mvvm.debugAssert
|
|||
import com.lagradost.cloudstream3.mvvm.observe
|
||||
import com.lagradost.cloudstream3.syncproviders.SyncAPI
|
||||
import com.lagradost.cloudstream3.syncproviders.SyncIdName
|
||||
import com.lagradost.cloudstream3.ui.result.UiText
|
||||
import com.lagradost.cloudstream3.ui.result.txt
|
||||
import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_LOAD
|
||||
import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_SHOW_METADATA
|
||||
|
@ -70,14 +71,12 @@ class LibraryFragment : Fragment() {
|
|||
|
||||
sort_fab?.setOnClickListener {
|
||||
val methods = libraryViewModel.sortingMethods.map {
|
||||
txt(it.stringRes).asString(
|
||||
context ?: view.context
|
||||
)
|
||||
txt(it.stringRes).asString(view.context)
|
||||
}
|
||||
|
||||
activity?.showBottomDialog(methods,
|
||||
libraryViewModel.sortingMethods.indexOf(libraryViewModel.currentSortingMethod),
|
||||
"Sort by",
|
||||
txt(R.string.sort_by).asString(view.context),
|
||||
false,
|
||||
{},
|
||||
{
|
||||
|
@ -98,7 +97,7 @@ class LibraryFragment : Fragment() {
|
|||
}
|
||||
})
|
||||
|
||||
libraryViewModel.loadPages()
|
||||
libraryViewModel.reloadPages(false)
|
||||
|
||||
list_selector?.setOnClickListener {
|
||||
val items = libraryViewModel.availableApiNames
|
||||
|
@ -106,10 +105,10 @@ class LibraryFragment : Fragment() {
|
|||
|
||||
activity?.showBottomDialog(items,
|
||||
items.indexOf(currentItem),
|
||||
"Select library",
|
||||
txt(R.string.select_library).asString(it.context),
|
||||
false,
|
||||
{}) {
|
||||
val selectedItem = items.getOrNull(it) ?: return@showBottomDialog
|
||||
{}) { index ->
|
||||
val selectedItem = items.getOrNull(index) ?: return@showBottomDialog
|
||||
libraryViewModel.switchList(selectedItem)
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +154,7 @@ class LibraryFragment : Fragment() {
|
|||
this.showBottomDialog(
|
||||
items,
|
||||
selectedIndex,
|
||||
"Open with",
|
||||
txt(R.string.open_with).asString(this),
|
||||
true,
|
||||
{},
|
||||
) {
|
||||
|
|
|
@ -44,14 +44,16 @@ class LibraryViewModel : ViewModel() {
|
|||
ListSorting.AlphabeticalZ,
|
||||
)
|
||||
|
||||
var currentSortingMethod: ListSorting = sortingMethods.first()
|
||||
var currentSortingMethod: ListSorting = sortingMethods.first().also {
|
||||
println("SET SORTING METHOD $it")
|
||||
}
|
||||
private set
|
||||
|
||||
fun switchList(name: String) {
|
||||
currentSyncApi = availableSyncApis[availableApiNames.indexOf(name)]
|
||||
_currentApiName.postValue(currentSyncApi?.name)
|
||||
|
||||
loadPages()
|
||||
reloadPages(true)
|
||||
}
|
||||
|
||||
fun sort(method: ListSorting, query: String? = null) {
|
||||
|
@ -63,7 +65,10 @@ class LibraryViewModel : ViewModel() {
|
|||
_pages.postValue(currentList)
|
||||
}
|
||||
|
||||
fun loadPages() {
|
||||
fun reloadPages(forceReload: Boolean) {
|
||||
// Only skip loading if its not forced and pages is not empty
|
||||
if (!forceReload && pages.value?.isNotEmpty() == true) return
|
||||
|
||||
ioSafe {
|
||||
currentSyncApi?.let { repo ->
|
||||
_currentApiName.postValue(repo.name)
|
||||
|
@ -80,7 +85,6 @@ class LibraryViewModel : ViewModel() {
|
|||
it.value
|
||||
)
|
||||
}
|
||||
println("PAGES $pages")
|
||||
_pages.postValue(pages)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -617,10 +617,13 @@
|
|||
<string name="safe_mode_title">Safe Mode enabled</string>
|
||||
<string name="safe_mode_description">An unrecoverable crash occurred and we\'ve automatically disabled all extensions, so you can find and remove the extension which is causing trouble.</string>
|
||||
<string name="safe_mode_crash_info">View crash info</string>
|
||||
<string name="sort_by">Sort by</string>
|
||||
<string name="sort_rating_desc">Rating (High to Low)</string>
|
||||
<string name="sort_rating_asc">Rating (Low to High)</string>
|
||||
<string name="sort_updated_new">Updated (New to Old)</string>
|
||||
<string name="sort_updated_old">Updated (Old to New)</string>
|
||||
<string name="sort_alphabetical_a">Alphabetical (A to Z)</string>
|
||||
<string name="sort_alphabetical_z">Alphabetical (Z to A)</string>
|
||||
<string name="select_library">Select Library</string>
|
||||
<string name="open_with">Open with</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue