当前位置: 首页>>代码示例>>Java>>正文


Java ApiCallback.onSuccess方法代码示例

本文整理汇总了Java中org.matrix.androidsdk.rest.callback.ApiCallback.onSuccess方法的典型用法代码示例。如果您正苦于以下问题:Java ApiCallback.onSuccess方法的具体用法?Java ApiCallback.onSuccess怎么用?Java ApiCallback.onSuccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.matrix.androidsdk.rest.callback.ApiCallback的用法示例。


在下文中一共展示了ApiCallback.onSuccess方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
        }
    });

}
 
开发者ID:vector-im,项目名称:riot-android,代码行数:25,代码来源:Matrix.java

示例2: removeAlias

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Remove a room alias.
 *
 * @param alias    the alias to remove
 * @param callback the async callback
 */
public void removeAlias(final String alias, final ApiCallback<Void> callback) {
    final List<String> updatedAliasesList = new ArrayList<>(getAliases());

    // nothing to do
    if (TextUtils.isEmpty(alias) || (updatedAliasesList.indexOf(alias) < 0)) {
        if (null != callback) {
            callback.onSuccess(null);
        }
        return;
    }

    mDataHandler.getDataRetriever().getRoomsRestClient().removeRoomAlias(alias, new RoomInfoUpdateCallback<Void>(callback) {
        @Override
        public void onSuccess(Void info) {
            getState().removeAlias(alias);
            super.onSuccess(info);
        }
    });
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:26,代码来源:Room.java

示例3: addAlias

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Try to add an alias to the aliases list.
 *
 * @param alias    the alias to add.
 * @param callback the the async callback
 */
public void addAlias(final String alias, final ApiCallback<Void> callback) {
    final List<String> updatedAliasesList = new ArrayList<>(getAliases());

    // nothing to do
    if (TextUtils.isEmpty(alias) || (updatedAliasesList.indexOf(alias) >= 0)) {
        if (null != callback) {
            callback.onSuccess(null);
        }
        return;
    }

    mDataHandler.getDataRetriever().getRoomsRestClient().setRoomIdByAlias(getRoomId(), alias, new RoomInfoUpdateCallback<Void>(callback) {
        @Override
        public void onSuccess(Void info) {
            getState().addAlias(alias);
            super.onSuccess(info);
        }
    });
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:26,代码来源:Room.java

示例4: 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 tag      the new tag to add to the room.
 * @param order    the order.
 * @param callback the operation callback
 */
private void addTag(String tag, Double order, final ApiCallback<Void> callback) {
    // sanity check
    if ((null != tag) && (null != order)) {
        mDataHandler.getDataRetriever().getRoomsRestClient().addTag(getRoomId(), tag, order, callback);
    } else {
        if (null != callback) {
            callback.onSuccess(null);
        }
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:19,代码来源:Room.java

示例5: removeTag

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Remove a tag to a room.
 *
 * @param tag      the new tag to add to the room.
 * @param callback the operation callback.
 */
private void removeTag(String tag, final ApiCallback<Void> callback) {
    // sanity check
    if (null != tag) {
        mDataHandler.getDataRetriever().getRoomsRestClient().removeTag(getRoomId(), tag, callback);
    } else {
        if (null != callback) {
            callback.onSuccess(null);
        }
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:17,代码来源:Room.java

示例6: manageBackEvents

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Send MAX_EVENT_COUNT_PER_PAGINATION events to the caller.
 *
 * @param maxEventCount the max event count
 * @param callback      the callback.
 */
private void manageBackEvents(int maxEventCount, final ApiCallback<Integer> callback) {
    // check if the SDK was not logged out
    if (!mDataHandler.isAlive()) {
        Log.d(LOG_TAG, "manageEvents : mDataHandler is not anymore active.");

        return;
    }

    int count = Math.min(mSnapshotEvents.size(), maxEventCount);

    Event latestSupportedEvent = null;

    for (int i = 0; i < count; i++) {
        SnapshotEvent snapshotedEvent = mSnapshotEvents.get(0);

        // in some cases, there is no displayed summary
        // https://github.com/vector-im/vector-android/pull/354
        if ((null == latestSupportedEvent) && RoomSummary.isSupportedEvent(snapshotedEvent.mEvent)) {
            latestSupportedEvent = snapshotedEvent.mEvent;
        }

        mSnapshotEvents.remove(0);
        onEvent(snapshotedEvent.mEvent, Direction.BACKWARDS, snapshotedEvent.mState);
    }

    // https://github.com/vector-im/vector-android/pull/354
    // defines a new summary if the known is not supported
    RoomSummary summary = mStore.getSummary(mRoomId);

    if ((null != latestSupportedEvent) && ((null == summary) || !RoomSummary.isSupportedEvent(summary.getLatestReceivedEvent()))) {
        mStore.storeSummary(new RoomSummary(null, latestSupportedEvent, mState, mDataHandler.getUserId()));
    }

    Log.d(LOG_TAG, "manageEvents : commit");
    mStore.commit();

    if ((mSnapshotEvents.size() < MAX_EVENT_COUNT_PER_PAGINATION) && mIsLastBackChunk) {
        mCanBackPaginate = false;
    }

    if (callback != null) {
        try {
            callback.onSuccess(count);
        } catch (Exception e) {
            Log.e(LOG_TAG, "requestHistory exception " + e.getMessage());
        }
    }

    mIsBackPaginating = false;
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:57,代码来源:EventTimeline.java

示例7: addPaginationEvents

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Add some events in a dedicated direction.
 *
 * @param events    the events list
 * @param direction the direction
 * @param callback  the callback.
 */
private void addPaginationEvents(final List<Event> events, final Direction direction, final ApiCallback<Integer> callback) {
    AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            addPaginationEvents(events, direction);
            return null;
        }

        @Override
        protected void onPostExecute(Void args) {
            if (direction == Direction.BACKWARDS) {
                manageBackEvents(MAX_EVENT_COUNT_PER_PAGINATION, callback);
            } else {
                for (Event event : events) {
                    onEvent(event, Direction.FORWARDS, getState());
                }

                if (null != callback) {
                    callback.onSuccess(events.size());
                }
            }
        }
    };

    try {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } catch (final Exception e) {
        Log.e(LOG_TAG, "## addPaginationEvents() failed " + e.getMessage());
        task.cancel(true);

        (new android.os.Handler(Looper.getMainLooper())).post(new Runnable() {
            @Override
            public void run() {
                if (null != callback) {
                    callback.onUnexpectedError(e);
                }
            }
        });
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:48,代码来源:EventTimeline.java

示例8: refreshUserInfos

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Refresh the user data if it is required
 *
 * @param skipPendingTest true to do not check if the refreshes started (private use)
 * @param callback        callback when the job is done.
 */
public void refreshUserInfos(boolean skipPendingTest, final ApiCallback<Void> callback) {
    if (!skipPendingTest) {
        boolean isPending;

        synchronized (this) {
            // mRefreshListeners == null => no refresh in progress
            // mRefreshListeners != null -> a refresh is in progress
            isPending = (null != mRefreshListeners);

            if (null == mRefreshListeners) {
                mRefreshListeners = new ArrayList<>();
            }

            if (null != callback) {
                mRefreshListeners.add(callback);
            }
        }

        if (isPending) {
            // please wait
            return;
        }
    }

    if (!mIsDisplayNameRefreshed) {
        refreshUserDisplayname();
        return;
    }

    if (!mIsAvatarRefreshed) {
        refreshUserAvatarUrl();
        return;
    }

    if (!mAre3PIdsLoaded) {
        refreshThirdPartyIdentifiers();
        return;
    }

    synchronized (this) {
        if (null != mRefreshListeners) {
            for (ApiCallback<Void> listener : mRefreshListeners) {
                try {
                    listener.onSuccess(null);
                } catch (Exception e) {
                    Log.e(LOG_TAG, "## refreshUserInfos() : listener.onSuccess failed " + e.getMessage());
                }
            }
        }

        // no more pending refreshes
        mRefreshListeners = null;
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:61,代码来源:MyUser.java

示例9: requestEmailValidationToken

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Request an email validation token.
 *
 * @param address              the email address
 * @param clientSecret         the client secret number
 * @param attempt              the attempt count
 * @param nextLink             the next link
 * @param isDuringRegistration true if it occurs during a registration flow
 * @param callback             the callback
 */
public void requestEmailValidationToken(final String address, final String clientSecret, final int attempt,
                                        final String nextLink, final boolean isDuringRegistration,
                                        final ApiCallback<RequestEmailValidationResponse> callback) {
    final String description = "requestEmailValidationToken";

    RequestEmailValidationParams params = new RequestEmailValidationParams();
    params.email = address;
    params.clientSecret = clientSecret;
    params.sendAttempt = attempt;
    params.id_server = mHsConfig.getIdentityServerUri().getHost();
    if (!TextUtils.isEmpty(nextLink)) {
        params.next_link = nextLink;
    }

    final RestAdapterCallback<RequestEmailValidationResponse> adapterCallback = new RestAdapterCallback<RequestEmailValidationResponse>(description, mUnsentEventsManager, callback,
            new RestAdapterCallback.RequestRetryCallBack() {
                @Override
                public void onRetry() {
                    requestEmailValidationToken(address, clientSecret, attempt, nextLink, isDuringRegistration, callback);
                }
            }
    ) {
        @Override
        public void success(RequestEmailValidationResponse requestEmailValidationResponse, Response response) {
            onEventSent();
            requestEmailValidationResponse.email = address;
            requestEmailValidationResponse.clientSecret = clientSecret;
            requestEmailValidationResponse.sendAttempt = attempt;

            callback.onSuccess(requestEmailValidationResponse);
        }
    };

    try {
        if (isDuringRegistration) {
            // URL differs in that case
            mApi.requestEmailValidationForRegistration(params, adapterCallback);
        } else {
            mApi.requestEmailValidation(params, adapterCallback);
        }
    } catch (Throwable t) {
        callback.onUnexpectedError(new Exception(t));
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:55,代码来源:ProfileRestClient.java

示例10: requestPhoneNumberValidationToken

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Request a phone number validation token.
 *
 * @param phoneNumber          the phone number
 * @param countryCode          the country code of the phone number
 * @param clientSecret         the client secret number
 * @param attempt              the attempt count
 * @param isDuringRegistration true if it occurs during a registration flow
 * @param callback             the callback
 */
public void requestPhoneNumberValidationToken(final String phoneNumber, final String countryCode,
                                              final String clientSecret, final int attempt,
                                              final boolean isDuringRegistration, final ApiCallback<RequestPhoneNumberValidationResponse> callback) {
    final String description = "requestPhoneNumberValidationToken";

    RequestPhoneNumberValidationParams params = new RequestPhoneNumberValidationParams();
    params.phone_number = phoneNumber;
    params.country = countryCode;
    params.clientSecret = clientSecret;
    params.sendAttempt = attempt;
    params.id_server = mHsConfig.getIdentityServerUri().getHost();

    final RestAdapterCallback<RequestPhoneNumberValidationResponse> adapterCallback = new RestAdapterCallback<RequestPhoneNumberValidationResponse>(description, mUnsentEventsManager, callback,
            new RestAdapterCallback.RequestRetryCallBack() {
                @Override
                public void onRetry() {
                    requestPhoneNumberValidationToken(phoneNumber, countryCode, clientSecret, attempt, isDuringRegistration, callback);
                }
            }
    ) {
        @Override
        public void success(RequestPhoneNumberValidationResponse requestPhoneNumberValidationResponse, Response response) {
            onEventSent();
            requestPhoneNumberValidationResponse.clientSecret = clientSecret;
            requestPhoneNumberValidationResponse.sendAttempt = attempt;

            callback.onSuccess(requestPhoneNumberValidationResponse);
        }
    };

    try {
        if (isDuringRegistration) {
            // URL differs in that case
            mApi.requestPhoneNumberValidationForRegistration(params, adapterCallback);
        } else {
            mApi.requestPhoneNumberValidation(params, adapterCallback);
        }
    } catch (Throwable t) {
        callback.onUnexpectedError(new Exception(t));
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:52,代码来源:ProfileRestClient.java

示例11: lookup3Pids

import org.matrix.androidsdk.rest.callback.ApiCallback; //导入方法依赖的package包/类
/**
 * Retrieve user matrix id from a 3rd party id.
 * @param addresses 3rd party ids
 * @param mediums the medias.
 * @param callback the 3rd parties callback
 */
public void lookup3Pids(final List<String> addresses, final List<String> mediums, final ApiCallback<List<String>> callback) {
    // sanity checks
    if ((null == addresses) || (null == mediums) || (addresses.size() != mediums.size())) {
        callback.onUnexpectedError(new Exception("invalid params"));
        return;
    }

    // nothing to check
    if (0 == mediums.size()) {
        callback.onSuccess(new ArrayList<String>());
        return;
    }

    BulkLookupParams threePidsParams = new BulkLookupParams();

    ArrayList<List<String>> list = new ArrayList<>();

    for(int i = 0; i < addresses.size(); i++) {
        list.add(Arrays.asList(mediums.get(i), addresses.get(i)));
    }

    threePidsParams.threepids = list;

    try {
        mApi.bulkLookup(threePidsParams, new Callback<BulkLookupResponse>() {
            @Override
            public void success(BulkLookupResponse bulkLookupResponse, Response response) {
                HashMap<String, String> mxidByAddress = new HashMap<>();

                if (null != bulkLookupResponse.threepids) {
                    for (int i = 0; i < bulkLookupResponse.threepids.size(); i++) {
                        List<String> items = bulkLookupResponse.threepids.get(i);
                        // [0] : medium
                        // [1] : address
                        // [2] : matrix id
                        mxidByAddress.put(items.get(1), items.get(2));
                    }
                }

                ArrayList<String> matrixIds = new ArrayList<>();

                for (String address : addresses) {
                    if (mxidByAddress.containsKey(address)) {
                        matrixIds.add(mxidByAddress.get(address));
                    } else {
                        matrixIds.add("");
                    }
                }

                callback.onSuccess(matrixIds);
            }

            @Override
            public void failure(RetrofitError error) {
                callback.onUnexpectedError(error);
            }
        });
    }  catch (Throwable t) {
        callback.onUnexpectedError(new Exception(t));
    }
}
 
开发者ID:matrix-org,项目名称:matrix-android-sdk,代码行数:68,代码来源:ThirdPidRestClient.java


注:本文中的org.matrix.androidsdk.rest.callback.ApiCallback.onSuccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。