mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add callbacks
This commit is contained in:
parent
f0db3068d0
commit
2ad5ac1de1
2 changed files with 25 additions and 5 deletions
|
@ -22,6 +22,7 @@ import com.lagradost.cloudstream3.ui.result.setImage
|
||||||
import com.lagradost.cloudstream3.ui.result.setLinearListLayout
|
import com.lagradost.cloudstream3.ui.result.setLinearListLayout
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||||
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getAccounts
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.getDefaultAccount
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.getDefaultAccount
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setAccount
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.setAccount
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||||
|
@ -270,6 +271,21 @@ object AccountHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showAccountSelectLinear(context: Context) {
|
fun showAccountSelectLinear(context: Context) {
|
||||||
|
fun onAccountUpdated(account: DataStoreHelper.Account) {
|
||||||
|
val currentAccounts = DataStoreHelper.accounts.toMutableList()
|
||||||
|
|
||||||
|
val overrideIndex = currentAccounts.indexOfFirst { it.keyIndex == account.keyIndex }
|
||||||
|
|
||||||
|
if (overrideIndex != -1) {
|
||||||
|
currentAccounts[overrideIndex] = account
|
||||||
|
} else currentAccounts.add(account)
|
||||||
|
|
||||||
|
val currentHomePage = DataStoreHelper.currentHomePage
|
||||||
|
setAccount(account, false)
|
||||||
|
DataStoreHelper.currentHomePage = currentHomePage
|
||||||
|
DataStoreHelper.accounts = currentAccounts.toTypedArray()
|
||||||
|
}
|
||||||
|
|
||||||
val binding: AccountSelectLinearBinding = AccountSelectLinearBinding.inflate(
|
val binding: AccountSelectLinearBinding = AccountSelectLinearBinding.inflate(
|
||||||
LayoutInflater.from(context)
|
LayoutInflater.from(context)
|
||||||
)
|
)
|
||||||
|
@ -280,7 +296,7 @@ object AccountHelper {
|
||||||
|
|
||||||
binding.profilesRecyclerview.setLinearListLayout(isHorizontal = true)
|
binding.profilesRecyclerview.setLinearListLayout(isHorizontal = true)
|
||||||
binding.profilesRecyclerview.adapter = AccountAdapter(
|
binding.profilesRecyclerview.adapter = AccountAdapter(
|
||||||
DataStoreHelper.getAccounts(context),
|
getAccounts(context),
|
||||||
accountSelectCallback = { account ->
|
accountSelectCallback = { account ->
|
||||||
// Check if the selected account has a lock PIN set
|
// Check if the selected account has a lock PIN set
|
||||||
if (account.lockPin != null) {
|
if (account.lockPin != null) {
|
||||||
|
@ -297,9 +313,14 @@ object AccountHelper {
|
||||||
builder.dismissSafe()
|
builder.dismissSafe()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
accountCreateCallback = {},
|
accountCreateCallback = {
|
||||||
// TODO
|
onAccountUpdated(it)
|
||||||
accountEditCallback = {}
|
builder.dismissSafe()
|
||||||
|
},
|
||||||
|
accountEditCallback = {
|
||||||
|
onAccountUpdated(it)
|
||||||
|
builder.dismissSafe()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -44,7 +44,6 @@ class AccountSelectActivity : AppCompatActivity() {
|
||||||
accounts,
|
accounts,
|
||||||
// Handle the selected account
|
// Handle the selected account
|
||||||
accountSelectCallback = { onAccountSelected(it) },
|
accountSelectCallback = { onAccountSelected(it) },
|
||||||
// Handle the selected account
|
|
||||||
accountCreateCallback = { onAccountUpdated(it) },
|
accountCreateCallback = { onAccountUpdated(it) },
|
||||||
accountEditCallback = { onAccountUpdated(it) }
|
accountEditCallback = { onAccountUpdated(it) }
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue