Exemplo n.º 1
0
  /**
   * Gets the shared command cache object for all ParseObjects. This command cache is used to
   * locally store save commands created by the ParseObject.saveEventually(). When a new
   * ParseCommandCache is instantiated, it will begin running its run loop, which will start by
   * processing any commands already stored in the on-disk queue.
   */
  /* package */ static ParseEventuallyQueue getEventuallyQueue() {
    Context context = ParsePlugins.Android.get().applicationContext();
    synchronized (MUTEX) {
      boolean isLocalDatastoreEnabled = Parse.isLocalDatastoreEnabled();
      if (eventuallyQueue == null
          || (isLocalDatastoreEnabled && eventuallyQueue instanceof ParseCommandCache)
          || (!isLocalDatastoreEnabled && eventuallyQueue instanceof ParsePinningEventuallyQueue)) {
        checkContext();
        eventuallyQueue =
            isLocalDatastoreEnabled
                ? new ParsePinningEventuallyQueue(context)
                : new ParseCommandCache(context);

        // We still need to clear out the old command cache even if we're using Pinning in case
        // anything is left over when the user upgraded. Checking number of pending and then
        // initializing should be enough.
        if (isLocalDatastoreEnabled && ParseCommandCache.getPendingCount() > 0) {
          new ParseCommandCache(context);
        }
      }
      return eventuallyQueue;
    }
  }
Exemplo n.º 2
0
 static Context getApplicationContext() {
   checkContext();
   return ParsePlugins.Android.get().applicationContext();
 }