react-native-tpstreams 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,24 +65,29 @@ class FragmentModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
|
|
|
65
65
|
|
|
66
66
|
@ReactMethod
|
|
67
67
|
fun closeCustomFragment() {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
Log.e("FragmentModule", "closeCustomFragment() called")
|
|
69
|
+
|
|
70
|
+
// Ensure currentActivity is a FragmentActivity
|
|
71
|
+
val activity = currentActivity as? FragmentActivity
|
|
72
|
+
if (activity == null || activity.isFinishing || activity.isDestroyed) {
|
|
73
|
+
Log.e("FragmentModule", "Activity is null, finishing, or destroyed")
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
val fragmentManager = activity.supportFragmentManager
|
|
78
|
+
val playerFragment = fragmentManager.findFragmentByTag("PLAYER_FRAGMENT") as? PlayerFragment
|
|
79
|
+
|
|
80
|
+
if (playerFragment != null) {
|
|
81
|
+
Log.d("FragmentModule", "Removing PlayerFragment")
|
|
82
|
+
fragmentManager.beginTransaction()
|
|
83
|
+
.remove(playerFragment)
|
|
84
|
+
.commitAllowingStateLoss() // Avoid IllegalStateException
|
|
85
|
+
} else if (fragmentManager.backStackEntryCount > 0) {
|
|
86
|
+
Log.d("FragmentModule", "Popping back stack")
|
|
87
|
+
fragmentManager.popBackStack()
|
|
79
88
|
} else {
|
|
80
|
-
|
|
89
|
+
Log.e("FragmentModule", "No fragments to remove")
|
|
81
90
|
}
|
|
82
|
-
} ?: run {
|
|
83
|
-
// Handle the error if the activity is not a FragmentActivity
|
|
84
|
-
Log.e("ReactNativeJS", "Current activity is not a FragmentActivity")
|
|
85
|
-
}
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
@ReactMethod
|
|
@@ -39,7 +39,14 @@ class TpStreamsPlayerView @JvmOverloads constructor(
|
|
|
39
39
|
|
|
40
40
|
private fun updateFragment() {
|
|
41
41
|
if (!videoId.isNullOrEmpty() && !accessToken.isNullOrEmpty()) {
|
|
42
|
+
fragmentModule?.closeCustomFragment()
|
|
42
43
|
fragmentModule?.showCustomFragment(videoId!!, accessToken!!)
|
|
43
44
|
}
|
|
44
45
|
}
|
|
46
|
+
|
|
47
|
+
override fun onDetachedFromWindow() {
|
|
48
|
+
super.onDetachedFromWindow()
|
|
49
|
+
fragmentModule?.closeCustomFragment()
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
}
|