Showing
4 changed files
with
73 additions
and
15 deletions
| ... | @@ -237,13 +237,13 @@ | ... | @@ -237,13 +237,13 @@ |
| 237 | <!-- </intent-filter>--> | 237 | <!-- </intent-filter>--> |
| 238 | <!-- </receiver>--> | 238 | <!-- </receiver>--> |
| 239 | 239 | ||
| 240 | - <receiver | 240 | +<!-- <receiver--> |
| 241 | - android:name=".receivers.BluetoothStateChangeReceiver" | 241 | +<!-- android:name=".receivers.BluetoothStateChangeReceiver"--> |
| 242 | - android:exported="false"> | 242 | +<!-- android:exported="false">--> |
| 243 | - <intent-filter> | 243 | +<!-- <intent-filter>--> |
| 244 | - <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" /> | 244 | +<!-- <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />--> |
| 245 | - </intent-filter> | 245 | +<!-- </intent-filter>--> |
| 246 | - </receiver> | 246 | +<!-- </receiver>--> |
| 247 | 247 | ||
| 248 | <receiver | 248 | <receiver |
| 249 | android:name=".receivers.WarplyInAppNotificationReceiver" | 249 | android:name=".receivers.WarplyInAppNotificationReceiver" | ... | ... |
| ... | @@ -137,6 +137,19 @@ public enum Warply { | ... | @@ -137,6 +137,19 @@ public enum Warply { |
| 137 | }); | 137 | }); |
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | + public static WarplyInitializer getWarplyInitializer(Context context, WarplyReadyCallback callback) { | ||
| 141 | + return new WarplyInitializer(context, true, callback, new WarplyInitializer.WarplyInitCallback() { | ||
| 142 | + | ||
| 143 | + @Override | ||
| 144 | + public void onInit(Context context) { | ||
| 145 | + if (context != null) { | ||
| 146 | + INSTANCE.mContext = context.getApplicationContext(); | ||
| 147 | + } | ||
| 148 | + initInternal(context); | ||
| 149 | + } | ||
| 150 | + }); | ||
| 151 | + } | ||
| 152 | + | ||
| 140 | private static void initInternal(Context context) { | 153 | private static void initInternal(Context context) { |
| 141 | if (/*isInitialized()*/ context == null) { | 154 | if (/*isInitialized()*/ context == null) { |
| 142 | INSTANCE.check(); | 155 | INSTANCE.check(); |
| ... | @@ -1980,7 +1993,7 @@ public enum Warply { | ... | @@ -1980,7 +1993,7 @@ public enum Warply { |
| 1980 | @Override | 1993 | @Override |
| 1981 | public void onServerPreferencesReceived() { | 1994 | public void onServerPreferencesReceived() { |
| 1982 | // changeLocationSettings(true); | 1995 | // changeLocationSettings(true); |
| 1983 | - initBeaconsApplicationIfNeed(); | 1996 | +// initBeaconsApplicationIfNeed(); |
| 1984 | WarplyUserManager.rewriteTags(); | 1997 | WarplyUserManager.rewriteTags(); |
| 1985 | } | 1998 | } |
| 1986 | }; | 1999 | }; | ... | ... |
| ... | @@ -7,4 +7,6 @@ public interface WarplyReadyCallback { | ... | @@ -7,4 +7,6 @@ public interface WarplyReadyCallback { |
| 7 | void onWarplyInitTimeOut(); | 7 | void onWarplyInitTimeOut(); |
| 8 | 8 | ||
| 9 | void onWarplyPermissionsDenied(); | 9 | void onWarplyPermissionsDenied(); |
| 10 | + | ||
| 11 | + default void onWarplyInitialized() {}; | ||
| 10 | } | 12 | } | ... | ... |
| ... | @@ -16,6 +16,7 @@ import java.util.List; | ... | @@ -16,6 +16,7 @@ import java.util.List; |
| 16 | import java.util.Map; | 16 | import java.util.Map; |
| 17 | import java.util.concurrent.atomic.AtomicBoolean; | 17 | import java.util.concurrent.atomic.AtomicBoolean; |
| 18 | 18 | ||
| 19 | +import ly.warp.sdk.Warply; | ||
| 19 | import ly.warp.sdk.dexter.listener.DexterError; | 20 | import ly.warp.sdk.dexter.listener.DexterError; |
| 20 | import ly.warp.sdk.dexter.listener.PermissionDeniedResponse; | 21 | import ly.warp.sdk.dexter.listener.PermissionDeniedResponse; |
| 21 | import ly.warp.sdk.io.callbacks.WarplyReadyCallback; | 22 | import ly.warp.sdk.io.callbacks.WarplyReadyCallback; |
| ... | @@ -65,6 +66,24 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ | ... | @@ -65,6 +66,24 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ |
| 65 | stopThreadLock.set(true); | 66 | stopThreadLock.set(true); |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 69 | + public WarplyInitializer(Context context, boolean isInternal, WarplyReadyCallback readyCallback, WarplyInitCallback initCallback) { | ||
| 70 | + | ||
| 71 | +// this.mPermissionsResultRequested = false; | ||
| 72 | + this.mContext = context; | ||
| 73 | + this.mReadyCallback = readyCallback; | ||
| 74 | + this.mInitCallback = initCallback; | ||
| 75 | + | ||
| 76 | + if (mMainThreadHandler == null) { | ||
| 77 | + mMainThreadHandler = new Handler(Looper.getMainLooper()); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + if (stopThreadLock == null) { | ||
| 81 | + stopThreadLock = new AtomicBoolean(true); | ||
| 82 | + } | ||
| 83 | + stopThreadLock.set(true); | ||
| 84 | + init(); | ||
| 85 | + } | ||
| 86 | + | ||
| 68 | // =========================================================== | 87 | // =========================================================== |
| 69 | // Methods for/from SuperClass/Interfaces | 88 | // Methods for/from SuperClass/Interfaces |
| 70 | // =========================================================== | 89 | // =========================================================== |
| ... | @@ -159,16 +178,40 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ | ... | @@ -159,16 +178,40 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ |
| 159 | // =========================================================== | 178 | // =========================================================== |
| 160 | 179 | ||
| 161 | public synchronized void init() { | 180 | public synchronized void init() { |
| 162 | - | ||
| 163 | stopThreadLock.set(true); | 181 | stopThreadLock.set(true); |
| 164 | - mInitCallback.onInit(mContext); | 182 | + |
| 165 | - try { | 183 | + /* New code */ |
| 166 | - super.start(); // call run() | 184 | + if (Warply.INSTANCE.mContext != null) { |
| 167 | - } catch (IllegalThreadStateException e) { | 185 | + if (mReadyCallback != null) { |
| 168 | - if (WarpConstants.DEBUG) { | 186 | + mMainThreadHandler.post(new Runnable() { |
| 169 | - e.printStackTrace(); | 187 | + @Override |
| 188 | + public void run() { | ||
| 189 | + mReadyCallback.onWarplyInitialized(); | ||
| 190 | + } | ||
| 191 | + }); | ||
| 192 | + } | ||
| 193 | + } else { | ||
| 194 | + mInitCallback.onInit(mContext); | ||
| 195 | + try { | ||
| 196 | + super.start(); // call run() | ||
| 197 | + } catch (IllegalThreadStateException e) { | ||
| 198 | + if (WarpConstants.DEBUG) { | ||
| 199 | + e.printStackTrace(); | ||
| 200 | + } | ||
| 170 | } | 201 | } |
| 171 | } | 202 | } |
| 203 | + /* New code */ | ||
| 204 | + | ||
| 205 | + /* Old code */ | ||
| 206 | +// mInitCallback.onInit(mContext); | ||
| 207 | +// try { | ||
| 208 | +// super.start(); // call run() | ||
| 209 | +// } catch (IllegalThreadStateException e) { | ||
| 210 | +// if (WarpConstants.DEBUG) { | ||
| 211 | +// e.printStackTrace(); | ||
| 212 | +// } | ||
| 213 | +// } | ||
| 214 | + /* Old code */ | ||
| 172 | } | 215 | } |
| 173 | 216 | ||
| 174 | public synchronized void initWithPermissions(Activity activity) { | 217 | public synchronized void initWithPermissions(Activity activity) { | ... | ... |
-
Please register or login to post a comment