mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
A few bug fixes and cleanup
This commit is contained in:
parent
411a2444ff
commit
842ea97415
5 changed files with 17 additions and 12 deletions
|
@ -80,12 +80,14 @@ class AccountAdapter(
|
|||
is AccountListItemEditBinding -> binding.apply {
|
||||
if (account == null) return@apply
|
||||
|
||||
val isTv = isTvSettings() || !root.isInTouchMode
|
||||
|
||||
val isLastUsedAccount = account.keyIndex == DataStoreHelper.selectedKeyIndex
|
||||
|
||||
accountName.text = account.name
|
||||
accountImage.setImage(account.image)
|
||||
lockIcon.isVisible = account.lockPin != null
|
||||
outline.isVisible = !isTvSettings() && isLastUsedAccount
|
||||
outline.isVisible = !isTv && isLastUsedAccount
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
accountImage.setRenderEffect(
|
||||
|
@ -95,7 +97,7 @@ class AccountAdapter(
|
|||
)
|
||||
}
|
||||
|
||||
if (isTvSettings()) {
|
||||
if (isTv) {
|
||||
root.isFocusableInTouchMode = true
|
||||
if (isLastUsedAccount) {
|
||||
root.requestFocus()
|
||||
|
|
|
@ -5,14 +5,13 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.CommonActivity
|
||||
import com.lagradost.cloudstream3.CommonActivity.loadThemes
|
||||
import com.lagradost.cloudstream3.MainActivity
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.ActivityAccountSelectBinding
|
||||
import com.lagradost.cloudstream3.mvvm.observe
|
||||
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
|
||||
import com.lagradost.cloudstream3.ui.account.AccountAdapter.Companion.VIEW_TYPE_EDIT_ACCOUNT
|
||||
import com.lagradost.cloudstream3.ui.account.AccountAdapter.Companion.VIEW_TYPE_SELECT_ACCOUNT
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||
|
@ -50,7 +49,7 @@ class AccountSelectActivity : AppCompatActivity() {
|
|||
val binding = ActivityAccountSelectBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
val recyclerView: RecyclerView = binding.accountRecyclerView
|
||||
val recyclerView: AutofitRecyclerView = binding.accountRecyclerView
|
||||
|
||||
val viewModel = ViewModelProvider(this)[AccountViewModel::class.java]
|
||||
|
||||
|
@ -83,6 +82,12 @@ class AccountSelectActivity : AppCompatActivity() {
|
|||
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
if (isTvSettings()) {
|
||||
binding.editAccountButton.setBackgroundResource(
|
||||
R.drawable.player_button_tv_attr_no_bg
|
||||
)
|
||||
}
|
||||
|
||||
observe(viewModel.isEditing) { isEditing ->
|
||||
if (isEditing) {
|
||||
binding.editAccountButton.setImageResource(R.drawable.ic_baseline_close_24)
|
||||
|
@ -114,11 +119,9 @@ class AccountSelectActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
if (isTvSettings()) {
|
||||
val spanSize = if (accounts.count() <= 6) {
|
||||
recyclerView.spanCount = if (accounts.count() <= 6) {
|
||||
accounts.count()
|
||||
} else 6
|
||||
|
||||
recyclerView.layoutManager = GridLayoutManager(this, spanSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class AccountViewModel : ViewModel() {
|
|||
account: DataStoreHelper.Account,
|
||||
context: Context
|
||||
) {
|
||||
val currentAccounts = getAccounts(context).toMutableList()
|
||||
val currentAccounts = DataStoreHelper.accounts.toMutableList()
|
||||
|
||||
val overrideIndex = currentAccounts.indexOfFirst { it.keyIndex == account.keyIndex }
|
||||
|
||||
|
|
|
@ -120,11 +120,11 @@ class LibraryViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
init {
|
||||
MainActivity.reloadHomeEvent += ::reloadPages
|
||||
MainActivity.bookmarksUpdatedEvent += ::reloadPages
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
MainActivity.reloadHomeEvent -= ::reloadPages
|
||||
MainActivity.bookmarksUpdatedEvent -= ::reloadPages
|
||||
super.onCleared()
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
android:src="@drawable/ic_baseline_edit_24"
|
||||
android:focusable="true"
|
||||
android:nextFocusDown="@id/account_recycler_view"
|
||||
android:background="@drawable/player_button_tv_attr_no_bg"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/manage_accounts"
|
||||
app:tint="@color/player_on_button_tv_attr" />
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue