Showing
4 changed files
with
67 additions
and
9 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,8 +178,19 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ | ... | @@ -159,8 +178,19 @@ 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); |
182 | + | ||
183 | + /* New code */ | ||
184 | + if (Warply.INSTANCE.mContext != null) { | ||
185 | + if (mReadyCallback != null) { | ||
186 | + mMainThreadHandler.post(new Runnable() { | ||
187 | + @Override | ||
188 | + public void run() { | ||
189 | + mReadyCallback.onWarplyInitialized(); | ||
190 | + } | ||
191 | + }); | ||
192 | + } | ||
193 | + } else { | ||
164 | mInitCallback.onInit(mContext); | 194 | mInitCallback.onInit(mContext); |
165 | try { | 195 | try { |
166 | super.start(); // call run() | 196 | super.start(); // call run() |
... | @@ -170,6 +200,19 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ | ... | @@ -170,6 +200,19 @@ public class WarplyInitializer extends Thread /*implements ActivityCompat.OnRequ |
170 | } | 200 | } |
171 | } | 201 | } |
172 | } | 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 */ | ||
215 | + } | ||
173 | 216 | ||
174 | public synchronized void initWithPermissions(Activity activity) { | 217 | public synchronized void initWithPermissions(Activity activity) { |
175 | mContext = activity; | 218 | mContext = activity; | ... | ... |
-
Please register or login to post a comment