@Override public void onRetry() { getFilter(userId, filterId, callback); } }));
@Override public void onRetry() { uploadFilter(userId, filterBody, callback); } }));
mGroupsRestClient = new GroupsRestClient(hsConfig); mMediaScanRestClient = new MediaScanRestClient(hsConfig); mFilterRestClient = new FilterRestClient(hsConfig); mRoomKeysRestClient = new RoomKeysRestClient(hsConfig);
/** * Convert a filter to a filterId * Either it is already known to the server, or send the filter to the server to get a filterId */ private void convertFilterToFilterId() { // Ensure mCurrentFilter has not been updated in the same time final String wantedJsonFilter = mCurrentFilter.toJSONString(); // Check if the current filter is known by the server, to directly use the filterId String filterId = getDataHandler().getStore().getFilters().get(wantedJsonFilter); if (TextUtils.isEmpty(filterId)) { // enable the filter in JSON representation so do not block sync until the filter response is there mEventsThread.setFilterOrFilterId(wantedJsonFilter); // Send the filter to the server mFilterRestClient.uploadFilter(getMyUserId(), mCurrentFilter, new SimpleApiCallback<FilterResponse>() { @Override public void onSuccess(FilterResponse filter) { // Store the couple filter/filterId getDataHandler().getStore().addFilter(wantedJsonFilter, filter.filterId); // Ensure the filter is still corresponding to the current filter if (TextUtils.equals(wantedJsonFilter, mCurrentFilter.toJSONString())) { // Tell the event thread to use the id now mEventsThread.setFilterOrFilterId(filter.filterId); } } }); } else { // Tell the event thread to use the id now mEventsThread.setFilterOrFilterId(filterId); } }