12
12
import android .content .pm .PackageManager ;
13
13
import android .content .pm .ResolveInfo ;
14
14
import android .util .Log ;
15
-
16
15
import androidx .annotation .NonNull ;
17
16
import androidx .annotation .Nullable ;
18
-
19
17
import com .parse .boltsinternal .Continuation ;
20
18
import com .parse .boltsinternal .Task ;
21
-
22
19
import java .io .File ;
23
20
import java .io .FileOutputStream ;
24
21
import java .io .IOException ;
29
26
import java .util .List ;
30
27
import java .util .Set ;
31
28
import java .util .concurrent .Callable ;
32
-
33
29
import okhttp3 .OkHttpClient ;
34
30
35
31
/**
@@ -79,8 +75,8 @@ private Parse() {
79
75
* }
80
76
* }
81
77
* </pre>
82
- * <p>
83
- * See <a
78
+ *
79
+ * <p> See <a
84
80
* href="https://github.com/parse-community/Parse-SDK-Android/issues/279">https://github.com/parse-community/Parse-SDK-Android/issues/279</a>
85
81
* for a discussion on performance of local datastore, and if it is right for your project.
86
82
*
@@ -89,8 +85,8 @@ private Parse() {
89
85
public static void enableLocalDatastore (Context context ) {
90
86
if (isInitialized ()) {
91
87
throw new IllegalStateException (
92
- "`Parse#enableLocalDatastore(Context)` must be invoked "
93
- + "before `Parse#initialize(Context)`" );
88
+ "`Parse#enableLocalDatastore(Context)` must be invoked "
89
+ + "before `Parse#initialize(Context)`" );
94
90
}
95
91
isLocalDatastoreEnabled = true ;
96
92
}
@@ -117,7 +113,7 @@ public static boolean isLocalDatastoreEnabled() {
117
113
118
114
/**
119
115
* @return {@code True} if {@link Configuration.Builder#allowCustomObjectId()} has been called,
120
- * otherwise {@code false}.
116
+ * otherwise {@code false}.
121
117
*/
122
118
public static boolean isAllowCustomObjectId () {
123
119
return allowCustomObjectId ;
@@ -183,32 +179,32 @@ static void initialize(Configuration configuration, ParsePlugins parsePlugins) {
183
179
checkCacheApplicationId ();
184
180
final Context context = configuration .context ;
185
181
Task .callInBackground (
186
- (Callable <Void >)
187
- () -> {
188
- getEventuallyQueue (context );
189
- return null ;
190
- });
182
+ (Callable <Void >)
183
+ () -> {
184
+ getEventuallyQueue (context );
185
+ return null ;
186
+ });
191
187
192
188
ParseFieldOperations .registerDefaultDecoders ();
193
189
194
190
if (!allParsePushIntentReceiversInternal ()) {
195
191
throw new SecurityException (
196
- "To prevent external tampering to your app's notifications, "
197
- + "all receivers registered to handle the following actions must have "
198
- + "their exported attributes set to false: com.parse.push.intent.RECEIVE, "
199
- + "com.parse.push.intent.OPEN, com.parse.push.intent.DELETE" );
192
+ "To prevent external tampering to your app's notifications, "
193
+ + "all receivers registered to handle the following actions must have "
194
+ + "their exported attributes set to false: com.parse.push.intent.RECEIVE, "
195
+ + "com.parse.push.intent.OPEN, com.parse.push.intent.DELETE" );
200
196
}
201
197
202
198
ParseUser .getCurrentUserAsync ()
203
- .makeVoid ()
204
- .continueWith (
205
- (Continuation <Void , Void >)
206
- task -> {
207
- // Prime config in the background
208
- ParseConfig .getCurrentConfig ();
209
- return null ;
210
- },
211
- Task .BACKGROUND_EXECUTOR );
199
+ .makeVoid ()
200
+ .continueWith (
201
+ (Continuation <Void , Void >)
202
+ task -> {
203
+ // Prime config in the background
204
+ ParseConfig .getCurrentConfig ();
205
+ return null ;
206
+ },
207
+ Task .BACKGROUND_EXECUTOR );
212
208
213
209
dispatchOnParseInitialized ();
214
210
@@ -220,11 +216,8 @@ static void initialize(Configuration configuration, ParsePlugins parsePlugins) {
220
216
221
217
// region Server URL
222
218
223
- /**
224
- * Returns the current server URL.
225
- */
226
- public static @ Nullable
227
- String getServer () {
219
+ /** Returns the current server URL. */
220
+ public static @ Nullable String getServer () {
228
221
URL server = ParseRESTCommand .server ;
229
222
return server == null ? null : server .toString ();
230
223
}
@@ -258,8 +251,7 @@ public static void setServer(@NonNull String server) {
258
251
* @param server The server URL to validate.
259
252
* @return The validated server URL.
260
253
*/
261
- private static @ Nullable
262
- String validateServerUrl (@ Nullable String server ) {
254
+ private static @ Nullable String validateServerUrl (@ Nullable String server ) {
263
255
264
256
// Add an extra trailing slash so that Parse REST commands include
265
257
// the path as part of the server URL (i.e. http://api.myhost.com/parse)
@@ -296,9 +288,7 @@ public static void destroy() {
296
288
allowCustomObjectId = false ;
297
289
}
298
290
299
- /**
300
- * @return {@code True} if {@link #initialize} has been called, otherwise {@code false}.
301
- */
291
+ /** @return {@code True} if {@link #initialize} has been called, otherwise {@code false}. */
302
292
static boolean isInitialized () {
303
293
return ParsePlugins .get () != null ;
304
294
}
@@ -321,10 +311,10 @@ public static Context getApplicationContext() {
321
311
*/
322
312
private static boolean allParsePushIntentReceiversInternal () {
323
313
List <ResolveInfo > intentReceivers =
324
- ManifestInfo .getIntentReceivers (
325
- ParsePushBroadcastReceiver .ACTION_PUSH_RECEIVE ,
326
- ParsePushBroadcastReceiver .ACTION_PUSH_DELETE ,
327
- ParsePushBroadcastReceiver .ACTION_PUSH_OPEN );
314
+ ManifestInfo .getIntentReceivers (
315
+ ParsePushBroadcastReceiver .ACTION_PUSH_RECEIVE ,
316
+ ParsePushBroadcastReceiver .ACTION_PUSH_DELETE ,
317
+ ParsePushBroadcastReceiver .ACTION_PUSH_OPEN );
328
318
329
319
for (ResolveInfo resolveInfo : intentReceivers ) {
330
320
if (resolveInfo .activityInfo .exported ) {
@@ -427,15 +417,15 @@ private static ParseEventuallyQueue getEventuallyQueue(Context context) {
427
417
synchronized (MUTEX ) {
428
418
boolean isLocalDatastoreEnabled = Parse .isLocalDatastoreEnabled ();
429
419
if (eventuallyQueue == null
430
- || (isLocalDatastoreEnabled && eventuallyQueue instanceof ParseCommandCache )
431
- || (!isLocalDatastoreEnabled
432
- && eventuallyQueue instanceof ParsePinningEventuallyQueue )) {
420
+ || (isLocalDatastoreEnabled && eventuallyQueue instanceof ParseCommandCache )
421
+ || (!isLocalDatastoreEnabled
422
+ && eventuallyQueue instanceof ParsePinningEventuallyQueue )) {
433
423
checkContext ();
434
424
ParseHttpClient httpClient = ParsePlugins .get ().restClient ();
435
425
eventuallyQueue =
436
- isLocalDatastoreEnabled
437
- ? new ParsePinningEventuallyQueue (context , httpClient )
438
- : new ParseCommandCache (context , httpClient );
426
+ isLocalDatastoreEnabled
427
+ ? new ParsePinningEventuallyQueue (context , httpClient )
428
+ : new ParseCommandCache (context , httpClient );
439
429
440
430
// We still need to clear out the old command cache even if we're using Pinning in
441
431
// case
@@ -449,35 +439,33 @@ private static ParseEventuallyQueue getEventuallyQueue(Context context) {
449
439
}
450
440
}
451
441
452
- /**
453
- * Used by Parse LiveQuery
454
- */
442
+ /** Used by Parse LiveQuery */
455
443
public static void checkInit () {
456
444
if (ParsePlugins .get () == null ) {
457
445
throw new RuntimeException (
458
- "You must call Parse.initialize(Context)" + " before using the Parse library." );
446
+ "You must call Parse.initialize(Context)" + " before using the Parse library." );
459
447
}
460
448
461
449
if (ParsePlugins .get ().applicationId () == null ) {
462
450
throw new RuntimeException (
463
- "applicationId is null. "
464
- + "You must call Parse.initialize(Context)"
465
- + " before using the Parse library." );
451
+ "applicationId is null. "
452
+ + "You must call Parse.initialize(Context)"
453
+ + " before using the Parse library." );
466
454
}
467
455
}
468
456
469
457
static void checkContext () {
470
458
if (ParsePlugins .get ().applicationContext () == null ) {
471
459
throw new RuntimeException (
472
- "applicationContext is null. "
473
- + "You must call Parse.initialize(Context)"
474
- + " before using the Parse library." );
460
+ "applicationContext is null. "
461
+ + "You must call Parse.initialize(Context)"
462
+ + " before using the Parse library." );
475
463
}
476
464
}
477
465
478
466
static boolean hasPermission (String permission ) {
479
467
return (getApplicationContext ().checkCallingOrSelfPermission (permission )
480
- == PackageManager .PERMISSION_GRANTED );
468
+ == PackageManager .PERMISSION_GRANTED );
481
469
}
482
470
483
471
// endregion
@@ -487,10 +475,10 @@ static boolean hasPermission(String permission) {
487
475
static void requirePermission (String permission ) {
488
476
if (!hasPermission (permission )) {
489
477
throw new IllegalStateException (
490
- "To use this functionality, add this to your AndroidManifest.xml:\n "
491
- + "<uses-permission android:name=\" "
492
- + permission
493
- + "\" />" );
478
+ "To use this functionality, add this to your AndroidManifest.xml:\n "
479
+ + "<uses-permission android:name=\" "
480
+ + permission
481
+ + "\" />" );
494
482
}
495
483
}
496
484
@@ -504,7 +492,7 @@ static void requirePermission(String permission) {
504
492
static void registerParseCallbacks (ParseCallbacks listener ) {
505
493
if (isInitialized ()) {
506
494
throw new IllegalStateException (
507
- "You must register callbacks before Parse.initialize(Context)" );
495
+ "You must register callbacks before Parse.initialize(Context)" );
508
496
}
509
497
510
498
synchronized (MUTEX_CALLBACKS ) {
@@ -552,9 +540,7 @@ private static ParseCallbacks[] collectParseCallbacks() {
552
540
return callbacks ;
553
541
}
554
542
555
- /**
556
- * Returns the level of logging that will be displayed.
557
- */
543
+ /** Returns the level of logging that will be displayed. */
558
544
public static int getLogLevel () {
559
545
return PLog .getLogLevel ();
560
546
}
@@ -586,9 +572,7 @@ interface ParseCallbacks {
586
572
void onParseInitialized ();
587
573
}
588
574
589
- /**
590
- * Represents an opaque configuration for the {@code Parse} SDK configuration.
591
- */
575
+ /** Represents an opaque configuration for the {@code Parse} SDK configuration. */
592
576
public static final class Configuration {
593
577
final Context context ;
594
578
final String applicationId ;
@@ -610,9 +594,7 @@ private Configuration(Builder builder) {
610
594
this .maxRetries = builder .maxRetries ;
611
595
}
612
596
613
- /**
614
- * Allows for simple constructing of a {@code Configuration} object.
615
- */
597
+ /** Allows for simple constructing of a {@code Configuration} object. */
616
598
public static final class Builder {
617
599
private final Context context ;
618
600
private String applicationId ;
0 commit comments