From b8797883a98f58a57008197441068737c77cd1c6 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Wed, 22 Oct 2025 20:02:35 -0600 Subject: [PATCH 1/2] Fix openSettings context access I've mentioned to extension developers already, but it's probably good to follow here as well. Rather than using context to get the activity outside of the callback, We have to use the version provided to the callback. Otherwise when there is an activity state change the context is outdated and the settings dialog won't open, or in some cases cause the app to crash with an exception. --- .../src/main/kotlin/com/example/ExamplePlugin.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt b/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt index 79fffa5ea3..294d2b05a5 100644 --- a/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt +++ b/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt @@ -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 val frag = BlankFragment(this) - activity?.let { - frag.show(it.supportFragmentManager, "Frag") - } + frag.show(activity.supportFragmentManager, "Frag") } } -} \ No newline at end of file +} From 174fc02404a5c83e99331123866ad13dd70e8b8c Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Sat, 1 Nov 2025 10:11:55 -0600 Subject: [PATCH 2/2] Update --- ExampleProvider/build.gradle.kts | 12 ++++++------ .../src/main/kotlin/com/example/ExamplePlugin.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ExampleProvider/build.gradle.kts b/ExampleProvider/build.gradle.kts index 3270d2912f..777aa7c799 100644 --- a/ExampleProvider/build.gradle.kts +++ b/ExampleProvider/build.gradle.kts @@ -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") diff --git a/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt b/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt index 294d2b05a5..c334c2a873 100644 --- a/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt +++ b/ExampleProvider/src/main/kotlin/com/example/ExamplePlugin.kt @@ -17,4 +17,4 @@ class ExamplePlugin: Plugin() { frag.show(activity.supportFragmentManager, "Frag") } } -} +} \ No newline at end of file