本文整理汇总了Java中com.android.volley.TimeoutError类的典型用法代码示例。如果您正苦于以下问题:Java TimeoutError类的具体用法?Java TimeoutError怎么用?Java TimeoutError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeoutError类属于com.android.volley包,在下文中一共展示了TimeoutError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onErrorResponse
import com.android.volley.TimeoutError; //导入依赖的package包/类
@Override
public void onErrorResponse(VolleyError error) {
error.printStackTrace();
Log.d("RVA", "error:" + error);
int errorCode = 0;
if (error instanceof TimeoutError) {
errorCode = -7;
} else if (error instanceof NoConnectionError) {
errorCode = -1;
} else if (error instanceof AuthFailureError) {
errorCode = -6;
} else if (error instanceof ServerError) {
errorCode = 0;
} else if (error instanceof NetworkError) {
errorCode = -1;
} else if (error instanceof ParseError) {
errorCode = -8;
}
Toast.makeText(contextHold, ErrorCode.errorCodeMap.get(errorCode), Toast.LENGTH_SHORT).show();
}
示例2: onErrorResponse
import com.android.volley.TimeoutError; //导入依赖的package包/类
@Override
public void onErrorResponse(VolleyError error) {
if (error instanceof TimeoutError || error instanceof NoConnectionError) {
// Is thrown if there's no network connection or server is down
Toast.makeText(context, getString(R.string.error_network_timeout),
Toast.LENGTH_LONG).show();
// We return to the last fragment
if (getFragmentManager().getBackStackEntryCount() != 0) {
getFragmentManager().popBackStack();
}
} else {
// Is thrown if there's no network connection or server is down
Toast.makeText(context, getString(R.string.error_network),
Toast.LENGTH_LONG).show();
// We return to the last fragment
if (getFragmentManager().getBackStackEntryCount() != 0) {
getFragmentManager().popBackStack();
}
}
}
示例3: isConnectionError
import com.android.volley.TimeoutError; //导入依赖的package包/类
/**
* 判断是否有网络 或者 server无响应等非Client端请求参数异常
*
* @param error VolleyError
* @return isConnectionError
*/
public boolean isConnectionError(VolleyError error) {
if (error == null) {
return false;
}
if (error instanceof TimeoutError) {
return true;
}
if (error instanceof NoConnectionError) {
return true;
}
if (error instanceof NetworkError) {
return true;
}
if (error instanceof ServerError) {
return true;
}
if (error instanceof RedirectError) {
return true;
}
if (error instanceof AuthFailureError) {
return true;
}
return false;
}
示例4: transToOsaException
import com.android.volley.TimeoutError; //导入依赖的package包/类
public static OsaException transToOsaException(Throwable a) {
if (a == null) {
return new OsaException("未知错误");
}
if (a instanceof ParseError) {
return new OsaException("数据解析错误", a);
}
if (a instanceof TimeoutError) {
return new OsaException("请求超时", a);
}
if (a instanceof ServerError) {
return new OsaException("服务器错误", a);
}
if (a instanceof AuthFailureError) {
return new OsaException("请求认证错误", a);
}
if (a instanceof NoConnectionError) {
return new OsaException("网络未连接,请检查网络状态", a);
}
if (a instanceof NetworkError) {
return new OsaException("网络连接异常", a);
}
return new OsaException("未知错误");
}
示例5: deliverError
import com.android.volley.TimeoutError; //导入依赖的package包/类
@Override
public void deliverError(VolleyError error) {
statusCode = error.networkResponse != null ? error.networkResponse.statusCode : 0;
String msgError = null;
if (error instanceof NetworkError) {
msgError = "Failed to connect to server";
} else if (error instanceof TimeoutError) {
msgError = "Timeout for connection exceeded";
} else {
if (error.networkResponse != null && error.networkResponse.data != null && !error.networkResponse.data.equals("")) {
try {
msgError = new String(error.networkResponse.data, PROTOCOL_CHARSET);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
msgError = error.getMessage();
}
}
this.onPlainRequest.onError(error, msgError, statusCode);
}
示例6: checkErrorType
import com.android.volley.TimeoutError; //导入依赖的package包/类
public static String checkErrorType(VolleyError error) {
String str = "";
if (error instanceof NoConnectionError) {
str = ErrorCode.IS_NOT_NETWORK;
} else if (error instanceof AuthFailureError) {
str = ErrorCode.AUTH_FAILED;
} else if (error instanceof TimeoutError) {
str = ErrorCode.CONNECTION_TIMEOUT;
} else if (error instanceof ParseError) {
str = ErrorCode.PARSE_DATA_ERROR;
} else if (error instanceof ServerError) {
str = ErrorCode.SERVER_ERROR;
} else if (error instanceof HttpError) {
HttpError httpError = (HttpError) error;
str = httpError.getMessage();
if (TextUtils.isEmpty(str)) {
str = ErrorCode.REQUEST_ERROR;
}
} else {
str = ErrorCode.REQUEST_ERROR;
}
return str;
}
示例7: getErrorCommonResponse
import com.android.volley.TimeoutError; //导入依赖的package包/类
/**
* 根据Volley错误对象返回CommonResponse对象并写入错误信息.
*
* @param error Volley错误对象
* @return 返回CommonResponse对象并写入错误信息s
*/
private static CommonResponse getErrorCommonResponse(VolleyError error) {
CommonResponse response = null;
Throwable cause = error.getCause();
if (cause == null) {
cause = error;
}
if (cause instanceof TimeoutException) {
response = new CommonResponse(CodeEnum._404);
} else if (cause instanceof TimeoutException) {
response = new CommonResponse(CodeEnum.CONNECT_TIMEOUT);
} else if (cause instanceof ConnectTimeoutException) {
response = new CommonResponse(CodeEnum.CONNECT_TIMEOUT);
} else if (cause instanceof TimeoutError) {
response = new CommonResponse(CodeEnum.CONNECT_TIMEOUT);
} else if (cause instanceof UnknownHostException) {
response = new CommonResponse(CodeEnum.UNKNOWN_HOST);
} else if (cause instanceof IOException) {
response = new CommonResponse(CodeEnum.NETWORK_EXCEPTION);
} else {
response = new CommonResponse(CodeEnum.EXCEPTION.getCode(), cause.getLocalizedMessage());
}
return response;
}
示例8: getErrorCommonResponse
import com.android.volley.TimeoutError; //导入依赖的package包/类
/**
* 根据Volley错误对象返回CommonResponse对象并写入错误信息.
*
* @param error Volley错误对象
* @return 返回CommonResponse对象并写入错误信息s
*/
private static CommonResponse getErrorCommonResponse(VolleyError error) {
CommonResponse response;
Throwable cause = error.getCause();
if (cause == null) {
cause = error;
}
if (cause instanceof TimeoutException) {
response = new CommonResponse(CodeEnum._404);
} else if (cause instanceof ConnectTimeoutException) {
response = new CommonResponse(CodeEnum.CONNECT_TIMEOUT);
} else if (cause instanceof TimeoutError) {
response = new CommonResponse(CodeEnum.CONNECT_TIMEOUT);
} else if (cause instanceof UnknownHostException) {
response = new CommonResponse(CodeEnum.UNKNOWN_HOST);
} else if (cause instanceof IOException) {
response = new CommonResponse(CodeEnum.NETWORK_EXCEPTION);
} else {
response = new CommonResponse(CodeEnum.EXCEPTION.getCode(), cause.getLocalizedMessage());
}
return response;
}
示例9: queryZSuperweaponProgress
import com.android.volley.TimeoutError; //导入依赖的package包/类
/**
* Queries the user's superweapon progress.
*/
private void queryZSuperweaponProgress() {
NSStringRequest stringRequest = new NSStringRequest(getApplicationContext(), Request.Method.GET, ZSuperweaponProgress.ZOMBIE_CONTROL_QUERY,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
processZSuperweaponProgress(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
SparkleHelper.logError(error.toString());
mSwipeRefreshLayout.setRefreshing(false);
if (error instanceof TimeoutError || error instanceof NoConnectionError || error instanceof NetworkError) {
SparkleHelper.makeSnackbar(mView, getString(R.string.login_error_no_internet));
} else {
SparkleHelper.makeSnackbar(mView, getString(R.string.login_error_generic));
}
}
});
if (!DashHelper.getInstance(this).addRequest(stringRequest)) {
mSwipeRefreshLayout.setRefreshing(false);
SparkleHelper.makeSnackbar(mView, getString(R.string.rate_limit_error));
}
}
示例10: get
import com.android.volley.TimeoutError; //导入依赖的package包/类
public static String get(Context paramContext, VolleyError paramVolleyError)
{
if ((paramVolleyError instanceof DisplayMessageError)) {
return ((DisplayMessageError)paramVolleyError).mDisplayErrorHtml;
}
if ((paramVolleyError instanceof AuthFailureError)) {
return paramContext.getString(2131361869);
}
if ((paramVolleyError instanceof ServerError)) {
return paramContext.getString(2131362721);
}
if ((paramVolleyError instanceof TimeoutError)) {
return paramContext.getString(2131362787);
}
if ((paramVolleyError instanceof NetworkError)) {
return paramContext.getString(2131362362);
}
FinskyLog.d("No specific error message for: %s", new Object[] { paramVolleyError });
return paramContext.getString(2131362362);
}
示例11: convertErrorCode
import com.android.volley.TimeoutError; //导入依赖的package包/类
private static int convertErrorCode(Throwable paramThrowable)
{
if ((paramThrowable instanceof ServerError)) {
return -1;
}
if ((paramThrowable instanceof NetworkError)) {
return -2;
}
if ((paramThrowable instanceof AuthFailureError)) {
return -3;
}
if ((paramThrowable instanceof TimeoutError)) {
return -4;
}
return 0;
}
示例12: showToast
import com.android.volley.TimeoutError; //导入依赖的package包/类
/**
* toast 方式显示异常信息到界面
*
* @param e
*/
public void showToast(Exception e) {
if (e instanceof SocketTimeoutException || e instanceof TimeoutError) {
showToast(R.string.error_networktimeout);
} else if (e instanceof UnknownHostException) {
showToast(R.string.error_unknowhost);
} else if (e instanceof FileNotFoundException) {
showToast(R.string.error_filenotfound);
} else if (e instanceof IllegalAccessException) {
showToast(R.string.error_notaccess);
} else if (e instanceof IOException) {
showToast(R.string.error_io);
} else {
showToast(R.string.error_unknow);
}
}
示例13: isNetworkingError
import com.android.volley.TimeoutError; //导入依赖的package包/类
public static boolean isNetworkingError(VolleyError volleyError)
{
if (volleyError.networkResponse == null) {
if (volleyError instanceof TimeoutError) {
return true;
}
if (volleyError instanceof NoConnectionError) {
return true;
}
if (volleyError instanceof NetworkError) {
return true;
}
}
return false;
}
示例14: showError
import com.android.volley.TimeoutError; //导入依赖的package包/类
private void showError(VolleyError error) {
//In your extended request class
dismissProgressBar();
if (error.networkResponse != null && error.networkResponse.data != null) {
VolleyError volleyError = new VolleyError(new String(error.networkResponse.data));
volleyError.printStackTrace();
}
if (error instanceof NetworkError) {
showToast(NETWORK_ERROR);
} else if (error instanceof ServerError) {
showToast(SERVER_ERROR);
} else if (error instanceof NoConnectionError) {
showToast(NO_INTERNET_CONNECTION);
} else if (error instanceof TimeoutError) {
showToast(CONNECTION_TIME_OUT);
} else {
showToast(UNKNOWN_ERROR);
}
}
示例15: handlerException
import com.android.volley.TimeoutError; //导入依赖的package包/类
public String handlerException(VolleyError error) {
if (error instanceof TimeoutError || error instanceof NoConnectionError) {
return "连接服务器失败";
} else if (error instanceof AuthFailureError) {
return "服务器验证失败";
} else if (error instanceof ServerError) {
return "服务器出错了";
} else if (error instanceof NetworkError) {
return "网络异常";
} else if (error instanceof ParseError) {
return "数据解析异常";
} else {
Log.d("error", error.toString());
return "其他错误";
}
}