mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
benene 2
This commit is contained in:
parent
bb9c75de6d
commit
bb2f8a3e56
2 changed files with 42 additions and 27 deletions
|
@ -8,7 +8,7 @@ import com.lagradost.cloudstream3.mapper
|
|||
object ScoreManager {
|
||||
private const val mainUrl = "http://dreamlo.com"
|
||||
private const val publicCode = "612d3dcf8f40bb6e98bece15"
|
||||
var privateCode: String? = BuildConfig.PRIVATE_BENENE_KEY // plz keep it a bit fair
|
||||
var privateCode: String? = BuildConfig.PRIVATE_BENENE_KEY // plz keep it a bit fair
|
||||
|
||||
data class DreamloMain(
|
||||
@JsonProperty("dreamlo") var dreamlo: Dreamlo
|
||||
|
@ -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,45 +61,60 @@ 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 (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.setOnPreferenceClickListener {
|
||||
if (ScoreManager.privateCode.isNullOrBlank()) {
|
||||
benenePref.isVisible = false
|
||||
} else {
|
||||
benenePref.isVisible = true
|
||||
try {
|
||||
count++
|
||||
settingsManager.edit().putInt(getString(R.string.benene_count), count).apply()
|
||||
var add = ""
|
||||
val localScoreBoard = scoreboard
|
||||
if (localScoreBoard != null) {
|
||||
for ((index, score) in localScoreBoard.withIndex()) {
|
||||
if (count > (score.score.toIntOrNull() ?: 0)) {
|
||||
add = " (${index + 1}/${localScoreBoard.size})"
|
||||
break
|
||||
}
|
||||
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() }
|
||||
}
|
||||
}
|
||||
it.summary = getString(R.string.benene_count_text).format(count) + add
|
||||
saveAfterTime()
|
||||
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++
|
||||
settingsManager.edit().putInt(getString(R.string.benene_count), count).apply()
|
||||
var add = ""
|
||||
val localScoreBoard = scoreboard
|
||||
if (localScoreBoard != null) {
|
||||
for ((index, score) in localScoreBoard.withIndex()) {
|
||||
if (count > (score.score.toIntOrNull() ?: 0)) {
|
||||
add = " (${index + 1}/${localScoreBoard.size})"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
it.summary = getString(R.string.benene_count_text).format(count) + add
|
||||
saveAfterTime()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
|
||||
|
||||
updatePrefrence.setOnPreferenceClickListener {
|
||||
thread {
|
||||
if (!requireActivity().runAutoUpdate(false)) {
|
||||
|
|
Loading…
Reference in a new issue