本文整理了Java中com.android.volley.Response.isSuccess
方法的一些代码示例,展示了Response.isSuccess
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.isSuccess
方法的具体详情如下:
包路径:com.android.volley.Response
类名称:Response
方法名:isSuccess
[英]Returns whether this response is considered successful.
[中]返回此响应是否被视为成功。
代码示例来源:origin: chentao0707/SimplifyReader
@SuppressWarnings("unchecked")
@Override
public void run() {
// If this request has canceled, finish it and don't deliver.
if (mRequest.isCanceled()) {
mRequest.finish("canceled-at-delivery");
return;
}
// Deliver a normal response or error, depending.
if (mResponse.isSuccess()) {
mRequest.deliverResponse(mResponse.result);
} else {
mRequest.deliverError(mResponse.error);
}
// If this is an intermediate response, add a marker, otherwise we're done
// and the request can be finished.
if (mResponse.intermediate) {
mRequest.addMarker("intermediate-response");
} else {
mRequest.finish("done");
}
// If we have been provided a post-delivery runnable, run it.
if (mRunnable != null) {
mRunnable.run();
}
}
}
代码示例来源:origin: mcxiaoke/android-volley
@SuppressWarnings("unchecked")
@Override
public void run() {
// If this request has canceled, finish it and don't deliver.
if (mRequest.isCanceled()) {
mRequest.finish("canceled-at-delivery");
return;
}
// Deliver a normal response or error, depending.
if (mResponse.isSuccess()) {
mRequest.deliverResponse(mResponse.result);
} else {
mRequest.deliverError(mResponse.error);
}
// If this is an intermediate response, add a marker, otherwise we're done
// and the request can be finished.
if (mResponse.intermediate) {
mRequest.addMarker("intermediate-response");
} else {
mRequest.finish("done");
}
// If we have been provided a post-delivery runnable, run it.
if (mRunnable != null) {
mRunnable.run();
}
}
}
代码示例来源:origin: mcxiaoke/android-volley
@Test public void specifiedCharsetJsonObject() throws Exception {
byte[] data = jsonObjectString().getBytes(Charset.forName("ISO-8859-1"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-1");
NetworkResponse network = new NetworkResponse(data, headers);
JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
assertNotNull(objectResponse);
assertTrue(objectResponse.isSuccess());
//don't check the text in Czech, ISO-8859-1 doesn't support some Czech characters
assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@SuppressWarnings("unchecked")
@Override
public void run() {
// If this request has canceled, finish it and don't deliver.
if (mRequest.isCanceled()) {
mRequest.finish("canceled-at-delivery");
return;
}
// Deliver a normal response or error, depending.
if (mResponse.isSuccess()) {
mRequest.deliverResponse(mResponse.result);
} else {
mRequest.deliverError(mResponse.error);
}
// If this is an intermediate response, add a marker, otherwise we're done
// and the request can be finished.
if (mResponse.intermediate) {
mRequest.addMarker("intermediate-response");
} else {
mRequest.finish("done");
}
// If we have been provided a post-delivery runnable, run it.
if (mRunnable != null) {
mRunnable.run();
}
}
}
代码示例来源:origin: mcxiaoke/android-volley
@Test public void specifiedCharsetJsonArray() throws Exception {
byte[] data = jsonArrayString().getBytes(Charset.forName("ISO-8859-2"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-2");
NetworkResponse network = new NetworkResponse(data, headers);
JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);
assertNotNull(arrayResponse);
assertTrue(arrayResponse.isSuccess());
assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
// don't check the copyright symbol, ISO-8859-2 doesn't have it, but it has Czech characters
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@Test public void specifiedCharsetJsonObject() throws Exception {
byte[] data = jsonObjectString().getBytes(Charset.forName("ISO-8859-1"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-1");
NetworkResponse network = new NetworkResponse(data, headers);
JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
assertNotNull(objectResponse);
assertTrue(objectResponse.isSuccess());
//don't check the text in Czech, ISO-8859-1 doesn't support some Czech characters
assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@Test public void specifiedCharsetJsonArray() throws Exception {
byte[] data = jsonArrayString().getBytes(Charset.forName("ISO-8859-2"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-2");
NetworkResponse network = new NetworkResponse(data, headers);
JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);
assertNotNull(arrayResponse);
assertTrue(arrayResponse.isSuccess());
assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
// don't check the copyright symbol, ISO-8859-2 doesn't have it, but it has Czech characters
}
代码示例来源:origin: mcxiaoke/android-volley
@Test public void defaultCharsetJsonArray() throws Exception {
// UTF-8 is default charset for JSON
byte[] data = jsonArrayString().getBytes(Charset.forName("UTF-8"));
NetworkResponse network = new NetworkResponse(data);
JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);
assertNotNull(arrayResponse);
assertTrue(arrayResponse.isSuccess());
assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
assertEquals(COPY_VALUE, arrayResponse.result.getString(COPY_INDEX));
}
代码示例来源:origin: mcxiaoke/android-volley
@Test public void defaultCharsetJsonObject() throws Exception {
// UTF-8 is default charset for JSON
byte[] data = jsonObjectString().getBytes(Charset.forName("UTF-8"));
NetworkResponse network = new NetworkResponse(data);
JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
assertNotNull(objectResponse);
assertTrue(objectResponse.isSuccess());
assertEquals(TEXT_VALUE, objectResponse.result.getString(TEXT_NAME));
assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@Test public void defaultCharsetJsonObject() throws Exception {
// UTF-8 is default charset for JSON
byte[] data = jsonObjectString().getBytes(Charset.forName("UTF-8"));
NetworkResponse network = new NetworkResponse(data);
JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
assertNotNull(objectResponse);
assertTrue(objectResponse.isSuccess());
assertEquals(TEXT_VALUE, objectResponse.result.getString(TEXT_NAME));
assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@Test public void defaultCharsetJsonArray() throws Exception {
// UTF-8 is default charset for JSON
byte[] data = jsonArrayString().getBytes(Charset.forName("UTF-8"));
NetworkResponse network = new NetworkResponse(data);
JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);
assertNotNull(arrayResponse);
assertTrue(arrayResponse.isSuccess());
assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
assertEquals(COPY_VALUE, arrayResponse.result.getString(COPY_INDEX));
}
代码示例来源:origin: mcxiaoke/android-volley
private void verifyResize(NetworkResponse networkResponse, int maxWidth, int maxHeight,
ScaleType scaleType, int expectedWidth, int expectedHeight) {
ImageRequest request = new ImageRequest("", null, maxWidth, maxHeight, scaleType,
Config.RGB_565, null);
Response<Bitmap> response = request.parseNetworkResponse(networkResponse);
assertNotNull(response);
assertTrue(response.isSuccess());
Bitmap bitmap = response.result;
assertNotNull(bitmap);
assertEquals(expectedWidth, bitmap.getWidth());
assertEquals(expectedHeight, bitmap.getHeight());
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
private void verifyResize(NetworkResponse networkResponse, int maxWidth, int maxHeight,
ScaleType scaleType, int expectedWidth, int expectedHeight) {
ImageRequest request = new ImageRequest("", null, maxWidth, maxHeight, scaleType,
Config.RGB_565, null);
Response<Bitmap> response = request.parseNetworkResponse(networkResponse);
assertNotNull(response);
assertTrue(response.isSuccess());
Bitmap bitmap = response.result;
assertNotNull(bitmap);
assertEquals(expectedWidth, bitmap.getWidth());
assertEquals(expectedHeight, bitmap.getHeight());
}
代码示例来源:origin: mcxiaoke/android-volley
@Test public void successPostsResponse() throws Exception {
mNetwork.setDataToReturn(CANNED_DATA);
mNetwork.setNumExceptionsToThrow(0);
mNetworkQueue.add(mRequest);
mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertFalse(mDelivery.postError_called);
assertTrue(mDelivery.postResponse_called);
Response<?> response = mDelivery.responsePosted;
assertNotNull(response);
assertTrue(response.isSuccess());
assertTrue(Arrays.equals((byte[])response.result, CANNED_DATA));
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@Test public void successPostsResponse() throws Exception {
mNetwork.setDataToReturn(CANNED_DATA);
mNetwork.setNumExceptionsToThrow(0);
mNetworkQueue.add(mRequest);
mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertFalse(mDelivery.postError_called);
assertTrue(mDelivery.postResponse_called);
Response<?> response = mDelivery.responsePosted;
assertNotNull(response);
assertTrue(response.isSuccess());
assertTrue(Arrays.equals((byte[])response.result, CANNED_DATA));
}
代码示例来源:origin: MewX/light-novel-library_Wenku8_Android
@Test public void specifiedCharsetJsonObject() throws Exception {
byte[] data = jsonObjectString().getBytes(Charset.forName("ISO-8859-1"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-1");
NetworkResponse network = new NetworkResponse(data, headers);
JsonObjectRequest objectRequest = new JsonObjectRequest("", null, null, null);
Response<JSONObject> objectResponse = objectRequest.parseNetworkResponse(network);
assertNotNull(objectResponse);
assertTrue(objectResponse.isSuccess());
//don't check the text in Czech, ISO-8859-1 doesn't support some Czech characters
assertEquals(COPY_VALUE, objectResponse.result.getString(COPY_NAME));
}
代码示例来源:origin: MewX/light-novel-library_Wenku8_Android
@Test public void specifiedCharsetJsonArray() throws Exception {
byte[] data = jsonArrayString().getBytes(Charset.forName("ISO-8859-2"));
Map<String, String> headers = new HashMap<String, String>();
headers.put("Content-Type", "application/json; charset=iso-8859-2");
NetworkResponse network = new NetworkResponse(data, headers);
JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);
assertNotNull(arrayResponse);
assertTrue(arrayResponse.isSuccess());
assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
// don't check the copyright symbol, ISO-8859-2 doesn't have it, but it has Czech characters
}
代码示例来源:origin: chuyangliu/tastysnake
@Test public void defaultCharsetJsonArray() throws Exception {
// UTF-8 is default charset for JSON
byte[] data = jsonArrayString().getBytes(Charset.forName("UTF-8"));
NetworkResponse network = new NetworkResponse(data);
JsonArrayRequest arrayRequest = new JsonArrayRequest("", null, null);
Response<JSONArray> arrayResponse = arrayRequest.parseNetworkResponse(network);
assertNotNull(arrayResponse);
assertTrue(arrayResponse.isSuccess());
assertEquals(TEXT_VALUE, arrayResponse.result.getString(TEXT_INDEX));
assertEquals(COPY_VALUE, arrayResponse.result.getString(COPY_INDEX));
}
代码示例来源:origin: MewX/light-novel-library_Wenku8_Android
private void verifyResize(NetworkResponse networkResponse, int maxWidth, int maxHeight,
ScaleType scaleType, int expectedWidth, int expectedHeight) {
ImageRequest request = new ImageRequest("", null, maxWidth, maxHeight, scaleType,
Config.RGB_565, null);
Response<Bitmap> response = request.parseNetworkResponse(networkResponse);
assertNotNull(response);
assertTrue(response.isSuccess());
Bitmap bitmap = response.result;
assertNotNull(bitmap);
assertEquals(expectedWidth, bitmap.getWidth());
assertEquals(expectedHeight, bitmap.getHeight());
}
代码示例来源:origin: MewX/light-novel-library_Wenku8_Android
@Test public void successPostsResponse() throws Exception {
mNetwork.setDataToReturn(CANNED_DATA);
mNetwork.setNumExceptionsToThrow(0);
mNetworkQueue.add(mRequest);
mNetworkQueue.waitUntilEmpty(TIMEOUT_MILLIS);
assertFalse(mDelivery.postError_called);
assertTrue(mDelivery.postResponse_called);
Response<?> response = mDelivery.responsePosted;
assertNotNull(response);
assertTrue(response.isSuccess());
assertTrue(Arrays.equals((byte[])response.result, CANNED_DATA));
}
内容来源于网络,如有侵权,请联系作者删除!