forked from recloudstream/cloudstream
benene 2
This commit is contained in:
parent
bb9c75de6d
commit
bb2f8a3e56
2 changed files with 42 additions and 27 deletions
|
@ -37,7 +37,7 @@ object ScoreManager {
|
|||
}
|
||||
|
||||
fun addScore(name: String, score: Int) { // plz dont cheat
|
||||
if(score < 0 || score > 100000 || privateCode.isNullOrBlank()) return
|
||||
if (score < 0 || score > 100000 || privateCode.isNullOrBlank()) return
|
||||
khttp.get("$mainUrl/lb/$privateCode/add/$name/$score")
|
||||
}
|
||||
}
|
|
@ -14,8 +14,8 @@ import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
|||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import java.lang.Exception
|
||||
import java.util.*
|
||||
import kotlin.Exception
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
|
@ -61,22 +61,32 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
count = settingsManager.getInt(getString(R.string.benene_count), 0)
|
||||
usernameUUID = settingsManager.getString(getString(R.string.benene_count_uuid), UUID.randomUUID().toString())
|
||||
|
||||
hideKeyboard()
|
||||
setPreferencesFromResource(R.xml.settings, rootKey)
|
||||
val updatePrefrence = findPreference<Preference>(getString(R.string.manual_check_update_key))!!
|
||||
|
||||
val benenePref = findPreference<Preference>(getString(R.string.benene_count))!!
|
||||
if (ScoreManager.privateCode.isNullOrBlank()) {
|
||||
benenePref.isVisible = false
|
||||
} else {
|
||||
benenePref.isVisible = true
|
||||
try {
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
count = settingsManager.getInt(getString(R.string.benene_count), 0)
|
||||
usernameUUID =
|
||||
settingsManager.getString(getString(R.string.benene_count_uuid), UUID.randomUUID().toString())
|
||||
if (count > 20) {
|
||||
thread {
|
||||
scoreboard = normalSafeApiCall { ScoreManager.getScore() }
|
||||
}
|
||||
}
|
||||
benenePref.summary = if(count <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(count)
|
||||
benenePref.summary =
|
||||
if (count <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(
|
||||
count
|
||||
)
|
||||
benenePref.setOnPreferenceClickListener {
|
||||
try {
|
||||
count++
|
||||
|
@ -99,6 +109,11 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
updatePrefrence.setOnPreferenceClickListener {
|
||||
thread {
|
||||
|
|
Loading…
Reference in a new issue