cloudstream-extensions/NginxProvider/src/main/kotlin/com/lagradost/NginxProviderPlugin.kt

35 lines
1.1 KiB
Kotlin
Raw Normal View History

package com.lagradost
2022-08-09 17:42:39 +00:00
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import android.content.Context
2022-08-17 20:20:31 +00:00
import androidx.appcompat.app.AppCompatActivity
import com.lagradost.cloudstream3.AcraApplication.Companion.context
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.AcraApplication.Companion.getActivity
import com.lagradost.cloudstream3.ui.settings.SettingsAccount
2022-08-09 17:42:39 +00:00
@CloudstreamPlugin
2022-08-17 20:20:31 +00:00
class NginxProviderPlugin : Plugin() {
val nginxApi = NginxApi(0)
2022-08-09 17:42:39 +00:00
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
2022-09-16 17:51:14 +00:00
nginxApi.init()
registerMainAPI(NginxProvider())
2022-08-17 20:20:31 +00:00
ioSafe {
nginxApi.initialize()
}
}
init {
this.openSettings = {
2022-08-17 20:43:00 +00:00
val activity = it as? AppCompatActivity
2022-08-17 20:20:31 +00:00
if (activity != null) {
val frag = NginxSettingsFragment(this, nginxApi)
frag.show(activity.supportFragmentManager, nginxApi.name)
}
}
2022-08-09 17:42:39 +00:00
}
2022-09-16 17:51:14 +00:00
}