mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
benene 3
This commit is contained in:
parent
bb2f8a3e56
commit
3e3e1b6a9d
1 changed files with 48 additions and 48 deletions
|
@ -35,18 +35,23 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveAndUpload() {
|
private fun saveAndUpload() {
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
if (ScoreManager.privateCode.isNullOrBlank()) return
|
||||||
val uuid = usernameUUID
|
try {
|
||||||
if (uuid != null) {
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
settingsManager.edit()
|
val uuid = usernameUUID
|
||||||
.putString(getString(R.string.benene_count_uuid), uuid)
|
if (uuid != null) {
|
||||||
.putInt(getString(R.string.benene_count), count)
|
settingsManager.edit()
|
||||||
.apply()
|
.putString(getString(R.string.benene_count_uuid), uuid)
|
||||||
thread {
|
.putInt(getString(R.string.benene_count), count)
|
||||||
normalSafeApiCall {
|
.apply()
|
||||||
ScoreManager.addScore(uuid, count)
|
thread {
|
||||||
|
normalSafeApiCall {
|
||||||
|
ScoreManager.addScore(uuid, count)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,59 +66,54 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
|
||||||
|
|
||||||
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)
|
try {
|
||||||
usernameUUID =
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
settingsManager.getString(getString(R.string.benene_count_uuid), UUID.randomUUID().toString())
|
|
||||||
if (count > 20) {
|
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 (!ScoreManager.privateCode.isNullOrBlank()) {
|
||||||
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(
|
benenePref.summary =
|
||||||
count
|
if (count <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(
|
||||||
)
|
count
|
||||||
benenePref.setOnPreferenceClickListener {
|
)
|
||||||
try {
|
benenePref.setOnPreferenceClickListener {
|
||||||
count++
|
try {
|
||||||
settingsManager.edit().putInt(getString(R.string.benene_count), count).apply()
|
count++
|
||||||
var add = ""
|
settingsManager.edit().putInt(getString(R.string.benene_count), count).apply()
|
||||||
val localScoreBoard = scoreboard
|
var add = ""
|
||||||
if (localScoreBoard != null) {
|
val localScoreBoard = scoreboard
|
||||||
for ((index, score) in localScoreBoard.withIndex()) {
|
if (localScoreBoard != null) {
|
||||||
if (count > (score.score.toIntOrNull() ?: 0)) {
|
for ((index, score) in localScoreBoard.withIndex()) {
|
||||||
add = " (${index + 1}/${localScoreBoard.size})"
|
if (count > (score.score.toIntOrNull() ?: 0)) {
|
||||||
break
|
add = " (${index + 1}/${localScoreBoard.size})"
|
||||||
}
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it.summary = getString(R.string.benene_count_text).format(count) + add
|
|
||||||
saveAfterTime()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
}
|
||||||
|
it.summary = getString(R.string.benene_count_text).format(count) + add
|
||||||
return@setOnPreferenceClickListener true
|
saveAfterTime()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return@setOnPreferenceClickListener true
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
updatePrefrence.setOnPreferenceClickListener {
|
updatePrefrence.setOnPreferenceClickListener {
|
||||||
thread {
|
thread {
|
||||||
|
|
Loading…
Reference in a new issue