/** * Authenticates this client as belonging to your application. * This must be called before your * application can use the Parse library. The recommended way is to put a call to * {@code Parse.initialize} in your {@code Application}'s {@code onCreate} method: * <p/> * <pre> * public class MyApplication extends Application { * public void onCreate() { * Parse.initialize(configuration); * } * } * </pre> * * @param configuration The configuration for your application. */ public static void initialize(Configuration configuration) { initialize(configuration, null); }
private static Context getContext() { return Parse.getApplicationContext(); }
@After public void tearDown() { Parse.disableLocalDatastore(); }
Parse.requirePermission(Manifest.permission.ACCESS_NETWORK_STATE); TaskCompletionSource<JSONObject> tcs = new TaskCompletionSource<>(); byte[] json; json = jsonObject.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { if (Parse.LOG_LEVEL_WARNING >= Parse.getLogLevel()) { log.log(Level.WARNING, "UTF-8 isn't supported. This shouldn't happen.", e); if (Parse.LOG_LEVEL_WARNING >= Parse.getLogLevel()) { log.warning("Unable to save command for later because it's too big."); if (size > maxCacheSizeBytes) { if (preferOldest) { if (Parse.LOG_LEVEL_WARNING >= Parse.getLogLevel()) { log.warning("Unable to save command for later because storage is full."); if (Parse.LOG_LEVEL_WARNING >= Parse.getLogLevel()) { log.warning("Deleting old commands to make room in command cache."); if (Parse.LOG_LEVEL_WARNING >= Parse.getLogLevel()) { log.log(Level.WARNING, "Unable to save command for later.", e);
@Override public void onCreate() { super.onCreate(); // Required - Initialize the Parse SDK Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ParseFacebookUtils.initialize(this); // Optional - If you don't want to allow Twitter login, you can // remove this line (and other related ParseTwitterUtils calls) ParseTwitterUtils.initialize(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); } }
@Override public void onCreate() { super.onCreate(); // Enable Local Datastore. Parse.enableLocalDatastore(this); // Add your initialization code here Parse.initialize(new Parse.Configuration.Builder(getApplicationContext()) .applicationId("aghr56hFHJTefFGG65") .clientKey(null) .server("http://uberclone5599.herokuapp.com/parse/") .build() ); //enable our AutomaticUser ParseUser.enableAutomaticUser(); ParseACL defaultACL = new ParseACL(); // Optionally enable public read access. // defaultACL.setPublicReadAccess(true); ParseACL.setDefaultACL(defaultACL, true); } }
@Test public void testGetAsyncFromLDS() throws Exception { Parse.enableLocalDatastore(null); ParseUser user = mock(ParseUser.class); ParseQueryController queryController = mock(ParseQueryController.class); //noinspection unchecked when(queryController.findAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)) ).thenReturn(Task.forResult(Collections.singletonList(user))); ParseCorePlugins.getInstance().registerQueryController(queryController); OfflineObjectStore<ParseUser> store = new OfflineObjectStore<>(ParseUser.class, PIN_NAME, null); ParseUser userAgain = ParseTaskUtils.wait(store.getAsync()); //noinspection unchecked verify(queryController, times(1)) .findAsync(any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)); assertSame(user, userAgain); }
when(plugins.restClient()) .thenReturn(restClient); Parse.initialize(configuration, plugins); Parse.destroy(); Parse.initialize(configuration, plugins);
@Test public void testGetAsyncFromLDSWithTooManyObjects() throws Exception { Parse.enableLocalDatastore(null); ParseQueryController queryController = mock(ParseQueryController.class); //noinspection unchecked when(queryController.findAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)) ).thenReturn(Task.forResult(Arrays.asList(mock(ParseUser.class), mock(ParseUser.class)))); ParseCorePlugins.getInstance().registerQueryController(queryController); OfflineStore lds = mock(OfflineStore.class); when(lds.unpinAllObjectsAsync(anyString())).thenReturn(Task.<Void>forResult(null)); Parse.setLocalDatastore(lds); @SuppressWarnings("unchecked") ParseObjectStore<ParseUser> legacy = mock(ParseObjectStore.class); when(legacy.getAsync()).thenReturn(Task.<ParseUser>forResult(null)); OfflineObjectStore<ParseUser> store = new OfflineObjectStore<>(ParseUser.class, PIN_NAME, legacy); ParseUser user = ParseTaskUtils.wait(store.getAsync()); //noinspection unchecked verify(queryController, times(1)) .findAsync(any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)); verify(lds, times(1)).unpinAllObjectsAsync(PIN_NAME); assertNull(user); }
if (Parse.LOG_LEVEL_INFO >= Parse.getLogLevel()) { log.info("Parse command cache has started processing queued commands."); if (Parse.LOG_LEVEL_ERROR >= Parse.getLogLevel()) { log.log(Level.SEVERE, "saveEventually thread had an error.", e); runningLock.notifyAll(); if (Parse.LOG_LEVEL_INFO >= Parse.getLogLevel()) { log.info("saveEventually thread has stopped processing commands.");
@Override public void onCreate() { super.onCreate(); // Required - Initialize the Parse SDK Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ParseFacebookUtils.initialize(this); // Optional - If you don't want to allow Twitter login, you can // remove this line (and other related ParseTwitterUtils calls) ParseTwitterUtils.initialize(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); } }
super.onCreate(); Parse.enableLocalDatastore(this); Parse.initialize(this, PARSE_APPLICATION_ID, PARSE_CLIENT_KEY);
@Test public void testExistsAsyncLDS() throws Exception { Parse.enableLocalDatastore(null); ParseQueryController queryController = mock(ParseQueryController.class); //noinspection unchecked when(queryController.countAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)) ).thenReturn(Task.forResult(1)); ParseCorePlugins.getInstance().registerQueryController(queryController); OfflineObjectStore<ParseUser> store = new OfflineObjectStore<>(ParseUser.class, PIN_NAME, null); assertTrue(ParseTaskUtils.wait(store.existsAsync())); //noinspection unchecked verify(queryController, times(1)).countAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)); }
@Test public void testGetAsyncMigrate() throws Exception { Parse.enableLocalDatastore(null); ParseQueryController queryController = mock(ParseQueryController.class); when(lds.pinAllObjectsAsync(anyString(), anyList(), anyBoolean())) .thenReturn(Task.<Void>forResult(null)); Parse.setLocalDatastore(lds);
} catch (FileNotFoundException e) { if (Parse.LOG_LEVEL_ERROR >= Parse.getLogLevel()) { log.log(Level.SEVERE, "File disappeared from cache while being read.", e); if (Parse.LOG_LEVEL_ERROR >= Parse.getLogLevel()) { log.log(Level.SEVERE, "Unable to read contents of file in cache.", e); continue; } catch (JSONException e) { if (Parse.LOG_LEVEL_ERROR >= Parse.getLogLevel()) { log.log(Level.SEVERE, "Error parsing JSON found in cache.", e); command = commandFromJSON(json); } catch (JSONException e) { if (Parse.LOG_LEVEL_ERROR >= Parse.getLogLevel()) { log.log(Level.SEVERE, "Unable to create ParseCommand from JSON.", e); if (Parse.LOG_LEVEL_INFO >= Parse.getLogLevel()) { log.info("Network timeout in command cache. Waiting for " + timeoutRetryWaitSeconds + " seconds and then retrying " + retriesRemaining + " times."); if (Parse.LOG_LEVEL_INFO >= Parse.getLogLevel()) { log.info("Aborting wait because runEventually thread should stop."); if (Parse.LOG_LEVEL_ERROR >= Parse.getLogLevel()) { log.log(Level.SEVERE, "Failed to run command.", e);
@Override public void onCreate() { super.onCreate(); // Required - Initialize the Parse SDK Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ParseFacebookUtils.initialize(this); // Optional - If you don't want to allow Twitter login, you can // remove this line (and other related ParseTwitterUtils calls) ParseTwitterUtils.initialize(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); } }
@Override public void onCreate() { super.onCreate(); Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); } }
@Test public void testExistsAsyncLegacy() throws Exception { Parse.enableLocalDatastore(null); ParseQueryController queryController = mock(ParseQueryController.class); //noinspection unchecked when(queryController.countAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)) ).thenReturn(Task.forResult(0)); ParseCorePlugins.getInstance().registerQueryController(queryController); @SuppressWarnings("unchecked") ParseObjectStore<ParseUser> legacy = mock(ParseObjectStore.class); when(legacy.existsAsync()).thenReturn(Task.forResult(true)); OfflineObjectStore<ParseUser> store = new OfflineObjectStore<>(ParseUser.class, PIN_NAME, legacy); assertTrue(ParseTaskUtils.wait(store.existsAsync())); //noinspection unchecked verify(queryController, times(1)).countAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)); }
static boolean hasPermission(String permission) { return (getApplicationContext().checkCallingOrSelfPermission(permission) == PackageManager.PERMISSION_GRANTED); }
private void debugLog(String message) { if (Parse.getLogLevel() <= Parse.LOG_LEVEL_DEBUG && Log.isLoggable(LOG_TAG, Log.DEBUG)) { Log.d(LOG_TAG, message); } } }