react-native-bootsplash 4.0.1 → 4.0.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.
@@ -21,7 +21,6 @@ import com.facebook.react.bridge.UiThreadUtil;
21
21
  import com.facebook.react.common.ReactConstants;
22
22
  import com.facebook.react.module.annotations.ReactModule;
23
23
 
24
- import java.util.Stack;
25
24
  import java.util.Timer;
26
25
  import java.util.TimerTask;
27
26
 
@@ -40,7 +39,7 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule implements Li
40
39
  @Nullable
41
40
  private static SplashScreen mSplashScreen = null;
42
41
 
43
- private static final Stack<RNBootSplashTask> mTaskStack = new Stack<>();
42
+ private static final RNBootSplashQueue<RNBootSplashTask> mTaskQueue = new RNBootSplashQueue<>();
44
43
  private static Status mStatus = Status.HIDDEN;
45
44
  private static boolean mIsAppInForeground = true;
46
45
  private static boolean mShouldFade = false;
@@ -114,11 +113,12 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule implements Li
114
113
  }
115
114
 
116
115
  private void shiftNextTask() {
117
- if (mStatus != Status.TRANSITIONING &&
118
- mIsAppInForeground &&
119
- mTaskStack.size() > 0) {
120
- RNBootSplashTask task = mTaskStack.pop();
121
- hideWithTask(task);
116
+ if (mStatus != Status.TRANSITIONING && mIsAppInForeground) {
117
+ RNBootSplashTask task = mTaskQueue.shift();
118
+
119
+ if (task != null) {
120
+ hideWithTask(task);
121
+ }
122
122
  }
123
123
  }
124
124
 
@@ -182,7 +182,7 @@ public class RNBootSplashModule extends ReactContextBaseJavaModule implements Li
182
182
  if (mSplashScreen == null || mStatus == Status.HIDDEN) {
183
183
  promise.resolve(true);
184
184
  } else {
185
- mTaskStack.push(new RNBootSplashTask(fade, promise));
185
+ mTaskQueue.push(new RNBootSplashTask(fade, promise));
186
186
  shiftNextTask();
187
187
  }
188
188
  }
@@ -0,0 +1,31 @@
1
+ package com.zoontek.rnbootsplash;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ import java.util.Vector;
7
+
8
+ /**
9
+ * Represents a first-in-first-out (FIFO) thread safe queue of objects.
10
+ * Its source code is based on Java internal <code>Stack</code>.
11
+ */
12
+ public class RNBootSplashQueue<E> extends Vector<E> {
13
+
14
+ public RNBootSplashQueue() {}
15
+
16
+ @Nullable
17
+ public synchronized E shift() {
18
+ if (size() == 0) {
19
+ return null;
20
+ }
21
+
22
+ E item = elementAt(0);
23
+ removeElementAt(0);
24
+
25
+ return item;
26
+ }
27
+
28
+ public void push(@NonNull E item) {
29
+ addElement(item);
30
+ }
31
+ }
@@ -3,7 +3,7 @@
3
3
  #import <React/RCTBridge.h>
4
4
  #import <React/RCTUtils.h>
5
5
 
6
- static NSMutableArray<RNBootSplashTask *> *_taskStack = nil;
6
+ static NSMutableArray<RNBootSplashTask *> *_taskQueue = nil;
7
7
  static RCTRootView *_rootView = nil;
8
8
  static RNBootSplashStatus _status = RNBootSplashStatusHidden;
9
9
 
@@ -37,7 +37,7 @@ RCT_EXPORT_MODULE();
37
37
  rootView:(RCTRootView * _Nonnull)rootView {
38
38
  _rootView = rootView;
39
39
  _status = RNBootSplashStatusVisible;
40
- _taskStack = [[NSMutableArray alloc] init];
40
+ _taskQueue = [[NSMutableArray alloc] init];
41
41
 
42
42
  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
43
43
  [_rootView setLoadingView:[[storyboard instantiateInitialViewController] view]];
@@ -86,10 +86,10 @@ RCT_EXPORT_MODULE();
86
86
 
87
87
  + (void)shiftNextTask {
88
88
  if (_status != RNBootSplashStatusTransitioning &&
89
- [_taskStack count] > 0 &&
89
+ [_taskQueue count] > 0 &&
90
90
  [[UIApplication sharedApplication] applicationState] != UIApplicationStateBackground) {
91
- RNBootSplashTask *task = [_taskStack objectAtIndex:0];
92
- [_taskStack removeObjectAtIndex:0];
91
+ RNBootSplashTask *task = [_taskQueue objectAtIndex:0];
92
+ [_taskQueue removeObjectAtIndex:0];
93
93
 
94
94
  [self hideWithTask:task];
95
95
  }
@@ -141,7 +141,7 @@ RCT_REMAP_METHOD(hide,
141
141
  RNBootSplashTask *task = [[RNBootSplashTask alloc] initWithFade:fade
142
142
  resolver:resolve];
143
143
 
144
- [_taskStack addObject:task];
144
+ [_taskQueue addObject:task];
145
145
  [RNBootSplash shiftNextTask];
146
146
  }
147
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-bootsplash",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "license": "MIT",
5
5
  "description": "Display a bootsplash on your app starts. Hide it when you want.",
6
6
  "author": "Mathieu Acthernoene <zoontek@gmail.com>",