File tree Expand file tree Collapse file tree
android/app/src/main/java/com/appzung/codepush/react Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import java .util .List ;
2020
2121public class CodePush implements ReactPackage {
22+ private static final Object LOCK = new Object ();
23+ private static volatile CodePush mCurrentInstance ;
24+
25+ public static CodePush getInstance (Context context ) {
26+ if (mCurrentInstance == null ) {
27+ synchronized (LOCK ) {
28+ if (mCurrentInstance == null ) {
29+ mCurrentInstance = new CodePush (context );
30+ }
31+ }
32+ }
33+ return mCurrentInstance ;
34+ }
2235
2336 private static boolean sIsRunningBinaryVersion = false ;
2437 private static boolean sNeedToReportRollback = false ;
@@ -47,13 +60,11 @@ public class CodePush implements ReactPackage {
4760
4861 private static ReactHostHolder mReactHostHolder ;
4962
50- private static CodePush mCurrentInstance ;
51-
5263 public static String getServiceUrl () {
5364 return mServerUrl ;
5465 }
5566
56- public CodePush (Context context ) {
67+ private CodePush (Context context ) {
5768 mContext = context .getApplicationContext ();
5869
5970 String releaseChannelPublicIdFromStrings = getCustomPropertyFromStringsIfExist ("ReleaseChannelPublicId" );
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ module.exports = {
22 dependency : {
33 platforms : {
44 android : {
5- packageInstance : 'new CodePush(getApplicationContext())' ,
5+ packageInstance : 'CodePush.getInstance (getApplicationContext())' ,
66 sourceDir : './android/app' ,
77 } ,
88 } ,
You can’t perform that action at this time.
0 commit comments