Java 类com.android.volley.error.VolleyError 实例源码

项目:DE-MVP-Clean    文件:SentenceDataRepository.java   
public void startDownloadAudio(final String audioUrl, final long playToken, final DownloadAudioCallback callback) {
    DownloadRequest request = new DownloadRequest(audioUrl, DEVolley.getInstance().getTempAudioDownloadFile().getPath(),
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    callback.onSuccess(audioUrl, playToken);
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            callback.onFail(audioUrl, playToken);
        }
    });
    request.setRetryPolicy(DEVolley.getInstance().getDefaultRetryPolicy(2));
    request.setTag("fetchSentenceAudio");
    DEVolley.getInstance().getRequestQueue().add(request);
}
项目:TamTime    文件:DisruptEventHandler.java   
@Override
public void update() {
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_ALL_DISRUPT, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(final JSONObject response) {
                    new BackgroundTask().execute(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
项目:TamTime    文件:RealTimes.java   
@Override
public void update() {
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_REALTIME, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    setRealTimes(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
项目:TamTime    文件:TheoricTimes.java   
@Override
public void update() { // Theoric times
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_THEOTIME, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    setTheoTimes(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
项目:TamTime    文件:ReportEvent.java   
@Override
public void update() {
    JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
            JSON_REPORT, null,
            new Response.Listener<JSONObject>() {

                @Override
                public void onResponse(JSONObject response) {
                    setReport(response);
                }
            }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d(TAG, "Error: " + error.getMessage());
        }
    });
    VolleyApp.getInstance(context).addToRequestQueue(jsonObjReq);
}
项目:TamTime    文件:ReportEvent.java   
public void confirmReport(final Context context, final int reportId) {
    Map<String,String> params = new HashMap<String, String>();
    params.put("report_id", reportId + "");

    StringRequest sr = new StringRequest(
            Request.Method.POST,
            CONFIRM_REPORT,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Integer result = Integer.parseInt(response);
                    Log.d(TAG, "REPONSE:" + response + "|");
                    Toast.makeText(context, context.getResources().getStringArray(R.array.confirm_status)[result], Toast.LENGTH_SHORT).show();
                    update();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d(TAG, "Error: " + error.getMessage());
                }
            }) {
    };
    sr.setParams(params);
    VolleyApp.getInstance(context).addToRequestQueue(sr);
}
项目:spotify-web-api-android    文件:ExampleActivity.java   
/**
 * (non-doc)
 */
private void onTextChange(String query) {
    mClient.getRequestQueue().cancelAll("SEARCH");
    mClient.searchTrack(query).setListener(new Response.Listener<Page<Track>>() {
        @Override
        public void onResponse(Page<Track> tracks) {
            final List<Track> items = tracks.getItems();
            for (Track item : items) {
                Log.d("Track", item.getArtist(0).getName() + " - " + item.getName());
            }
        }
    }).setErrorListener(new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            volleyError.printStackTrace();
        }
    }).setLimit(25).setTag("SEARCH").build();
}
项目:USADiving_Helix    文件:VolleyUtils.java   
/**
 * Gets a Blurred bitmap for the imageView suggested.
 *
 * @param view
 * @return
 */
public static ImageLoader.ImageListener createBlurImageListener(final ImageView view) {
    return new ImageLoader.ImageListener() {
        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            BitmapDrawable bd = response.getBitmap();
            if (bd != null) {
                ImageBlurTask blur = new ImageBlurTask() {
                    @Override
                    protected void onPostExecute(Bitmap bitmap) {
                        super.onPostExecute(bitmap);
                        view.setImageBitmap(bitmap);
                    }
                };
                blur.execute(bd.getBitmap());
            }
        }

        @Override
        public void onErrorResponse(VolleyError error) {

        }
    };
}
项目:android-volley-file-upload    文件:MainActivity.java   
private void imageUpload(final String imagePath) {

        SimpleMultiPartRequest smr = new SimpleMultiPartRequest(Request.Method.POST, BASE_URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        Log.d("Response", response);
                        try {
                            JSONObject jObj = new JSONObject(response);
                            String message = jObj.getString("message");

                            Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();

                        } catch (JSONException e) {
                            // JSON error
                            e.printStackTrace();
                            Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
            }
        });

        smr.addFile("image", imagePath);
        MyApplication.getInstance().addToRequestQueue(smr);

    }
项目:TamTime    文件:ReportEvent.java   
public void sendReport(final Context context, final Report report) {
    Map<String,String> params = new HashMap<String, String>();
    params.put("our_id", report.getStop().getOurId() + "");
    params.put("type", report.getType().getValue() + "");
    params.put("msg", report.getMessage());

    StringRequest sr = new StringRequest(
            Request.Method.POST,
            POST_REPORT,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Integer result = Integer.parseInt(response);
                    Log.d(TAG, "REPONSE:" + response + "|");
                    Toast.makeText(context, context.getResources().getStringArray(R.array.post_status)[result], Toast.LENGTH_SHORT).show();
                    update();
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d(TAG, "Error: " + error.getMessage());
                }
            }) {
    };
    sr.setParams(params);
    VolleyApp.getInstance(context).addToRequestQueue(sr);
}
项目:spotify-web-api-android    文件:ExampleActivity.java   
/**
 * {@inheritDoc}
 */
@Override
public void onCreate(Bundle instance) {
    super.onCreate(instance);
    setContentView(R.layout.activity_main);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mClient = new ClientRestAPI(Volley.newRequestQueue(getApplicationContext()));

    findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d("XXX", "Click");
            mClient.getAlbum("2dIGnmEIy1WZIcZCFSj6i8").setListener(new Response.Listener<Album>() {
                @Override
                public void onResponse(Album o) {
                    Log.d("XXX", o.getName());
                }
            }).setErrorListener(new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {
                    Log.d("XXX", "ERROR:" + volleyError.getMessage());
                }
            }).build();
        }
    });
}
项目:USADiving_Helix    文件:VolleyUtils.java   
/**
 * Generic Error Listener
 */
public static Response.ErrorListener createErrorListener() {
    return new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
        }
    };
}
项目:openmap-client-android    文件:Notifications.java   
@Override
public void run() {
    Location l = null;
    if (ContextCompat.checkSelfPermission(getApplicationContext(),
            Manifest.permission.ACCESS_COARSE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
            //l = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    }else{
        ActivityCompat.requestPermissions((Activity)MainActivity.getContext(),
                new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
                10);
    }
    //Create a post request
    final Location finalL = l;
    StringRequest request = new StringRequest(Request.Method.POST,
            "http://api.openpokemap.pw/c", new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            //Find location

            //Handle response
            Log.w("Json", response);
            JsonParser parser = new JsonParser();
            JsonArray pokemons = parser.parse(response).getAsJsonObject()
                    .getAsJsonArray("MapObjects");

            for (int i=0; i<pokemons.size();i++){
                JsonObject o = pokemons.get(i).getAsJsonObject();
                int id = o.get("PokemonId").getAsInt();
                String uuid = o.get("Id").getAsString();
                if(RarePokemons.contains(id)){
                    Log.i("P", "Rare pokemon found!");

                    Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);

                    PendingIntent intent = PendingIntent.getActivity(getApplicationContext(), 0,
                            notificationIntent, 0);

                    String name = names.get(id);

                    NotificationCompat.Builder mBuilder =
                            new NotificationCompat.Builder(getApplicationContext())
                                    .setSmallIcon(R.drawable.map)
                                    .setContentTitle("A wild " + name + " is nearby!")
                                    .setContentIntent(intent)
                                    .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 })
                                    .setLights(Color.MAGENTA, 3000, 3000);

                    mNotifyMgr.notify(i, mBuilder.build());
                }
            }
        }

    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("notifications", error.getStackTrace().toString());
            return;
        }
    }){
        @Override
        protected Map<String,String> getParams() {
            Map<String,String> params = new HashMap<String, String>();
            String lat = Double.toString(0);
            String lng = Double.toString(0);
            params.put("lat", lat);
            params.put("lng", lng);
            params.put("p", "true");
            return params;
        }
    };
    queue.add(request);

    //Re run this after 5 minutes
    h.postDelayed(notificationRunnable, 1*60*1000);
}