/** * Persists the history data to the backing file if the latter * was provided. Calling this method before a call to {@link #readHistoricalData()} * throws an exception. Calling this method more than one without choosing an * activity has not effect. * * @throws IllegalStateException If this method is called before a call to * {@link #readHistoricalData()}. */ private void persistHistoricalData() { synchronized (mInstanceLock) { if (!mReadShareHistoryCalled) { throw new IllegalStateException("No preceding call to #readHistoricalData"); } if (!mHistoricalRecordsChanged) { return; } mHistoricalRecordsChanged = false; mCanReadHistoricalData = true; if (!TextUtils.isEmpty(mHistoryFileName)) { /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryPersister()); } } }
public void run() { try { r.run(); } finally { scheduleNext(); } } });
/** * Reads the history data from the backing file if the latter * was provided. Calling this method more than once before a call * to {@link #persistHistoricalData()} has been made has no effect. * <p> * <strong>Note:</strong> Historical data is read asynchronously and * as soon as the reading is completed any registered * {@link DataSetObserver}s will be notified. Also no historical * data is read until this method is invoked. * <p> */ private void readHistoricalData() { synchronized (mInstanceLock) { if (!mCanReadHistoricalData || !mHistoricalRecordsChanged) { return; } mCanReadHistoricalData = false; mReadShareHistoryCalled = true; if (!TextUtils.isEmpty(mHistoryFileName)) { /*AsyncTask.*/SERIAL_EXECUTOR.execute(new HistoryLoader()); } } }
public synchronized void execute(final Runnable r) { mTasks.offer(new Runnable() { public void run() { try { r.run(); } finally { scheduleNext(); } } }); if (mActive == null) { scheduleNext(); } }