Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ExampleProvider/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ cloudstream {
authors = listOf("Cloudburst", "Luna712")

/**
* Status int as one of the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta-only
**/
* Status int as one of the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta-only
*/
status = 1 // Will be 3 if unspecified

tvTypes = listOf("Movie")
Expand Down
11 changes: 3 additions & 8 deletions ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ import com.lagradost.cloudstream3.plugins.Plugin

@CloudstreamPlugin
class ExamplePlugin: Plugin() {
private var activity: AppCompatActivity? = null

override fun load(context: Context) {
activity = context as? AppCompatActivity

// All providers should be added in this manner
registerMainAPI(ExampleProvider())

openSettings = {
openSettings = { ctx ->
val activity = ctx as AppCompatActivity

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a a cast that might fail if we change how context is passed. Please use as?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think it was possible to fail for 2 reasons.

  1. It's passed as requireContext not to great but doesn't matter because...
  2. it catches any Throwable so it would handle bad context or failed casting automatically

I mean I can use a check like that but just didn't think we needed to.

val frag = BlankFragment(this)
activity?.let {
frag.show(it.supportFragmentManager, "Frag")
}
frag.show(activity.supportFragmentManager, "Frag")
}
}
}