本文整理汇总了Java中org.matrix.androidsdk.rest.callback.ApiCallback.onUnexpectedError方法的典型用法代码示例。如果您正苦于以下问题:Java ApiCallback.onUnexpectedError方法的具体用法?Java ApiCallback.onUnexpectedError怎么用?Java ApiCallback.onUnexpectedError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.matrix.androidsdk.rest.callback.ApiCallback
的用法示例。
在下文中一共展示了ApiCallback.onUnexpectedError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendEventToRoom
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Send an event to a room.
*
* @param transactionId the unique transaction id (it should avoid duplicated messages)
* @param roomId the room id
* @param eventType the type of event
* @param content the event content
* @param callback the callback containing the created event if successful
*/
public void sendEventToRoom(final String transactionId, final String roomId, final String eventType, final JsonObject content, final ApiCallback<Event> callback) {
// privacy
//final String description = "sendEvent : roomId " + roomId + " - eventType " + eventType + " content " + content;
final String description = "sendEvent : roomId " + roomId + " - eventType " + eventType;
try {
// do not retry the call invite
// it might trigger weird behaviour on flaggy networks
if (!TextUtils.equals(eventType, Event.EVENT_TYPE_CALL_INVITE)) {
mApi.send(transactionId, roomId, eventType, content, new RestAdapterCallback<Event>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
sendEventToRoom(transactionId, roomId, eventType, content, callback);
}
}));
} else {
mApi.send(transactionId, roomId, eventType, content, new RestAdapterCallback<Event>(description, mUnsentEventsManager, callback, null));
}
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例2: updateJoinRules
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Update the join rule of the room.
* To make the room private, the aJoinRule must be set to {@link RoomState#JOIN_RULE_INVITE}.
*
* @param aRoomId the room id
* @param aJoinRule the join rule: {@link RoomState#JOIN_RULE_PUBLIC} or {@link RoomState#JOIN_RULE_INVITE}
* @param callback the async callback response
*/
public void updateJoinRules(final String aRoomId, final String aJoinRule, final ApiCallback<Void> callback) {
final String description = "updateJoinRules : roomId=" + aRoomId + " rule=" + aJoinRule;
// build RoomState as input parameter
RoomState roomStateParam = new RoomState();
roomStateParam.join_rule = aJoinRule;
try {
mApi.setJoinRules(aRoomId, roomStateParam, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
updateJoinRules(aRoomId, aJoinRule, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例3: getSupportedLoginFlows
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Retrieve the login supported flows.
* It should be done to check before displaying a default login form.
*
* @param callback the callback success and failure callback
*/
public void getSupportedLoginFlows(final ApiCallback<List<LoginFlow>> callback) {
final String description = "geLoginSupportedFlows";
try {
mApi.login(new RestAdapterCallback<LoginFlowResponse>(description, mUnsentEventsManager, callback,
new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
getSupportedLoginFlows(callback);
}
}
) {
@Override
public void success(LoginFlowResponse loginFlowResponse, Response response) {
onEventSent();
callback.onSuccess(loginFlowResponse.flows);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例4: 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));
}
}
示例5: deleteRule
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Delete a rule.
*
* @param Kind the rule kind
* @param ruleId the rule id
* @param callback the asynchronous callback
*/
public void deleteRule(String Kind, String ruleId, final ApiCallback<Void> callback) {
try {
mApi.deleteRule(Kind, ruleId, new Callback<Void>() {
@Override
public void success(Void voidObject, Response response) {
callback.onSuccess(voidObject);
}
@Override
public void failure(RetrofitError error) {
callback.onUnexpectedError(error);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例6: getAllBingRules
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Retrieve the bing rules list.
*
* @param callback the asynchronous callback.
*/
public void getAllBingRules(final ApiCallback<BingRulesResponse> callback) {
try {
mApi.getAllBingRules(new Callback<BingRulesResponse>() {
@Override
public void success(BingRulesResponse bingRulesResponse, Response response) {
callback.onSuccess(bingRulesResponse);
}
@Override
public void failure(RetrofitError error) {
callback.onUnexpectedError(error);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例7: 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));
}
}
示例8: updateTopic
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Update the room topic.
*
* @param roomId the room id
* @param topic the room topic
* @param callback the async callback
*/
public void updateTopic(final String roomId, final String topic, final ApiCallback<Void> callback) {
final String description = "updateTopic : roomId " + roomId + " topic " + topic;
RoomState roomState = new RoomState();
roomState.topic = topic;
try {
mApi.setRoomTopic(roomId, roomState, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
updateTopic(roomId, topic, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例9: addTag
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Add a tag to a room.
* Use this method to update the order of an existing tag.
*
* @param roomId the roomId
* @param tag the new tag to add to the room.
* @param order the order.
* @param callback the operation callback
*/
public void addTag(final String roomId, final String tag, final Double order, final ApiCallback<Void> callback) {
final String description = "addTag : roomId " + roomId + " - tag " + tag + " - order " + order;
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("order", order);
try {
mApi.addTag(mCredentials.userId, roomId, tag, hashMap, new RestAdapterCallback<Void>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
addTag(roomId, tag, order, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例10: getTurnServer
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
public void getTurnServer(final ApiCallback<JsonObject> callback) {
try {
mApi.getTurnServer(new Callback<JsonObject>() {
@Override
public void success(JsonObject turnServer, Response response) {
callback.onSuccess(turnServer);
}
@Override
public void failure(RetrofitError error) {
callback.onUnexpectedError(error);
}
});
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例11: clearGCMData
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Clear the GCM data
*
* @param clearRegistrationToken true to clear the provided GCM token
* @param callback the asynchronous callback
*/
public void clearGCMData(final boolean clearRegistrationToken, final ApiCallback callback) {
try {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
setStoredRegistrationToken(null);
mRegistrationToken = null;
mRegistrationState = setStoredRegistrationState(RegistrationState.UNREGISTRATED);
if (clearRegistrationToken) {
GCMHelper.clearRegistrationToken();
}
return null;
}
@Override
protected void onPostExecute(Void nothing) {
if (null != callback) {
callback.onSuccess(null);
}
}
}.execute();
} catch (Exception e) {
Log.e(LOG_TAG, "## clearGCMData failed " + e.getMessage());
if (null != callback) {
callback.onUnexpectedError(e);
}
}
}
示例12: initialSync
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Perform an initial sync on the room
*
* @param roomId the room id
* @param callback the async callback
*/
public void initialSync(final String roomId, final ApiCallback<RoomResponse> callback) {
final String description = "initialSync : roomId " + roomId;
try {
mApi.initialSync(roomId, DEFAULT_MESSAGES_PAGINATION_LIMIT, new RestAdapterCallback<RoomResponse>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
initialSync(roomId, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例13: joinRoom
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Join a room by its roomAlias or its roomId with some parameters.
*
* @param roomIdOrAlias the room id or the room alias
* @param params the joining parameters.
* @param callback the async callback
*/
public void joinRoom(final String roomIdOrAlias, final HashMap<String, Object> params, final ApiCallback<RoomResponse> callback) {
final String description = "joinRoom : roomId " + roomIdOrAlias;
try {
mApi.joinRoomByAliasOrId(roomIdOrAlias, (null == params) ? new HashMap<String, Object>() : params, new RestAdapterCallback<RoomResponse>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
joinRoom(roomIdOrAlias, params, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例14: getRoomIdByAlias
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Get the room ID corresponding to this room alias.
*
* @param roomAlias the room alias.
* @param callback the operation callback
*/
public void getRoomIdByAlias(final String roomAlias, final ApiCallback<RoomAliasDescription> callback) {
final String description = "getRoomIdByAlias : " + roomAlias;
try {
mApi.getRoomIdByAlias(roomAlias, new RestAdapterCallback<RoomAliasDescription>(description, mUnsentEventsManager, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
getRoomIdByAlias(roomAlias, callback);
}
}));
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}
示例15: uploadKeys
import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
* Upload device and/or one-time keys.
*
* @param deviceKeys the device keys to send.
* @param oneTimeKeys the one-time keys to send.
* @param deviceId he explicit device_id to use for upload (default is to use the same as that used during auth).
* @param callback the asynchronous callback
*/
public void uploadKeys(final Map<String, Object> deviceKeys, final Map<String, Object> oneTimeKeys, final String deviceId, final ApiCallback<KeysUploadResponse> callback) {
final String description = "uploadKeys";
String encodedDeviceId = JsonUtils.convertToUTF8(deviceId);
HashMap<String, Object> params = new HashMap<>();
if (null != deviceKeys) {
params.put("device_keys", deviceKeys);
}
if (null != oneTimeKeys) {
params.put("one_time_keys", oneTimeKeys);
}
try {
if (!TextUtils.isEmpty(encodedDeviceId)) {
mApi.uploadKeys(encodedDeviceId, params, new RestAdapterCallback<KeysUploadResponse>(description, null, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
uploadKeys(deviceKeys, oneTimeKeys, deviceId, callback);
}
}));
} else {
mApi.uploadKeys(params, new RestAdapterCallback<KeysUploadResponse>(description, null, callback, new RestAdapterCallback.RequestRetryCallBack() {
@Override
public void onRetry() {
uploadKeys(deviceKeys, oneTimeKeys, deviceId, callback);
}
}));
}
} catch (Throwable t) {
callback.onUnexpectedError(new Exception(t));
}
}