本文整理汇总了Java中org.matrix.androidsdk.rest.callback.ApiCallback类的典型用法代码示例。如果您正苦于以下问题:Java ApiCallback类的具体用法?Java ApiCallback怎么用?Java ApiCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ApiCallback类属于org.matrix.androidsdk.rest.callback包,在下文中一共展示了ApiCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveRoomInfo
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
private void saveRoomInfo() {
// Save things
RoomState roomState = mRoom.getLiveState();
String nameFromForm = mEditTextName.getText().toString();
String topicFromForm = mEditTextTopic.getText().toString();
String canonicalFromForm = mEditTextCanonical.getText().toString();
ApiCallback<Void> changeCallback = UIUtils.buildOnChangeCallback(null);
if (UIUtils.hasFieldChanged(roomState.name, nameFromForm)) {
mRoom.updateName(nameFromForm, changeCallback);
}
if (UIUtils.hasFieldChanged(roomState.topic, topicFromForm)) {
mRoom.updateTopic(topicFromForm, changeCallback);
}
if (UIUtils.hasFieldChanged(roomState.alias, canonicalFromForm)) {
mRoom.updateCanonicalAlias(canonicalFromForm, changeCallback);
}
}
示例2: clearSessions
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Internal routine to clear the sessions data
*
* @param context the context
* @param iterator the sessions iterator
* @param clearCredentials true to clear the credentials.
* @param callback the asynchronous callback
*/
private synchronized void clearSessions(final Context context, final Iterator<MXSession> iterator, final boolean clearCredentials, final ApiCallback<Void> callback) {
if (!iterator.hasNext()) {
if (null != callback) {
callback.onSuccess(null);
}
return;
}
clearSession(context, iterator.next(), clearCredentials, new SimpleApiCallback<Void>() {
@Override
public void onSuccess(Void info) {
clearSessions(context, iterator, clearCredentials, callback);
}
});
}
示例3: startPublicRoomsSearch
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Start a new public rooms search
*
* @param server set the server in which searches, null if any
* @param thirdPartyInstanceId the third party instance id (optional)
* @param includeAllNetworks true to search in all the connected network
* @param pattern the pattern to search
* @param callback the asynchronous callback
*/
public void startPublicRoomsSearch(final String server, final String thirdPartyInstanceId, final boolean includeAllNetworks, final String pattern, final ApiCallback<List<PublicRoom>> callback) {
Log.d(LOG_TAG, "## startPublicRoomsSearch() " + " : server " + server + " pattern " + pattern);
// on android, a request cannot be cancelled
// so define a key to detect if the request makes senses
mRequestKey = "startPublicRoomsSearch" + System.currentTimeMillis();
// init the parameters
mRequestServer = server;
mThirdPartyInstanceId = thirdPartyInstanceId;
mIncludeAllNetworks = includeAllNetworks;
mSearchedPattern = pattern;
mForwardPaginationToken = null;
launchPublicRoomsRequest(callback);
}
示例4: forwardPaginate
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Forward paginate the public rooms search.
*
* @param callback the asynchronous callback
* @return true if the pagination starts
*/
public boolean forwardPaginate(final ApiCallback<List<PublicRoom>> callback) {
Log.d(LOG_TAG, "## forwardPaginate() " + " : server " + mRequestServer + " pattern " + mSearchedPattern + " mForwardPaginationToken " + mForwardPaginationToken);
if (isRequestInProgress()) {
Log.d(LOG_TAG, "## forwardPaginate() : a request is already in progress");
return false;
}
if (TextUtils.isEmpty(mForwardPaginationToken)) {
Log.d(LOG_TAG, "## forwardPaginate() : there is no forward token");
return false;
}
// on android, a request cannot be cancelled
// so define a key to detect if the request makes senses
mRequestKey = "forwardPaginate" + System.currentTimeMillis();
launchPublicRoomsRequest(callback);
return true;
}
示例5: closeWidget
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Close a widget
*
* @param session the session
* @param room the room
* @param widgetId the widget id
* @param callback the asynchronous callback
*/
public void closeWidget(MXSession session, Room room, String widgetId, final ApiCallback<Void> callback) {
// sanity checks
if ((null != session) && (null != room) && (null != widgetId)) {
WidgetError permissionError = checkWidgetPermission(session, room);
if (null != permissionError) {
if (null != callback) {
callback.onMatrixError(permissionError);
}
return;
}
// Send a state event with the widget data
// TODO: This API will be shortly replaced by a pure scalar API
session.getRoomsApiClient().sendStateEvent(room.getRoomId(), WIDGET_EVENT_TYPE, widgetId, new HashMap<String, Object>(), callback);
}
}
示例6: getEventFromRoomIdEventId
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Retrieve an event from its room id / event id.
*
* @param roomId the room id
* @param eventId the event id
* @param callback the asynchronous callback.
*/
private void getEventFromRoomIdEventId(final String roomId, final String eventId, final ApiCallback<Event> callback) {
final String description = "getEventFromRoomIdEventId : roomId " + roomId + " eventId " + eventId;
try {
mApi.getEvent(roomId, eventId , new RestAdapterCallback<Event>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
getEventFromRoomIdEventId(roomId, eventId, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例7: sendStateEvent
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Send a state events.
*
* @param roomId the dedicated room id
* @param eventType the event type
* @param stateKey the state key
* @param params the put parameters
* @param callback the asynchronous callback
*/
public void sendStateEvent(final String roomId, final String eventType, @Nullable final String stateKey, final Map<String, Object> params, final ApiCallback<Void> callback) {
final String description = "sendStateEvent : roomId " + roomId + " - eventType " + eventType;
try {
if (null != stateKey) {
mApi.sendStateEvent(roomId, eventType, stateKey, params, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
sendStateEvent(roomId, eventType, stateKey, params, callback);
}
}));
} else {
mApi.sendStateEvent(roomId, eventType, params, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
sendStateEvent(roomId, eventType, null, params, callback);
}
}));
}
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例8: createDirectMessageRoom
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Create a direct message room with one participant.<br>
* The participant can be a user ID or mail address. Once the room is created, on success, the room
* is set as a "direct message" with the participant.
*
* @param aParticipantUserId user ID (or user mail) to be invited in the direct message room
* @param algorithm the crypto algorithm (null to create an unencrypted room)
* @param aCreateRoomCallBack async call back response
* @return true if the invite was performed, false otherwise
*/
public boolean createDirectMessageRoom(final String aParticipantUserId, final String algorithm, final ApiCallback<String> aCreateRoomCallBack) {
boolean retCode = false;
if (!TextUtils.isEmpty(aParticipantUserId)) {
retCode = true;
CreateRoomParams params = new CreateRoomParams();
params.addCryptoAlgorithm(algorithm);
params.setDirectMessage();
params.addParticipantIds(mHsConfig, Arrays.asList(aParticipantUserId));
createRoom(params, aCreateRoomCallBack);
}
return retCode;
}
示例9: markRoomsAsRead
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Send the read receipts to the latest room messages.
*
* @param rooms the rooms list
* @param callback the asynchronous callback
*/
public void markRoomsAsRead(final Collection<Room> rooms, final ApiCallback<Void> callback) {
if ((null == rooms) || (0 == rooms.size())) {
if (null != callback) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
callback.onSuccess(null);
}
});
}
return;
}
markRoomsAsRead(rooms.iterator(), callback);
}
示例10: sendToDevice
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Send an event to a specific list of devices
*
* @param eventType the type of event to send
* @param contentMap content to send. Map from user_id to device_id to content dictionary.
* @param transactionId the transactionId
* @param callback the asynchronous callback.
*/
public void sendToDevice(final String eventType, final MXUsersDevicesMap<Map<String, Object>> contentMap, final String transactionId, final ApiCallback<Void> callback) {
final String description = "sendToDevice " + eventType;
HashMap<String, Object> content = new HashMap<>();
content.put("messages", contentMap.getMap());
try {
mApi.sendToDevice(eventType, transactionId, content, new RestAdapterCallback<Void>(description, null, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
sendToDevice(eventType, contentMap, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例11: uploadDeviceKeys
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Upload my user's device keys.
* This method must called on getEncryptingThreadHandler() thread.
* The callback will called on UI thread.
*
* @param callback the asynchronous callback
*/
private void uploadDeviceKeys(ApiCallback<KeysUploadResponse> callback) {
// Prepare the device keys data to send
// Sign it
String signature = mOlmDevice.signJSON(mMyDevice.signalableJSONDictionary());
HashMap<String, String> submap = new HashMap<>();
submap.put("ed25519:" + mMyDevice.deviceId, signature);
HashMap<String, Map<String, String>> map = new HashMap<>();
map.put(mSession.getMyUserId(), submap);
mMyDevice.signatures = map;
// For now, we set the device id explicitly, as we may not be using the
// same one as used in login.
mSession.getCryptoRestClient().uploadKeys(mMyDevice.JSONDictionary(), null, mMyDevice.deviceId, callback);
}
示例12: submitValidationToken
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Request the ownership validation of an email address or a phone number previously set
* by {@link ProfileRestClient#requestEmailValidationToken(String, String, int, String, boolean, ApiCallback)}
* @param medium the medium of the 3pid
* @param token the token generated by the requestEmailValidationToken call
* @param clientSecret the client secret which was supplied in the requestEmailValidationToken call
* @param sid the sid for the session
* @param callback asynchronous callback response
*/
public void submitValidationToken(final String medium, final String token, final String clientSecret, final String sid, final ApiCallback<Boolean> callback) {
try {
mApi.requestOwnershipValidation(medium, token, clientSecret, sid, new Callback<Map<String, Object>>() {
@Override
public void success(Map<String, Object> aDataRespMap, Response response) {
if (aDataRespMap.containsKey(KEY_SUBMIT_TOKEN_SUCCESS)) {
callback.onSuccess((Boolean) aDataRespMap.get(KEY_SUBMIT_TOKEN_SUCCESS));
} else {
callback.onSuccess(false);
}
}
@Override
public void failure(RetrofitError error) {
callback.onUnexpectedError(error);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例13: forceDirectChatRoomValue
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* For the value account_data with the rooms list passed in aRoomIdsListToAdd for a given user ID (aParticipantUserId)<br>
* WARNING: this method must be used with care because it erases the account_data object.
*
* @param aRoomParticipantUserIdList the couple direct chat rooms ID / user IDs
* @param callback the asynchronous response callback
*/
private void forceDirectChatRoomValue(List<RoomIdsListRetroCompat> aRoomParticipantUserIdList, ApiCallback<Void> callback) {
Map<String, List<String>> params = new HashMap<>();
List<String> roomIdsList;
if (null != aRoomParticipantUserIdList) {
for (RoomIdsListRetroCompat item : aRoomParticipantUserIdList) {
if (params.containsKey(item.mParticipantUserId)) {
roomIdsList = new ArrayList<>(params.get(item.mParticipantUserId));
roomIdsList.add(item.mRoomId);
} else {
roomIdsList = new ArrayList<>();
roomIdsList.add(item.mRoomId);
}
params.put(item.mParticipantUserId, roomIdsList);
}
mAccountDataRestClient.setAccountData(getMyUserId(), AccountDataRestClient.ACCOUNT_DATA_TYPE_DIRECT_MESSAGES, params, callback);
}
}
示例14: updateCanonicalAlias
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Update the room name.
*
* @param roomId the room id
* @param canonicalAlias the canonical alias
* @param callback the async callback
*/
public void updateCanonicalAlias(final String roomId, final String canonicalAlias, final ApiCallback<Void> callback) {
final String description = "updateCanonicalAlias : roomId " + roomId + " canonicalAlias " + canonicalAlias;
RoomState roomState = new RoomState();
roomState.alias = canonicalAlias;
try {
mApi.setCanonicalAlias(roomId, roomState, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
updateCanonicalAlias(roomId, canonicalAlias, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例15: ignoreUsers
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入依赖的package包/类
/**
* Ignore a list of users.
*
* @param userIds the user ids list to ignore
* @param callback the result callback
*/
public void ignoreUsers(ArrayList<String> userIds, ApiCallback<Void> callback) {
List<String> curUserIdsToIgnore = getDataHandler().getIgnoredUserIds();
ArrayList<String> userIdsToIgnore = new ArrayList<>(getDataHandler().getIgnoredUserIds());
// something to add
if ((null != userIds) && (userIds.size() > 0)) {
// add the new one
for (String userId : userIds) {
if (userIdsToIgnore.indexOf(userId) < 0) {
userIdsToIgnore.add(userId);
}
}
// some items have been added
if (curUserIdsToIgnore.size() != userIdsToIgnore.size()) {
updateUsers(userIdsToIgnore, callback);
}
}
}