コード例 #1
0
 /**
  * Ensures the model is in a consistent state which is the activities for the current intent have
  * been loaded, the most recent history has been read, and the activities are sorted.
  */
 private void ensureConsistentState() {
   boolean stateChanged = loadActivitiesIfNeeded();
   stateChanged |= readHistoricalDataIfNeeded();
   pruneExcessiveHistoricalRecordsIfNeeded();
   if (stateChanged) {
     sortActivitiesIfNeeded();
     notifyChanged();
   }
 }
コード例 #2
0
 /**
  * Adds a historical record.
  *
  * @param historicalRecord The record to add.
  * @return True if the record was added.
  */
 private boolean addHistoricalRecord(HistoricalRecord historicalRecord) {
   final boolean added = mHistoricalRecords.add(historicalRecord);
   if (added) {
     mHistoricalRecordsChanged = true;
     pruneExcessiveHistoricalRecordsIfNeeded();
     persistHistoricalDataIfNeeded();
     sortActivitiesIfNeeded();
     notifyChanged();
   }
   return added;
 }
コード例 #3
0
 /**
  * Sets the maximal size of the historical data. Defaults to {@link #DEFAULT_HISTORY_MAX_LENGTH}
  *
  * <p><strong>Note:</strong> Setting this property will immediately enforce the specified max
  * history size by dropping enough old historical records to enforce the desired size. Thus, any
  * records that exceed the history size will be discarded and irreversibly lost.
  *
  * @param historyMaxSize The max history size.
  */
 public void setHistoryMaxSize(int historyMaxSize) {
   synchronized (mInstanceLock) {
     if (mHistoryMaxSize == historyMaxSize) {
       return;
     }
     mHistoryMaxSize = historyMaxSize;
     pruneExcessiveHistoricalRecordsIfNeeded();
     if (sortActivitiesIfNeeded()) {
       notifyChanged();
     }
   }
 }
コード例 #4
0
  /**
   * Removes all historical records for this pkg.
   *
   * @param historicalRecord The pkg to delete records for.
   * @return True if the record was added.
   */
  boolean removeHistoricalRecordsForPackage(final String pkg) {
    boolean removed = false;

    for (Iterator<HistoricalRecord> i = mHistoricalRecords.iterator(); i.hasNext(); ) {
      final HistoricalRecord record = i.next();
      if (record.activity.getPackageName().equals(pkg)) {
        i.remove();
        removed = true;
      }
    }

    if (removed) {
      mHistoricalRecordsChanged = true;
      pruneExcessiveHistoricalRecordsIfNeeded();
      persistHistoricalDataIfNeeded();
      sortActivitiesIfNeeded();
      notifyChanged();
    }

    return removed;
  }