mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
onCreate, onDestroy fix
This commit is contained in:
parent
7ef9b18e00
commit
fcff6de838
3 changed files with 18 additions and 16 deletions
|
@ -35,6 +35,7 @@ import com.lagradost.cloudstream3.APIHolder.apis
|
||||||
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
|
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
|
||||||
import com.lagradost.cloudstream3.APIHolder.initAll
|
import com.lagradost.cloudstream3.APIHolder.initAll
|
||||||
import com.lagradost.cloudstream3.APIHolder.updateHasTrailers
|
import com.lagradost.cloudstream3.APIHolder.updateHasTrailers
|
||||||
|
import com.lagradost.cloudstream3.AcraApplication.Companion.context
|
||||||
import com.lagradost.cloudstream3.CommonActivity.loadThemes
|
import com.lagradost.cloudstream3.CommonActivity.loadThemes
|
||||||
import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent
|
import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent
|
||||||
import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent
|
import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent
|
||||||
|
@ -596,7 +597,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
apis = allProviders.distinctBy { it }
|
apis = allProviders.distinctBy { it }
|
||||||
|
|
||||||
if (githubApi.getLatestLoginData() != null && settingsManager.getBoolean(getString(R.string.automatic_cloud_backups), false)){
|
if (githubApi.getLatestLoginData() != null && settingsManager.getBoolean(getString(R.string.automatic_cloud_backups), false)){
|
||||||
this@MainActivity.restorePromptGithub()
|
context?.restorePromptGithub()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.lagradost.cloudstream3.syncproviders.providers
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
|
import com.lagradost.cloudstream3.AcraApplication.Companion.context
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.setKey
|
||||||
|
@ -111,8 +112,8 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
||||||
userAvatar = it.owner.userAvatar,
|
userAvatar = it.owner.userAvatar,
|
||||||
gistUrl = it.gistUrl
|
gistUrl = it.gistUrl
|
||||||
))
|
))
|
||||||
runOnMainThread {
|
ioSafe {
|
||||||
FragmentActivity().restorePromptGithub()
|
context?.restorePromptGithub()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -335,14 +335,14 @@ object BackupUtils {
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
suspend fun Context.restorePromptGithub() {
|
||||||
fun FragmentActivity.restorePromptGithub() =
|
|
||||||
ioSafe {
|
|
||||||
val gistUrl = githubApi.getLatestLoginData()?.server ?: throw IllegalAccessException()
|
val gistUrl = githubApi.getLatestLoginData()?.server ?: throw IllegalAccessException()
|
||||||
val jsondata = app.get(gistUrl).text
|
val jsondata = app.get(gistUrl).text
|
||||||
val dataraw = parseJson<GithubApi.gistsElements>(jsondata ?: "").files.values.first().dataRaw?: throw IllegalAccessException()
|
val dataraw =
|
||||||
|
parseJson<GithubApi.gistsElements>(jsondata ?: "").files.values.first().dataRaw
|
||||||
|
?: throw IllegalAccessException()
|
||||||
val data = parseJson<BackupFile>(dataraw)
|
val data = parseJson<BackupFile>(dataraw)
|
||||||
this@restorePromptGithub.restore(
|
restore(
|
||||||
data,
|
data,
|
||||||
restoreSettings = true,
|
restoreSettings = true,
|
||||||
restoreDataStore = true
|
restoreDataStore = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue