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 { | object ScoreManager { | ||||||
|     private const val mainUrl = "http://dreamlo.com" |     private const val mainUrl = "http://dreamlo.com" | ||||||
|     private const val publicCode = "612d3dcf8f40bb6e98bece15" |     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( |     data class DreamloMain( | ||||||
|         @JsonProperty("dreamlo") var dreamlo: Dreamlo |         @JsonProperty("dreamlo") var dreamlo: Dreamlo | ||||||
|  | @ -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") | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -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,45 +61,60 @@ 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 (count > 20) { |         if (ScoreManager.privateCode.isNullOrBlank()) { | ||||||
|             thread { |             benenePref.isVisible = false | ||||||
|                 scoreboard = normalSafeApiCall { ScoreManager.getScore() } |         } else { | ||||||
|             } |             benenePref.isVisible = true | ||||||
|         } |  | ||||||
|         benenePref.summary = if(count <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(count) |  | ||||||
|         benenePref.setOnPreferenceClickListener { |  | ||||||
|             try { |             try { | ||||||
|                 count++ |                 val settingsManager = PreferenceManager.getDefaultSharedPreferences(context) | ||||||
|                 settingsManager.edit().putInt(getString(R.string.benene_count), count).apply() | 
 | ||||||
|                 var add = "" |                 count = settingsManager.getInt(getString(R.string.benene_count), 0) | ||||||
|                 val localScoreBoard = scoreboard |                 usernameUUID = | ||||||
|                 if (localScoreBoard != null) { |                     settingsManager.getString(getString(R.string.benene_count_uuid), UUID.randomUUID().toString()) | ||||||
|                     for ((index, score) in localScoreBoard.withIndex()) { |                 if (count > 20) { | ||||||
|                         if (count > (score.score.toIntOrNull() ?: 0)) { |                     thread { | ||||||
|                             add = " (${index + 1}/${localScoreBoard.size})" |                         scoreboard = normalSafeApiCall { ScoreManager.getScore() } | ||||||
|                             break |  | ||||||
|                         } |  | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 it.summary = getString(R.string.benene_count_text).format(count) + add |                 benenePref.summary = | ||||||
|                 saveAfterTime() |                     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) { |             } catch (e: Exception) { | ||||||
|                 e.printStackTrace() |                 e.printStackTrace() | ||||||
|             } |             } | ||||||
| 
 |  | ||||||
|             return@setOnPreferenceClickListener true |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|         updatePrefrence.setOnPreferenceClickListener { |         updatePrefrence.setOnPreferenceClickListener { | ||||||
|             thread { |             thread { | ||||||
|                 if (!requireActivity().runAutoUpdate(false)) { |                 if (!requireActivity().runAutoUpdate(false)) { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue