當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。