mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
make functions
This commit is contained in:
parent
3f134dc0b2
commit
40141f2d27
1 changed files with 37 additions and 0 deletions
|
@ -7,7 +7,9 @@ import android.content.res.Resources
|
|||
import android.os.Environment
|
||||
import android.widget.Toast
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||
|
@ -22,6 +24,7 @@ import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData
|
|||
import com.lagradost.cloudstream3.utils.VideoDownloadManager.sanitizeFilename
|
||||
import com.lagradost.cloudstream3.APIHolder.removePluginMapping
|
||||
import com.lagradost.cloudstream3.plugins.RepositoryManager.PREBUILT_REPOSITORIES
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.ExtractorApi
|
||||
import com.lagradost.cloudstream3.utils.extractorApis
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
|
@ -370,6 +373,40 @@ object PluginManager {
|
|||
)
|
||||
}
|
||||
|
||||
private suspend fun downloadAllPluginsFromRepository(
|
||||
activity: Activity,
|
||||
repositoryUrl: String
|
||||
) {
|
||||
getRepoPlugins(repositoryUrl)?.apmap {
|
||||
downloadAndLoadPlugin(
|
||||
activity,
|
||||
it.second.url,
|
||||
it.second.internalName,
|
||||
repositoryUrl
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun Activity.downloadAllPluginsDialog(repositoryUrl: String) {
|
||||
runOnUiThread {
|
||||
val context = this
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
|
||||
builder.setTitle(
|
||||
"Download all plugins from this repo?"
|
||||
)
|
||||
builder.apply {
|
||||
// TODO: R.string Yes No
|
||||
setPositiveButton("Yes") { _, _ ->
|
||||
showToast(context, R.string.download_started, Toast.LENGTH_LONG)
|
||||
ioSafe { downloadAllPluginsFromRepository(context, repositoryUrl) }
|
||||
}
|
||||
|
||||
setNegativeButton("No") { _, _ -> }
|
||||
}
|
||||
builder.show()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isFilePath will treat the pluginUrl as as the filepath instead of url
|
||||
* */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue