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


Java VolleyError类代码示例

本文整理汇总了Java中com.android.volley.VolleyError的典型用法代码示例。如果您正苦于以下问题:Java VolleyError类的具体用法?Java VolleyError怎么用?Java VolleyError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VolleyError类属于com.android.volley包,在下文中一共展示了VolleyError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getImageListener

import com.android.volley.VolleyError; //导入依赖的package包/类
/**
 * The default implementation of ImageListener which handles basic functionality
 * of showing a default image until the network response is received, at which point
 * it will switch to either the actual image or the error image.
 * @param view The imageView that the listener is associated with.
 * @param defaultImageResId Default image resource ID to use, or 0 if it doesn't exist.
 * @param errorImageResId Error image resource ID to use, or 0 if it doesn't exist.
 */
public static ImageListener getImageListener(final ImageView view,
        final int defaultImageResId, final int errorImageResId) {
    return new ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageResId != 0) {
                view.setImageResource(errorImageResId);
            }
        }

        @Override
        public void onResponse(ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                view.setImageBitmap(response.getBitmap());
            } else if (defaultImageResId != 0) {
                view.setImageResource(defaultImageResId);
            }
        }
    };
}
 
开发者ID:wangzhaosheng,项目名称:publicProject,代码行数:29,代码来源:ImageLoader.java

示例2: post

import com.android.volley.VolleyError; //导入依赖的package包/类
/**
 * 发送POST请求, 返回JSONObject对象数据
 * @param url    请求地址
 * @param listener  数据返回回调接口
 * @param params   POST请求参数
 */
public void post(String url, final Fdv_CallBackListener<JSONObject> listener,Map<String,String> params){
    JsonObjectRequest jsonObjectRequest=new JsonObjectRequest(Request.Method.POST, url, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            if(listener!=null){
                listener.onSuccessResponse(response);
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if(listener!=null){
                listener.onErrorResponse(error);
            }
        }
    });
    addRequest(jsonObjectRequest,params);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:Fdv_JsonObjectRequest.java

示例3: get

import com.android.volley.VolleyError; //导入依赖的package包/类
/**
 * 普通文本等信息 Get请求 无参数,或者get请求的参数直接拼接在URL上面
 * @param url  请求的地址
 * @param listener  数据请求返回接口回调
 */
public void get(String url, final Fdv_CallBackListener<String> listener){
    StringRequest stringRequest=new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            if(listener!=null){
                listener.onSuccessResponse(response);
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if(listener!=null){
                listener.onErrorResponse(error);
            }
        }
    });
    addRequest(stringRequest);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:Fdv_StringRequest.java

示例4: getImageListener

import com.android.volley.VolleyError; //导入依赖的package包/类
/**
 * The default implementation of ImageListener which handles basic functionality
 * of showing a default image until the network response is received, at which point
 * it will switch to either the actual image or the error image.
 * @param imageView The imageView that the listener is associated with.
 * @param defaultImageResId Default image resource ID to use, or 0 if it doesn't exist.
 * @param errorImageResId Error image resource ID to use, or 0 if it doesn't exist.
 */
public static ImageListener getImageListener(final ImageView view,
        final int defaultImageResId, final int errorImageResId) {
    return new ImageListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            if (errorImageResId != 0) {
                view.setImageResource(errorImageResId);
            }
        }

        @Override
        public void onResponse(ImageContainer response, boolean isImmediate) {
            if (response.getBitmap() != null) {
                view.setImageBitmap(response.getBitmap());
            } else if (defaultImageResId != 0) {
                view.setImageResource(defaultImageResId);
            }
        }
    };
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:29,代码来源:ImageLoader.java

示例5: onErrorResponse

import com.android.volley.VolleyError; //导入依赖的package包/类
@Override
public void onErrorResponse(VolleyError error) {
    Log.e(TAG, "onErrorResponse: " + error.toString());
    findViewById(R.id.articleLoader).setVisibility(View.GONE);

    ConnectivityManager cm = (ConnectivityManager) getBaseContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cm != null) {
        NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
        if (activeNetwork == null || !activeNetwork.isConnectedOrConnecting()) {
            // Display icon
            findViewById(R.id.noNetwork).setVisibility(View.VISIBLE);
            // Display permanent message
            Snackbar.make(findViewById(R.id.coordinatorArticle), getString(R.string.error_no_connection), Snackbar.LENGTH_INDEFINITE)
                    .setAction(getString(R.string.error_no_connection_retry), new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            REQUEST_QUEUE.add(new StringRequest(Request.Method.GET, shareLink, articleReceived, errorResponse));
                        }
                    }).show();
        }
    }
}
 
开发者ID:MBach,项目名称:LeMondeRssReader,代码行数:23,代码来源:ArticleActivity.java

示例6: requestJson

import com.android.volley.VolleyError; //导入依赖的package包/类
private void requestJson() {
    RequestManager.addRequest(new StringRequest("http://shop.boohee" +
            ".com/store/pages/story_json", new Listener<String>() {
        public void onResponse(String response) {
            try {
                List<Story> stories = Story.parseStory(response);
                if (stories != null && stories.size() > 0) {
                    WelcomeActivity.this.mDataList.clear();
                    WelcomeActivity.this.mDataList.addAll(stories);
                    WelcomeActivity.this.mAdapter.notifyDataSetChanged();
                    stories.clear();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            WelcomeActivity.this.setRefresh(false);
        }
    }, new ErrorListener() {
        public void onErrorResponse(VolleyError error) {
            Helper.showToast(error.toString());
            WelcomeActivity.this.setRefresh(false);
        }
    }), this);
    setRefresh(true);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:WelcomeActivity.java

示例7: requestPosts

import com.android.volley.VolleyError; //导入依赖的package包/类
public static void requestPosts(final onGetPosts callback){
    RequestQueue queue = Volley.newRequestQueue(App.getAppContext());
    StringRequest stringRequest = new StringRequest(
            Request.Method.GET,
            request.URL.LARAVEL_FEED_URL_LIVE,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    //finally return the posts list
                    VolleyResponseHelper responseHelper = new VolleyResponseHelper(response);
                    callback.onSuccess(responseHelper.getPosts());
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.d(App.Tag,"error : "+VolleyErrorHelper.getMessage(error));
                    callback.onFailure(error);
                }
            }
    );

    queue.add(stringRequest);
}
 
开发者ID:jamesddube,项目名称:LaravelNewsApp,代码行数:25,代码来源:rssRequest.java

示例8: getPosts

import com.android.volley.VolleyError; //导入依赖的package包/类
void getPosts() {
    String url = getArguments().getString(ARG_SECTION_URL);
    url = getString(R.string.tumblr_api_url, url);
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                JSONObject meta = response.getJSONObject("meta");
                if (meta.getInt("status") == 200) {
                    JSONArray posts = response.getJSONObject("response").getJSONArray("posts");
                    adapter.setPosts(posts);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.e("Activities", error.toString());
        }
    });

    VolleySingleton.getInstance(getContext()).addToRequestQueue(request);
}
 
开发者ID:ypicoleal,项目名称:FancyTab,代码行数:26,代码来源:MainActivity.java

示例9: getPosts

import com.android.volley.VolleyError; //导入依赖的package包/类
@Override
public void getPosts(@NonNull final GetPostsCallback getPostsCallback) {
    GsonRequest<PostList> gsonRequest = new GsonRequest<>(mUrl, PostList.class, null, new Response.Listener<PostList>() {
        @Override
        public void onResponse(PostList list) {
            getPostsCallback.onPostsLoaded(list.posts);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            getPostsCallback.onPostsNotAvailable(volleyError.getMessage(), volleyError.getCause());
            // + "\n" + volleyError.toString()
        }
    });

    mRequestQueue.add(gsonRequest);
}
 
开发者ID:googlecodelabs,项目名称:android-network-security-config,代码行数:18,代码来源:RemoteDataSource.java

示例10: checkErrorType

import com.android.volley.VolleyError; //导入依赖的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

示例11: requestGetMovies

import com.android.volley.VolleyError; //导入依赖的package包/类
private static void requestGetMovies(String url, final GetMoviesCallback callback,
                                         Activity activity) {
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    callback.successGetMovies(MoviesMapping.getMoviesFromResponse(response));
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    callback.errorGetMovies();
                }
            });
    VolleyHelper.getInstance(activity).addToRequestQueue(request, activity);
}
 
开发者ID:JonathandelaSen,项目名称:TheMovies,代码行数:18,代码来源:MoviesTask.java

示例12: volleyGetJsonObjectRequest

import com.android.volley.VolleyError; //导入依赖的package包/类
private String volleyGetJsonObjectRequest() {
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, Constant.JUHE_URL_GET, null, // 用post方式时,需更改为带请求参数的Object
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Toast.makeText(MainActivity.this, response.toString(), Toast.LENGTH_SHORT).show();
                }
    },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
                }
        });
    request.setTag(JSON_OBJECT_GET_TAG);
    MyApplication.getHttpQueues().add(request);
    return request.getTag().toString();
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:19,代码来源:MainActivity.java

示例13: setCountersDK

import com.android.volley.VolleyError; //导入依赖的package包/类
private static void setCountersDK(Context context) {
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, dkCountersURL, null, new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            try {
                dkUsersCount = response.get("users").toString();
                dkProjectsCount = response.get("projects").toString();
                dkTeamsCount = response.get("teams").toString();
                dkLookupsCount = response.get("lookups").toString();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            // log error?
        }
    });

    RequestQueue requestQueue = Volley.newRequestQueue(context);
    requestQueue.add(jsonObjectRequest);
}
 
开发者ID:KAEM,项目名称:android-widget,代码行数:26,代码来源:KaemWidget.java

示例14: requestGetCredits

import com.android.volley.VolleyError; //导入依赖的package包/类
private static void requestGetCredits(String url, final GetCastCallback callback,
                                         Activity activity) {
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    callback.successGetCast(MoviesMapping.getCast(response));
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    callback.errorGetCast();
                }
            });
    VolleyHelper.getInstance(activity).addToRequestQueue(request, activity);
}
 
开发者ID:JonathandelaSen,项目名称:TheMovies,代码行数:18,代码来源:MoviesTask.java

示例15: getActions

import com.android.volley.VolleyError; //导入依赖的package包/类
private void getActions(final DeviceDAO device) {
    Log.d(TAG, "TODO getActions");
    String uri = Uri.parse(String.format("http://%s:%s/", device.getIP(), device.getPort()))
            .buildUpon().build().toString();
    String credentials = device.getUsername() + ":" + device.getPassword();
    byte[] t = credentials.getBytes();
    byte[] auth = Base64.encode(t, Base64.DEFAULT);
    final String basicAuthValue = new String(auth);
    requestQueue.add(new StringRequest(Request.Method.POST, uri, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> params = new HashMap<>();
            params.put("Authorization", "Basic " + basicAuthValue);
            params.put("Connection", "close");
            return params;
        }
    });
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:28,代码来源:DeviceActionsResolver.java


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