14 | * this callback help you resize the height of RecyclerView. this is useful while ScrollView nested 15 | * RecyclerView with GridLayoutManager or StaggeredGridLayoutManager. but in layout xml you should define 16 | * a opportune height to RecyclerView, not wrap_content. 17 | *
18 | * Created by heaven7 on 2016/1/14. 19 | * @since 1.7.5 20 | */ 21 | public class ResizeHeightPostCallbackerrorCode != OK
. */
61 | public final VolleyError error;
62 |
63 | /** True if this response was a soft-expired one and a second one MAY be coming. */
64 | public boolean intermediate = false;
65 |
66 | /**
67 | * Returns whether this response is considered successful.
68 | */
69 | public boolean isSuccess() {
70 | return error == null;
71 | }
72 |
73 |
74 | private Response(T result, Cache.Entry cacheEntry) {
75 | this.result = result;
76 | this.cacheEntry = cacheEntry;
77 | this.error = null;
78 | }
79 |
80 | private Response(VolleyError error) {
81 | this.result = null;
82 | this.cacheEntry = null;
83 | this.error = error;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/ResponseDelivery.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.volley;
18 |
19 | public interface ResponseDelivery {
20 | /**
21 | * Parses a response from the network or cache and delivers it.
22 | */
23 | public void postResponse(Request> request, Response> response);
24 |
25 | /**
26 | * Parses a response from the network or cache and delivers it. The provided
27 | * Runnable will be executed after delivery.
28 | */
29 | public void postResponse(Request> request, Response> response, Runnable runnable);
30 |
31 | /**
32 | * Posts an error for the given request.
33 | */
34 | public void postError(Request> request, VolleyError error);
35 | }
36 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/RetryPolicy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.volley;
18 |
19 | /**
20 | * Retry policy for a request.
21 | */
22 | public interface RetryPolicy {
23 |
24 | /**
25 | * Returns the current timeout (used for logging).
26 | */
27 | public int getCurrentTimeout();
28 |
29 | /**
30 | * Returns the current retry count (used for logging).
31 | */
32 | public int getCurrentRetryCount();
33 |
34 | /**
35 | * Prepares for the next retry by applying a backoff to the timeout.
36 | * @param error The error code of the last attempt.
37 | * @throws VolleyError In the event that the retry could not be performed (for example if we
38 | * ran out of attempts), the passed in error is thrown.
39 | */
40 | public void retry(VolleyError error) throws VolleyError;
41 | }
42 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/ServerError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.volley;
18 |
19 | import com.android.volley.NetworkResponse;
20 | import com.android.volley.VolleyError;
21 |
22 | /**
23 | * Indicates that the error responded with an error response.
24 | */
25 | @SuppressWarnings("serial")
26 | public class ServerError extends VolleyError {
27 | public ServerError(NetworkResponse networkResponse) {
28 | super(networkResponse);
29 | }
30 |
31 | public ServerError() {
32 | super();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/TimeoutError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.volley;
18 |
19 | /**
20 | * Indicates that the connection or the socket timed out.
21 | */
22 | @SuppressWarnings("serial")
23 | public class TimeoutError extends VolleyError { }
24 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/VolleyError.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.android.volley;
18 |
19 | /**
20 | * Exception style class encapsulating Volley errors
21 | */
22 | @SuppressWarnings("serial")
23 | public class VolleyError extends Exception {
24 | public final NetworkResponse networkResponse;
25 |
26 | public VolleyError() {
27 | networkResponse = null;
28 | }
29 |
30 | public VolleyError(NetworkResponse response) {
31 | networkResponse = response;
32 | }
33 |
34 | public VolleyError(String exceptionMessage) {
35 | super(exceptionMessage);
36 | networkResponse = null;
37 | }
38 |
39 | public VolleyError(String exceptionMessage, Throwable reason) {
40 | super(exceptionMessage, reason);
41 | networkResponse = null;
42 | }
43 |
44 | public VolleyError(Throwable cause) {
45 | super(cause);
46 | networkResponse = null;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/data/ApiParams.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by Storm Zhang, Feb 13, 2014.
3 | */
4 |
5 | package com.android.volley.data;
6 |
7 | import java.util.HashMap;
8 |
9 | public class ApiParams extends HashMap18 | * Example: 19 | *
{@code 20 | * public abstract void setTextColor(@ColorInt int color); 21 | * }22 | */ 23 | @Retention(CLASS) 24 | @Target({PARAMETER,METHOD,LOCAL_VARIABLE,FIELD}) 25 | public @interface ColorInt { 26 | } -------------------------------------------------------------------------------- /common-utils/volley_with_extra/src/main/java/com/android/volley/extra/Corner.java: -------------------------------------------------------------------------------- 1 | package com.android.volley.extra; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.RetentionPolicy; 5 | 6 | @Retention(RetentionPolicy.SOURCE) 7 | @IntDef({ 8 | Corner.TOP_LEFT, Corner.TOP_RIGHT, 9 | Corner.BOTTOM_LEFT, Corner.BOTTOM_RIGHT 10 | }) 11 | public @interface Corner { 12 | int TOP_LEFT = 0; 13 | int TOP_RIGHT = 1; 14 | int BOTTOM_RIGHT = 2; 15 | int BOTTOM_LEFT = 3; 16 | } 17 | -------------------------------------------------------------------------------- /common-utils/volley_with_extra/src/main/java/com/android/volley/extra/ImageParam.java: -------------------------------------------------------------------------------- 1 | package com.android.volley.extra; 2 | 3 | public class ImageParam { 4 | 5 | public float roundSize; 6 | public Type type; 7 | public int defaultImageResId; 8 | public int errorImageResId; 9 | 10 | /*public*/ ImageParam(){} 11 | public ImageParam(float roundSize, Type type) { 12 | super(); 13 | this.roundSize = roundSize; 14 | this.type = type; 15 | } 16 | 17 | public void setDefaultImageResId(int resId){ 18 | this.defaultImageResId = resId; 19 | } 20 | 21 | public void setErrorImageResId(int resId){ 22 | this.errorImageResId = resId; 23 | } 24 | 25 | public static enum Type{ 26 | 27 | Round(1) , Circle(2); 28 | final int value; 29 | 30 | private Type(int value) { 31 | this.value = value; 32 | } 33 | } 34 | public static class Builder{ 35 | private final ImageParam mParam = new ImageParam(); 36 | 37 | /** indicate the four corner of image will be round*/ 38 | public Builder round(float roundSize){ 39 | mParam.roundSize = roundSize; 40 | if(mParam.type != Type.Round){ 41 | mParam.type = Type.Round; 42 | } 43 | return this; 44 | } 45 | /** set the image to circle.the radio is the width or height which is lower.*/ 46 | public Builder circle(){ 47 | if(mParam.type != Type.Circle){ 48 | mParam.type = Type.Circle; 49 | } 50 | return this; 51 | } 52 | /** @see {@link ExpandNetworkImageView#setDefaultImageResId(int)} */ 53 | public Builder placeholder(int defaultImageResId){ 54 | mParam.defaultImageResId = defaultImageResId; 55 | return this; 56 | } 57 | /** @see {@link ExpandNetworkImageView#setErrorImageResId(int)} */ 58 | public Builder error(int errorImageResId){ 59 | mParam.errorImageResId = errorImageResId; 60 | return this; 61 | } 62 | 63 | public ImageParam create(){ 64 | return mParam; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /common-utils/volley_with_extra/src/main/java/com/android/volley/extra/IntDef.java: -------------------------------------------------------------------------------- 1 | package com.android.volley.extra; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.ANNOTATION_TYPE; 7 | import static java.lang.annotation.RetentionPolicy.SOURCE; 8 | 9 | @Retention(SOURCE) 10 | @Target({ANNOTATION_TYPE}) 11 | public @interface IntDef { 12 | /** Defines the allowed constants for this element */ 13 | long[] value() default {}; 14 | 15 | /** Defines whether the constants can be used as a flag, or just as an enum (the default) */ 16 | boolean flag() default false; 17 | } -------------------------------------------------------------------------------- /common-utils/volley_with_extra/src/main/java/com/android/volley/extra/MultipartRequest.java: -------------------------------------------------------------------------------- 1 | package com.android.volley.extra; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.UnsupportedEncodingException; 6 | 7 | import android.util.Log; 8 | 9 | import com.android.volley.NetworkResponse; 10 | import com.android.volley.Request; 11 | import com.android.volley.Response; 12 | import com.android.volley.toolbox.HttpHeaderParser; 13 | /** 14 | * MultipartRequest,返回的结果是String格式的 15 | * @author mrsimple 16 | */ 17 | public class MultipartRequest extends Request
14 | * This is a marker annotation and it has no specific attributes.
15 | */
16 | @Retention(CLASS)
17 | @Target({METHOD, PARAMETER, FIELD})
18 | public @interface NonNull {
19 | }
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/extra/util/Method.java:
--------------------------------------------------------------------------------
1 | package com.android.volley.extra.util;
2 |
3 | import com.android.volley.Request;
4 |
5 | /***
6 | * wrap volley's request method
7 | */
8 | public interface Method{
9 | int GET = Request.Method.GET + 1;
10 | int POST = Request.Method.POST + 1;
11 | int PUT = Request.Method.PUT + 1;
12 | int DELETE = Request.Method.DELETE + 1;
13 | int HEAD = Request.Method.HEAD + 1;
14 | int OPTIONS = Request.Method.OPTIONS + 1;
15 | int TRACE = Request.Method.TRACE + 1;
16 | int PATCH = Request.Method.PATCH + 1;
17 | }
18 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/extra/util/MethodDef.java:
--------------------------------------------------------------------------------
1 | package com.android.volley.extra.util;
2 |
3 | import android.support.annotation.IntDef;
4 |
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 |
8 | @IntDef(value = {
9 | Method.DELETE,
10 | Method.GET,
11 | Method.POST,
12 | Method.PUT,
13 | Method.HEAD,
14 | Method.OPTIONS,
15 | Method.PATCH,
16 | Method.TRACE,
17 | })
18 | @Retention(RetentionPolicy.CLASS)
19 | public @interface MethodDef {
20 | }
21 |
--------------------------------------------------------------------------------
/common-utils/volley_with_extra/src/main/java/com/android/volley/extra/util/Pairs.java:
--------------------------------------------------------------------------------
1 | package com.android.volley.extra.util;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class Pairs {
7 | List