@takeoffmedia/react-native-penthera 0.2.56 → 0.2.58

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.
@@ -1,25 +1,19 @@
1
1
  package com.takeoffmediareactnativepenthera
2
2
 
3
3
  import EventEmitter
4
- import android.app.Activity
5
4
  import android.util.Log
6
- import com.facebook.react.bridge.Arguments
7
5
  import com.facebook.react.bridge.LifecycleEventListener
8
6
  import com.facebook.react.bridge.ReactApplicationContext
9
7
  import com.facebook.react.bridge.ReactContextBaseJavaModule
10
8
  import com.facebook.react.bridge.ReactMethod
11
9
  import com.facebook.react.bridge.Promise
12
10
  import com.facebook.react.bridge.ReadableArray
13
- import com.facebook.react.bridge.ReadableMap
14
- import com.facebook.react.bridge.WritableMap
15
11
  import com.takeoffmediareactnativepenthera.virtuoso.OfflineVideoEngine
16
- import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
17
12
 
18
13
 
19
14
  class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
20
15
 
21
16
  private var offlineVideoEngine: OfflineVideoEngine = OfflineVideoEngine(reactContext)
22
- private var activity: Activity? = null
23
17
  private var appState: String = "active"
24
18
  val reactContext: ReactApplicationContext = reactContext
25
19
 
@@ -28,7 +22,6 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
28
22
  super.initialize()
29
23
 
30
24
  EventEmitter.sharedInstance.registerEventEmitter(this)
31
- activity = currentActivity
32
25
  }
33
26
 
34
27
  // Example method
@@ -40,12 +33,12 @@ class PentheraModule(reactContext: ReactApplicationContext) : ReactContextBaseJa
40
33
 
41
34
  @ReactMethod
42
35
  fun initializeSdk(user: String, backplaneUrl: String, publicKey: String, privateKey: String, promise: Promise) {
43
- offlineVideoEngine?.setup(user, backplaneUrl, publicKey, privateKey, activity!!, promise)
36
+ offlineVideoEngine?.setup(user, backplaneUrl, publicKey, privateKey, promise)
44
37
  }
45
38
 
46
39
  @ReactMethod
47
40
  fun download(data: String){
48
- offlineVideoEngine?.downloadAsset(data, activity!!)
41
+ offlineVideoEngine?.downloadAsset(data)
49
42
  }
50
43
  @ReactMethod
51
44
  fun getDownloads(blank: String, promise: Promise) {
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
4
4
  import android.app.Activity
5
5
  import android.content.Context
6
6
  import android.util.Log
7
- import android.widget.Toast
8
7
  import com.bitmovin.player.reactnative.PlayerModule
9
8
  import com.bitmovin.player.reactnative.converter.JsonConverter
10
9
 
@@ -28,13 +27,11 @@ import com.facebook.react.bridge.Arguments
28
27
  import com.facebook.react.uimanager.UIManagerModule
29
28
  import com.facebook.react.bridge.Promise
30
29
  import com.facebook.react.bridge.ReadableArray
31
- import com.facebook.react.bridge.ReadableMap
32
30
  import com.penthera.virtuososdk.client.AncillaryFile
33
31
  import org.json.JSONArray
34
32
  import org.json.JSONObject
35
33
  import java.text.SimpleDateFormat
36
34
  import java.util.Calendar
37
- import java.util.TimeZone
38
35
 
39
36
  class OfflineVideoEngine(private val context: ReactApplicationContext) {
40
37
 
@@ -52,7 +49,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
52
49
  }
53
50
  }
54
51
 
55
- private fun getVirtuoso(activity: Activity): Virtuoso {
52
+ private fun getInstanceVirtuoso(): Virtuoso {
56
53
  virtuoso = Virtuoso(context)
57
54
  queueObserver = AssetQueueObserver(this, virtuoso)
58
55
  onResume()
@@ -76,10 +73,9 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
76
73
  backplaneUrl: String,
77
74
  publicKey: String,
78
75
  privateKey: String,
79
- activity: Activity,
80
76
  promise: Promise,
81
77
  ) {
82
- val backplane = getVirtuoso(activity)
78
+ val backplane = getInstanceVirtuoso()
83
79
  val status = backplane.backplane?.authenticationStatus
84
80
  val nameDevice = android.os.Build.MODEL
85
81
  if (status == AuthenticationStatus.NOT_AUTHENTICATED) {
@@ -104,7 +100,7 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
104
100
  }
105
101
 
106
102
 
107
- fun downloadAsset(newItem: String, activity: Activity) {
103
+ fun downloadAsset(newItem: String) {
108
104
  val data = JSONObject(newItem)
109
105
  val item = data["item"] as JSONObject
110
106
  assetId.add(item["id"].toString())
@@ -172,7 +168,6 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
172
168
  val columnNames = cursor?.columnNames
173
169
 
174
170
  while (cursor?.moveToNext() == true && columnNames != null) {
175
- val assetManager = virtuoso.assetManager
176
171
  val dataMap = mutableMapOf<String, Any>()
177
172
  var eap = ""
178
173
  var ead = ""
@@ -208,6 +203,11 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
208
203
  if (columnName == "eap") {
209
204
  eap = value
210
205
  }
206
+ if(columnName == "activePercentOfDownloads"){
207
+ val percentage = value.toDouble() * 100
208
+ val isComplete = percentage == 100.0
209
+ dataMap["isCompleted"] = isComplete
210
+ }
211
211
  if (columnName == "firstPlayTime") {
212
212
  var eadFormated = dateToString(ead)
213
213
  var eapFormated = dateToString(eap)
@@ -218,7 +218,6 @@ class OfflineVideoEngine(private val context: ReactApplicationContext) {
218
218
 
219
219
  }
220
220
  }
221
- dataMap["isCompleted"] = dataMap["currentSize"] == dataMap["expectedSize"]
222
221
  dataMap["isPaused"] = false
223
222
  completedList.add(dataMap)
224
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeoffmedia/react-native-penthera",
3
- "version": "0.2.56",
3
+ "version": "0.2.58",
4
4
  "description": "test",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",