当前位置: 首页>>代码示例>>Java>>正文


Java TimeoutError类代码示例

本文整理汇总了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();
}
 
开发者ID:freedomofme,项目名称:Netease,代码行数:22,代码来源:RequestSingletonFactory.java

示例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();
            }
    }
}
 
开发者ID:michaelachmann,项目名称:LnkShortener,代码行数:23,代码来源:SetupActivity.java

示例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;
}
 
开发者ID:xmagicj,项目名称:HappyVolley,代码行数:31,代码来源:BaseRequest.java

示例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("未知错误");
}
 
开发者ID:likebamboo,项目名称:AndroidBlog,代码行数:25,代码来源:ErrorTrans.java

示例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);
}
 
开发者ID:giovanimoura,项目名称:plainrequest,代码行数:25,代码来源:RequestCustom.java

示例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;
}
 
开发者ID:DoloresTeam,项目名称:dolores-android,代码行数:24,代码来源:HttpUtil.java

示例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;
}
 
开发者ID:tengbinlive,项目名称:ooooim_android,代码行数:30,代码来源:CommonRequest.java

示例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;
}
 
开发者ID:tengbinlive,项目名称:aibao_demo,代码行数:28,代码来源:CommonRequest.java

示例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));
    }
}
 
开发者ID:lloydtorres,项目名称:stately,代码行数:29,代码来源:ZombieControlActivity.java

示例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);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:21,代码来源:ErrorStrings.java

示例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;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:17,代码来源:BillingAccountService.java

示例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);
	}
}
 
开发者ID:lingganhezi,项目名称:dedecmsapp,代码行数:21,代码来源:BaseActivity.java

示例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;
}
 
开发者ID:lemberg,项目名称:android-project-template,代码行数:19,代码来源:VolleyResponseUtils.java

示例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);
    }

}
 
开发者ID:nishant-git,项目名称:social-api,代码行数:21,代码来源:ServerRequest.java

示例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 "其他错误";
        }
    }
 
开发者ID:Tangyingqi,项目名称:Jiemian,代码行数:18,代码来源:BasePresenter.java


注:本文中的com.android.volley.TimeoutError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。