Search in sources :

Example 1 with URLPreview

use of org.matrix.androidsdk.rest.model.URLPreview in project matrix-android-sdk by matrix-org.

the class EventsRestClient method getURLPreview.

/**
 * Retrieve the URL preview information.
 *
 * @param url      the URL
 * @param ts       the timestamp
 * @param callback the asynchronous callback
 */
public void getURLPreview(final String url, final long ts, final ApiCallback<URLPreview> callback) {
    final String description = "getURLPreview : URL " + url + " with ts " + ts;
    mApi.getURLPreview(url, ts).enqueue(new RestAdapterCallback<Map<String, Object>>(description, null, false, new SimpleApiCallback<Map<String, Object>>(callback) {

        @Override
        public void onSuccess(Map<String, Object> map) {
            if (null != callback) {
                callback.onSuccess(new URLPreview(map, url));
            }
        }
    }, new RestAdapterCallback.RequestRetryCallBack() {

        @Override
        public void onRetry() {
            getURLPreview(url, ts, callback);
        }
    }));
}
Also used : URLPreview(org.matrix.androidsdk.rest.model.URLPreview) HashMap(java.util.HashMap) Map(java.util.Map) SimpleApiCallback(org.matrix.androidsdk.core.callback.SimpleApiCallback)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 SimpleApiCallback (org.matrix.androidsdk.core.callback.SimpleApiCallback)1 URLPreview (org.matrix.androidsdk.rest.model.URLPreview)1