mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fix Random button on Main page. (#136)
* Fix Random button on Main page. * Removed unnecessary line
This commit is contained in:
parent
020b3b7472
commit
b6d0141cd9
1 changed files with 9 additions and 6 deletions
|
@ -521,16 +521,13 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Disable Random button, if its toggled off on settings
|
//Load value for toggling Random button. Hide at startup
|
||||||
context?.let {
|
context?.let {
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(it)
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(it)
|
||||||
toggleRandomButton =
|
toggleRandomButton =
|
||||||
settingsManager.getBoolean(getString(R.string.random_button_key), false)
|
settingsManager.getBoolean(getString(R.string.random_button_key), false)
|
||||||
home_random?.isVisible = toggleRandomButton
|
|
||||||
if (!toggleRandomButton) {
|
|
||||||
home_random?.visibility = View.GONE
|
home_random?.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
observe(homeViewModel.apiName) { apiName ->
|
observe(homeViewModel.apiName) { apiName ->
|
||||||
currentApiName = apiName
|
currentApiName = apiName
|
||||||
|
@ -626,6 +623,7 @@ class HomeFragment : Fragment() {
|
||||||
home_loading_shimmer?.stopShimmer()
|
home_loading_shimmer?.stopShimmer()
|
||||||
|
|
||||||
val d = data.value
|
val d = data.value
|
||||||
|
val mutableListOfResponse = mutableListOf<SearchResponse>()
|
||||||
listHomepageItems.clear()
|
listHomepageItems.clear()
|
||||||
|
|
||||||
// println("ITEMCOUNT: ${d.values.size} ${home_master_recycler?.adapter?.itemCount}")
|
// println("ITEMCOUNT: ${d.values.size} ${home_master_recycler?.adapter?.itemCount}")
|
||||||
|
@ -638,6 +636,11 @@ class HomeFragment : Fragment() {
|
||||||
home_loading_error?.isVisible = false
|
home_loading_error?.isVisible = false
|
||||||
home_loaded?.isVisible = true
|
home_loaded?.isVisible = true
|
||||||
if (toggleRandomButton) {
|
if (toggleRandomButton) {
|
||||||
|
//Flatten list
|
||||||
|
d.values.forEach { dlist ->
|
||||||
|
mutableListOfResponse.addAll(dlist.list.list)
|
||||||
|
}
|
||||||
|
listHomepageItems.addAll(mutableListOfResponse.distinctBy { it.url })
|
||||||
home_random?.isVisible = listHomepageItems.isNotEmpty()
|
home_random?.isVisible = listHomepageItems.isNotEmpty()
|
||||||
} else {
|
} else {
|
||||||
home_random?.isGone = true
|
home_random?.isGone = true
|
||||||
|
|
Loading…
Reference in a new issue