Exemplo n.º 1
0
    private boolean isPushNotificationPingNeeded() {
      if (mLastPingDate == null) {
        // first startup
        return false;
      }

      Date now = new Date();
      if (DateTimeUtils.secondsBetween(now, mLastPingDate) >= DEFAULT_TIMEOUT) {
        mLastPingDate = now;
        return true;
      }
      return false;
    }
Exemplo n.º 2
0
    @Override
    public void onTrimMemory(final int level) {
      if (level == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
        // We're in the Background
        mIsInBackground = true;
        String lastActivityString = AppPrefs.getLastActivityStr();
        ActivityId lastActivity = ActivityId.getActivityIdFromName(lastActivityString);
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("last_visible_screen", lastActivity.toString());
        if (mApplicationOpenedDate != null) {
          Date now = new Date();
          properties.put("time_in_app", DateTimeUtils.secondsBetween(now, mApplicationOpenedDate));
          mApplicationOpenedDate = null;
        }
        AnalyticsTracker.track(AnalyticsTracker.Stat.APPLICATION_CLOSED, properties);
        AnalyticsTracker.endSession(false);
        onAppGoesToBackground();
      } else {
        mIsInBackground = false;
      }

      boolean evictBitmaps = false;
      switch (level) {
        case TRIM_MEMORY_COMPLETE:
        case TRIM_MEMORY_MODERATE:
        case TRIM_MEMORY_RUNNING_MODERATE:
        case TRIM_MEMORY_RUNNING_CRITICAL:
        case TRIM_MEMORY_RUNNING_LOW:
          evictBitmaps = true;
          break;
        default:
          break;
      }

      if (evictBitmaps && mBitmapCache != null) {
        mBitmapCache.evictAll();
      }
    }