/** Handle an outstanding UI request. */ @Override protected void processUiRequest(ServiceUiRequest requestId, Object data) { LogUtils.logD("ActivityEngine processUiRequest:" + requestId); switch (requestId) { case UPDATE_STATUSES: // this is full sync or push, or "refresh" button requestStatusesFromServer(true); break; case FETCH_STATUSES: // "more" button requestStatusesFromServer(false); break; case FETCH_TIMELINES: // "more" button - we only need time lines enqueueRequest( ServiceUiRequest.FETCH_TIMELINES.ordinal(), ActivitiesState.FETCHING_OLDER_TIMELINE); newState(State.FETCH_OLDER_CALLLOG_FROM_NATIVE_DB); startCallLogSync(false); break; case UPDATE_PHONE_CALLS: // something on the NAB has changed newState(State.UPDATE_CALLOG_FROM_NATIVE); startCallLogSync(true); break; case UPDATE_SMS: newState(State.FETCH_SMS_FROM_NATIVE_DB); startFetchingSMS(); break; default: break; } }
/** * Function called when helper classes ends their work. Currently supported helpers are * FetchCallLogEvents and FetchSmsLogEvents * * @param status - ServiceStatus of completed operation. */ protected void onSyncHelperComplete(ServiceStatus status) { if (ServiceStatus.UPDATED_TIMELINES_FROM_NATIVE == status) { mTimelinesUpdated = true; } switch (mState) { case FETCH_STATUSES_FIRST_TIME: // 1st/full sync newState(State.FETCH_CALLOG_FIRST_TIME); startCallLogSync(true); break; case FETCH_OLDER_CALLLOG_FROM_NATIVE_DB: // button "more" newState(State.FETCH_SMS_FROM_NATIVE_DB); mActiveSyncHelper = new FetchSmsLogEvents(mContext, this, mDb, false); setTimeout(READ_TIMELINES_TIMEOUT_MILLS); break; case FETCH_CALLOG_FIRST_TIME: // 1st sync case UPDATE_CALLOG_FROM_NATIVE: // NAB changed. newState(State.FETCH_SMS_FROM_NATIVE_DB); mActiveSyncHelper = new FetchSmsLogEvents(mContext, this, mDb, true); setTimeout(READ_TIMELINES_TIMEOUT_MILLS); break; case FETCH_SMS_FROM_NATIVE_DB: dequeueRequest(ServiceUiRequest.FETCH_TIMELINES.ordinal()); case UPDATE_STATUSES: // activities sync is over mActiveSyncHelper = null; newState(State.IDLE); completeUiRequest(status, null); break; default: // Do nothing. completeUiRequest(status, null); break; } }