com.bumptech.glide.load.HttpException Java Examples

The following examples show how to use com.bumptech.glide.load.HttpException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OkHttpFetcher.java    From AndroidProject with Apache License 2.0 5 votes vote down vote up
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) {
    mResponseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = Preconditions.checkNotNull(mResponseBody).contentLength();
        mInputStream = ContentLengthInputStream.obtain(mResponseBody.byteStream(), contentLength);
        mDataCallback.onDataReady(mInputStream);
    } else {
        mDataCallback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
 
Example #2
Source File: OkHttpStreamFetcher.java    From FastAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onResponse(Call call, Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
 
Example #3
Source File: OkHttpStreamFetcher.java    From Aurora with Apache License 2.0 5 votes vote down vote up
@Override
public void onResponse(Call call, Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
 
Example #4
Source File: OkHttpStreamFetcher.java    From MVVMArms with Apache License 2.0 5 votes vote down vote up
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = responseBody.contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
 
Example #5
Source File: OkHttpStreamFetcher.java    From pandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) {
  responseBody = response.body();
  if (response.isSuccessful()) {
    long contentLength = Preconditions.checkNotNull(responseBody).contentLength();
    stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
    callback.onDataReady(stream);
  } else {
    callback.onLoadFailed(new HttpException(response.message(), response.code()));
  }
}
 
Example #6
Source File: OkHttpStreamFetcher.java    From MVPArms with Apache License 2.0 5 votes vote down vote up
@Override
public void onResponse(@NonNull Call call, @NonNull Response response) {
    responseBody = response.body();
    if (response.isSuccessful()) {
        long contentLength = Preconditions.checkNotNull(responseBody).contentLength();
        stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength);
        callback.onDataReady(stream);
    } else {
        callback.onLoadFailed(new HttpException(response.message(), response.code()));
    }
}
 
Example #7
Source File: Capabilities.java    From nextcloud-notes with GNU General Public License v3.0 5 votes vote down vote up
public Capabilities(@NonNull String response, @Nullable String eTag) throws NextcloudHttpRequestFailedException {
    this.eTag = eTag;
    final JSONObject ocs;
    try {
        ocs = new JSONObject(response).getJSONObject(JSON_OCS);
        if (ocs.has(JSON_OCS_META)) {
            final JSONObject meta = ocs.getJSONObject(JSON_OCS_META);
            if (meta.has(JSON_OCS_META_STATUSCODE)) {
                if (meta.getInt(JSON_OCS_META_STATUSCODE) == HTTP_UNAVAILABLE) {
                    Log.i(TAG, "Capabilities Endpoint: This instance is currently in maintenance mode.");
                    throw new NextcloudHttpRequestFailedException(HTTP_UNAVAILABLE, new HttpException(HTTP_UNAVAILABLE));
                }
            }
        }
        if (ocs.has(JSON_OCS_DATA)) {
            final JSONObject data = ocs.getJSONObject(JSON_OCS_DATA);
            if (data.has(JSON_OCS_DATA_CAPABILITIES)) {
                final JSONObject capabilities = data.getJSONObject(JSON_OCS_DATA_CAPABILITIES);
                if (capabilities.has(JSON_OCS_DATA_CAPABILITIES_NOTES)) {
                    final JSONObject notes = capabilities.getJSONObject(JSON_OCS_DATA_CAPABILITIES_NOTES);
                    if (notes.has(JSON_OCS_DATA_CAPABILITIES_NOTES_API_VERSION)) {
                        this.apiVersion = notes.getString(JSON_OCS_DATA_CAPABILITIES_NOTES_API_VERSION);
                    }
                }
                if (capabilities.has(JSON_OCS_DATA_CAPABILITIES_THEMING)) {
                    final JSONObject theming = capabilities.getJSONObject(JSON_OCS_DATA_CAPABILITIES_THEMING);
                    if (theming.has(JSON_OCS_DATA_CAPABILITIES_THEMING_COLOR)) {
                        this.color = theming.getString(JSON_OCS_DATA_CAPABILITIES_THEMING_COLOR);
                    }
                    if (theming.has(JSON_OCS_DATA_CAPABILITIES_THEMING_COLOR_TEXT)) {
                        this.textColor = theming.getString(JSON_OCS_DATA_CAPABILITIES_THEMING_COLOR_TEXT);
                    }
                }
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}