This commit is contained in:
LagradOst 2021-08-30 23:58:09 +02:00
parent bb9c75de6d
commit bb2f8a3e56
2 changed files with 42 additions and 27 deletions

View file

@ -37,7 +37,7 @@ object ScoreManager {
} }
fun addScore(name: String, score: Int) { // plz dont cheat 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") khttp.get("$mainUrl/lb/$privateCode/add/$name/$score")
} }
} }

View file

@ -14,8 +14,8 @@ import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import java.lang.Exception
import java.util.* import java.util.*
import kotlin.Exception
import kotlin.concurrent.thread import kotlin.concurrent.thread
class SettingsFragment : PreferenceFragmentCompat() { class SettingsFragment : PreferenceFragmentCompat() {
@ -61,22 +61,32 @@ class SettingsFragment : PreferenceFragmentCompat() {
} }
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { 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() hideKeyboard()
setPreferencesFromResource(R.xml.settings, rootKey) setPreferencesFromResource(R.xml.settings, rootKey)
val updatePrefrence = findPreference<Preference>(getString(R.string.manual_check_update_key))!! val updatePrefrence = findPreference<Preference>(getString(R.string.manual_check_update_key))!!
val benenePref = findPreference<Preference>(getString(R.string.benene_count))!! 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) { if (count > 20) {
thread { thread {
scoreboard = normalSafeApiCall { ScoreManager.getScore() } 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 { benenePref.setOnPreferenceClickListener {
try { try {
count++ count++
@ -99,6 +109,11 @@ class SettingsFragment : PreferenceFragmentCompat() {
return@setOnPreferenceClickListener true return@setOnPreferenceClickListener true
} }
} catch (e: Exception) {
e.printStackTrace()
}
}
updatePrefrence.setOnPreferenceClickListener { updatePrefrence.setOnPreferenceClickListener {
thread { thread {