Java Code Examples for com.android.volley.VolleyError#printStackTrace()

The following examples show how to use com.android.volley.VolleyError#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestSingletonFactory.java    From Netease with GNU General Public License v3.0 7 votes vote down vote up
@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();
}
 
Example 2
Source File: GosScheduleSiteTool.java    From Gizwits-SmartBuld_Android with MIT License 6 votes vote down vote up
private void sendDateToSite(String httpurl, JSONObject jsonObject, final OnResponListener respon) {
	JsonRequest<JSONObject> jsonRequest = new JsonObjectRequest(Method.POST, httpurl, jsonObject,
			new Response.Listener<JSONObject>() {
				@Override
				public void onResponse(JSONObject response) {
					Log.i("onSite", "response -> " + response.toString());
					respon.OnRespon(0, response.optString("id"));
				}
			}, new Response.ErrorListener() {
				@Override
				public void onErrorResponse(VolleyError error) {
					respon.OnRespon(1, error.toString());
					error.printStackTrace();
					Log.i("onSite", "sendDateToSite请求失败" + error.toString());
				}
			}) {

		@Override
		public Map<String, String> getHeaders() {
			return getHeaderWithToken();
		}
	};
	mRequestQueue.add(jsonRequest);
}
 
Example 3
Source File: ProcessingFragment.java    From timelapse-sony with GNU General Public License v3.0 6 votes vote down vote up
private void showImage(String url) {
    ImageRequest request = new ImageRequest(url,
            new Response.Listener<Bitmap>() {
                @Override
                public void onResponse(final Bitmap bitmap) {
                    if (getActivity() == null) return;
                    getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mImageReviewView.setImageBitmap(bitmap);
                        }
                    });
                }
            }, 0, 0, ImageView.ScaleType.CENTER_INSIDE, null,
            new Response.ErrorListener() {
                public void onErrorResponse(VolleyError error) {
                    error.printStackTrace();
                }
            });
    mImagesQueue.add(request);
}
 
Example 4
Source File: PlacesSearchItemActivity.java    From Place-Search-Service with MIT License 5 votes vote down vote up
public void reqDetails () {
    String place_id = obj.getPlace_id();

    RequestQueue mQueue = Volley.newRequestQueue(this);
    String details_url = BaseUrl.Place_id_info_url + place_id;
    Log.v("url:", BaseUrl.Place_id_info_url + place_id);// the url can get the detail json
    JsonObjectRequest jsonRequest = new JsonObjectRequest
            (Request.Method.GET, details_url, null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    if (response != null) {
                        try {
                            Log.v("the response is ", response.toString());
                            JSONObject json_details = response.getJSONObject("result");
                            String placeDetails = json_details.toString();
                            Gson gson = new Gson();
                            details = gson.fromJson(placeDetails, new TypeToken<Details>() {}.getType());

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }

                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(context,"API failure",Toast.LENGTH_LONG).show();
                    Log.i("the error is ",error.toString());
                    error.printStackTrace();

                }
            });
    mQueue.add(jsonRequest);
}
 
Example 5
Source File: VolleyStack.java    From AndNet with Apache License 2.0 5 votes vote down vote up
/**
 * 执行网络请求
 *
 * @param url
 * @param params   post时请求的参数 get时为null
 * @param parser
 * @param callback
 * @param method
 */
private void invoke(final int method, final String url,
                    final RequestParams params,
                    final Net.Parser<T> parser,
                    final Net.Callback<T> callback,
                    final Object tag) {
    StringRequest request = new StringRequest(method, url,
            new Response.Listener<String>() {
                public void onResponse(String response) {
                    onNetResponse(parser, callback, response);
                }
            }, new Response.ErrorListener() {
        public void onErrorResponse(VolleyError error) {
            error.printStackTrace();
            onError(callback, Net.DEF_ERR_MSG);
        }
    }) {
        @Override
        protected Map<String, String> getParams()
                throws AuthFailureError {
            if (params != null) return params.get();
            return super.getParams();
        }
    };

    VolleyManager.getInstance(mContext).add(request, tag);
}
 
Example 6
Source File: GosScheduleSiteTool.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
public void deleteTimeOnSite(String id, final OnResponListener reponse) {
	String httpurl = "http://api.gizwits.com/app/scheduler/" + id;
	StringRequest stringRequest = new StringRequest(Method.DELETE, httpurl, new Response.Listener<String>() {
		@Override
		public void onResponse(String arg0) {
			reponse.OnRespon(0, "OK");
		}
	}, new Response.ErrorListener() {
		@Override
		public void onErrorResponse(VolleyError error) {
			if (error.networkResponse != null) {
				if (error.networkResponse.statusCode == 404) {// 404:云端无法找到该条目,表示该条目已被删除
					reponse.OnRespon(0, "OK");
				}
			}
			reponse.OnRespon(1, error.toString());
			error.printStackTrace();
			Log.i("onSite", "删除失败" + error.toString());

		}
	}) {

		@Override
		public Map<String, String> getHeaders() throws AuthFailureError {
			return getHeaderWithToken();
		}

	};
	stringRequest.setRetryPolicy(new DefaultRetryPolicy(2500, 3, 0));
	mRequestQueue.add(stringRequest);

}
 
Example 7
Source File: HttpLoader.java    From seny-devpkg with Apache License 2.0 5 votes vote down vote up
@Override
public void onErrorResponse(VolleyError error) {
    ALog.w("Request error from network!");
    error.printStackTrace();
    mInFlightRequests.remove(requestCode);//请求错误,从正在飞的集合中删除该请求
    if (listener != null) {
        listener.onGetResponseError(requestCode, error);
    }

}
 
Example 8
Source File: PlaceSearchReviewFragment.java    From Place-Search-Service with MIT License 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_review, container, false);

    list_review = (ListView) view.findViewById(R.id.reviewList);
    layout = view.findViewById(R.id.layout);
    review_none_txt = view.findViewById(R.id.review_none_txt);
    Bundle arguments = getArguments();
    obj = (PlacesSearchResultObj.PlacesSearchResultItemObj) arguments.getSerializable("data");
    String place_id = obj.getPlace_id();
    context = getActivity();

    RequestQueue mQueue = Volley.newRequestQueue(context);
    String details_url = BaseUrl.Place_id_info_url + place_id;
    Log.v("url:", BaseUrl.Place_id_info_url + place_id);// the url can get the detail json
    JsonObjectRequest jsonRequest = new JsonObjectRequest
            (Request.Method.GET, details_url, null, new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    if (response != null) {
                        try {
                            Log.v("the response is ", response.toString());
                            JSONObject json_details = response.getJSONObject("result");
                            String placeDetails = json_details.toString();
                            Gson gson = new Gson();
                            details = gson.fromJson(placeDetails, new TypeToken<Details>() {}.getType());
                            originDetails = details.myclone();
                            yelpRequest(details,view);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }finally {
                            if (context instanceof PlacesSearchItemActivity){
                                ((PlacesSearchItemActivity)context).requsetNumberAdd();
                            }
                        }
                    }

                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.i("the error is ",error.toString());
                    Toast.makeText(getContext(),"API failure",Toast.LENGTH_LONG).show();
                    error.printStackTrace();
                    if (context instanceof PlacesSearchItemActivity){
                        ((PlacesSearchItemActivity)context).requsetNumberAdd();
                    }
                }
            });
    mQueue.add(jsonRequest);

    return view;
}
 
Example 9
Source File: GosScheduleSiteTool.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
/**
 * <p>
 * Description:
 * </p>
 */
public void getTimeOnSite(final OnResponseGetDeviceDate response) {

	String httpurl = "http://api.gizwits.com/app/scheduler";
	StringRequest stringRequest = new StringRequest(Method.GET, httpurl, new Response.Listener<String>() {
		@Override
		public void onResponse(String arg0) {
			Log.i("onSite", "-------------");
			Log.i("onSite", arg0);
			dataList = new ArrayList<ConcurrentHashMap<String, Object>>();
			try {
				JSONArray js = new JSONArray(arg0);
				for (int i = 0; i < js.length(); i++) {
					JSONObject jo = js.getJSONObject(i);
					ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<String, Object>();
					map.put("date", jo.optString("date"));
					map.put("time", jo.optString("time"));
					map.put("repeat", jo.optString("repeat"));
					map.put("did", getDidFromJsonObject(jo));
					map.put("dataMap", getDateFromJsonObject(jo));
					map.put("ruleID", jo.optString("id"));
					dataList.add(map);
				}
				response.onReceviceDate(dataList);
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
	}, new Response.ErrorListener() {
		@Override
		public void onErrorResponse(VolleyError error) {
			response.onReceviceDate(null);
			error.printStackTrace();
			Log.i("onSite", "获取设备状态请求失败" + error.toString() + error.getNetworkTimeMs());
		}
	}) {

		@Override
		public Map<String, String> getHeaders() throws AuthFailureError {
			return getHeaderWithToken();
		}

	};
	stringRequest.setRetryPolicy(new DefaultRetryPolicy(2500, 4, 0));
	mRequestQueue.add(stringRequest);
}
 
Example 10
Source File: BatchDownloaderService.java    From QuickLyric with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onErrorResponse(VolleyError error) {
    updateProgress();
    error.printStackTrace();
}
 
Example 11
Source File: MainActivity.java    From conference-app with Apache License 2.0 4 votes vote down vote up
@Override
public void onErrorResponse(VolleyError error) {
    error.printStackTrace();
    onUpdateDone();
}