Java 类com.parse.ConfigCallback 实例源码

项目:AnyWall    文件:ConfigHelper.java   
public void fetchConfigIfNeeded() {
  final long configRefreshInterval = 60 * 60; // 1 hour

  if (config == null ||
      System.currentTimeMillis() - configLastFetchedTime > configRefreshInterval) {
    // Set the config to current, just to load the cache
    config = ParseConfig.getCurrentConfig();

    // Set the current time, to flag that the operation started and prevent double fetch
    ParseConfig.getInBackground(new ConfigCallback() {
      @Override
      public void done(ParseConfig parseConfig, ParseException e) {
        if (e == null) {
          // Yay, retrieved successfully
          config = parseConfig;
          configLastFetchedTime = System.currentTimeMillis();
        } else {
          // Fetch failed, reset the time
          configLastFetchedTime = 0;
        }
      }
    });
  }
}
项目:readingtracker    文件:ParseConfigHelper.java   
public static void refreshConfig() {
    long currentTime = System.currentTimeMillis();
    if (currentTime - lastFetchedTime > configRefreshInterval) {
        lastFetchedTime = currentTime;
        ParseConfig.getInBackground(new ConfigCallback() {
            @Override
            public void done(ParseConfig config, ParseException e) {
                if (e == null) {
                    Log.d(TAG, "Fetched config from server.");
                } else {
                    Log.e(TAG, "Failed to fetch config from server. Using Cached Config.");
                }
                cachedConfig = ParseConfig.getCurrentConfig();
                Log.d(TAG,"Config is "+cachedConfig.toString());
           }
        });
    }
}
项目:Gazetti_Newspaper_Reader    文件:StarterApplication.java   
@Override
public void onCreate() {
    super.onCreate();

    Parse.enableLocalDatastore(this);
    Parse.initialize(this, Constants.getConstant(this, R.string.PARSE_APP_ID),
            Constants.getConstant(this, R.string.PARSE_CLIENT_KEY));

    Fabric.with(this, new Crashlytics());
    Crashlytics.getInstance().setDebugMode(false);

    Crashlytics.log(Log.INFO, StarterApplication.class.getName(), "Starting Application - " + System.currentTimeMillis());
    NewsCatFileUtil.getInstance(this);
    UserPrefUtil.getInstance(this);
    ParseConfig.getInBackground(new ConfigCallback() {
        @Override
        public void done(ParseConfig config, ParseException e) {
            ConfigService.getInstance();
            ConfigService.getInstance().setInstance(StarterApplication.this);
        }
    });
}