下面列出了怎么用com.bumptech.glide.load.HttpException的API类实例代码及写法,或者点击链接到github查看源代码。
@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()));
}
}
@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()));
}
}
@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()));
}
}
@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()));
}
}
@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()));
}
}
@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()));
}
}
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();
}
}