{
7 | public String getTitle(T t);
8 |
9 | public String getContent(T t);
10 |
11 | public String getDownURL(T t);
12 | public String getIncrementDownURL(T t);
13 |
14 | public boolean isMustUpdate(T t);
15 |
16 | public boolean isShowDialog(T t1);
17 |
18 | public String getResultDesConstants(String str);
19 |
20 | public String getDownApkVersionName(T t);
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/java/com/async/apkupdate/listener/NoticeListener.java:
--------------------------------------------------------------------------------
1 | package com.async.apkupdate.listener;
2 |
3 | import java.io.File;
4 | import java.io.Serializable;
5 |
6 | /**
7 | * Created by admin on 2016/10/20.
8 | */
9 | public interface NoticeListener extends Serializable {
10 | public void start();
11 | public void progress(int progress);
12 | public void currentDown(long current ,long total);
13 | public void finish();
14 | public void success(File file);
15 | }
16 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/java/com/async/apkupdate/listener/OKListener.java:
--------------------------------------------------------------------------------
1 | package com.async.apkupdate.listener;
2 |
3 | /**
4 | * Created by admin on 2016/10/19.
5 | */
6 | public interface OKListener {
7 | public void OK();
8 | public void incrementOk();
9 | }
10 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/java/com/async/apkupdate/utils/CloseUtils.java:
--------------------------------------------------------------------------------
1 | package com.async.apkupdate.utils;
2 |
3 | import java.io.Closeable;
4 | import java.io.IOException;
5 |
6 | /**
7 | * Created by admin on 2017-04-13.
8 | */
9 |
10 | public class CloseUtils {
11 | private CloseUtils() {
12 | throw new UnsupportedOperationException("u can't instantiate me...");
13 | }
14 |
15 | /**
16 | * 关闭IO
17 | *
18 | * @param closeables closeables
19 | */
20 | public static void closeIO(Closeable... closeables) {
21 | if (closeables == null) return;
22 | for (Closeable closeable : closeables) {
23 | if (closeable != null) {
24 | try {
25 | closeable.close();
26 | } catch (IOException e) {
27 | e.printStackTrace();
28 | }
29 | }
30 | }
31 | }
32 |
33 | /**
34 | * 安静关闭IO
35 | *
36 | * @param closeables closeables
37 | */
38 | public static void closeIOQuietly(Closeable... closeables) {
39 | if (closeables == null) return;
40 | for (Closeable closeable : closeables) {
41 | if (closeable != null) {
42 | try {
43 | closeable.close();
44 | } catch (IOException ignored) {
45 | }
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/java/com/async/apkupdate/utils/Intall.java:
--------------------------------------------------------------------------------
1 | package com.async.apkupdate.utils;
2 |
3 | import android.app.Application;
4 | import android.content.Intent;
5 | import android.net.Uri;
6 |
7 | import java.io.File;
8 |
9 | /**
10 | * Created by admin on 2017-04-11.
11 | */
12 |
13 | public class Intall {
14 | public static void install(Application application,File file){
15 | Intent intent = new Intent();
16 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
17 | intent.setAction(Intent.ACTION_VIEW);
18 | intent.setDataAndType(Uri.fromFile(file),
19 | "application/vnd.android.package-archive");
20 | application.startActivity(intent);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/java/com/async/apkupdate/utils/MemoryConstants.java:
--------------------------------------------------------------------------------
1 | package com.async.apkupdate.utils;
2 |
3 | /**
4 | * Created by admin on 2017-04-13.
5 | */
6 |
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 |
10 | /**
11 | *
12 | * author: Blankj
13 | * blog : http://blankj.com
14 | * time : 2017/03/13
15 | * desc : 存储相关常量
16 | *
17 | */
18 | public final class MemoryConstants {
19 |
20 | /**
21 | * Byte与Byte的倍数
22 | */
23 | public static final int BYTE = 1;
24 | /**
25 | * KB与Byte的倍数
26 | */
27 | public static final int KB = 1024;
28 | /**
29 | * MB与Byte的倍数
30 | */
31 | public static final int MB = 1048576;
32 | /**
33 | * GB与Byte的倍数
34 | */
35 | public static final int GB = 1073741824;
36 |
37 |
38 | }
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/java/com/async/apkupdate/utils/NetWorkType/Constants.java:
--------------------------------------------------------------------------------
1 | package com.async.apkupdate.utils.NetWorkType;
2 |
3 | /**
4 | * Created by admin on 2017-04-11.
5 | */
6 | public class Constants {
7 | /**
8 | * Unknown network class
9 | */
10 | public static final int NETWORK_CLASS_UNKNOWN = 0;
11 |
12 | /**
13 | * wifi net work
14 | */
15 | public static final int NETWORK_WIFI = 1;
16 |
17 | /**
18 | * "2G" networks
19 | */
20 | public static final int NETWORK_CLASS_2_G = 2;
21 |
22 | /**
23 | * "3G" networks
24 | */
25 | public static final int NETWORK_CLASS_3_G = 3;
26 |
27 | /**
28 | * "4G" networks
29 | */
30 | public static final int NETWORK_CLASS_4_G = 4;
31 |
32 | }
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/java/com/async/apkupdate/utils/SpUtils.java:
--------------------------------------------------------------------------------
1 | package com.async.apkupdate.utils;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 |
6 | import android.content.SharedPreferences;
7 |
8 |
9 |
10 | public class SpUtils {
11 | private static String name = "ApkUpdate";
12 |
13 | public static void save(Application application, String key, String value) {
14 | SharedPreferences mySharedPreferences = application.getSharedPreferences(name,
15 | Activity.MODE_PRIVATE);
16 | SharedPreferences.Editor editor = mySharedPreferences.edit();
17 | editor.putString(key, value);
18 | editor.commit();
19 |
20 |
21 | }
22 | public static String get(Application application,String key) {
23 | SharedPreferences mySharedPreferences = application.getSharedPreferences(name,
24 | Activity.MODE_PRIVATE);
25 | return mySharedPreferences.getString(key, "");
26 | }
27 | public static void delAll(Application application) {
28 | SharedPreferences mySharedPreferences = application.getSharedPreferences(name,
29 | Activity.MODE_PRIVATE);
30 | SharedPreferences.Editor editor = mySharedPreferences.edit();
31 | editor.clear();
32 | editor.commit();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 |
3 | include $(CLEAR_VARS)
4 |
5 | LOCAL_MODULE := apkupdateincrementlib
6 | LOCAL_SRC_FILES := bzip2/bzlib.c \
7 | bzip2/crctable.c \
8 | bzip2/compress.c \
9 | bzip2/decompress.c \
10 | bzip2/randtable.c \
11 | bzip2/blocksort.c \
12 | bzip2/huffman.c \
13 | com_async_apkupdate_BsdiffUtils.c
14 |
15 |
16 | LOCAL_LDLIBS := -lz -llog
17 |
18 | include $(BUILD_SHARED_LIBRARY)
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jni/bzip2/readMe.txt:
--------------------------------------------------------------------------------
1 | bzip2包中文件来来自:
2 | http://www.bzip.org/downloads.html
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jni/com_async_apkupdate_BsdiffUtils.h:
--------------------------------------------------------------------------------
1 | /* DO NOT EDIT THIS FILE - it is machine generated */
2 | #include
3 | /* Header for class com_async_apkupdate_BsdiffUtils */
4 |
5 | #ifndef _Included_com_async_apkupdate_BsdiffUtils
6 | #define _Included_com_async_apkupdate_BsdiffUtils
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 | /*
11 | * Class: com_async_apkupdate_BsdiffUtils
12 | * Method: genDiff
13 | * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
14 | */
15 | JNIEXPORT jint JNICALL Java_com_async_apkupdate_BsdiffUtils_genDiff
16 | (JNIEnv *, jobject, jstring, jstring, jstring);
17 |
18 | /*
19 | * Class: com_async_apkupdate_BsdiffUtils
20 | * Method: patch
21 | * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
22 | */
23 | JNIEXPORT jint JNICALL Java_com_async_apkupdate_BsdiffUtils_patch
24 | (JNIEnv *, jobject, jstring, jstring, jstring);
25 |
26 | #ifdef __cplusplus
27 | }
28 | #endif
29 | #endif
30 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jniLibs/arm64-v8a/libapkupdateincrementlib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/jniLibs/arm64-v8a/libapkupdateincrementlib.so
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jniLibs/armeabi-v7a/libapkupdateincrementlib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/jniLibs/armeabi-v7a/libapkupdateincrementlib.so
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jniLibs/armeabi/libapkupdateincrementlib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/jniLibs/armeabi/libapkupdateincrementlib.so
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jniLibs/mips/libapkupdateincrementlib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/jniLibs/mips/libapkupdateincrementlib.so
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jniLibs/mips64/libapkupdateincrementlib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/jniLibs/mips64/libapkupdateincrementlib.so
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jniLibs/x86/libapkupdateincrementlib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/jniLibs/x86/libapkupdateincrementlib.so
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/jniLibs/x86_64/libapkupdateincrementlib.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/jniLibs/x86_64/libapkupdateincrementlib.so
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/res/drawable/a55533b2ef5af49936a655f46e584b14_1_zjj7188.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/res/drawable/a55533b2ef5af49936a655f46e584b14_1_zjj7188.jpg
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/res/drawable/cancle_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
6 |
7 |
8 |
9 |
10 |
11 |
12 | -
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/res/drawable/corner_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/appupdate/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ApkUpdate
3 |
4 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/appupdate/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\as_sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/src/androidTest/java/com/uyin/asynchttp_android/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.uyin.asynchttp_android;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/src/main/java/com/async/http/android/FaileAndResponse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.android;
2 |
3 | import com.async.http.entity.ResponseBody;
4 |
5 | /**
6 | * Created by admin on 2016-11-05.
7 | */
8 | public class FaileAndResponse {
9 | public Exception e;
10 | public ResponseBody responseBody;
11 |
12 | public FaileAndResponse(Exception e,ResponseBody responseBody){
13 | this.e=e;
14 | this.responseBody=responseBody;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/src/main/java/com/async/http/android/ProgressBean.java:
--------------------------------------------------------------------------------
1 | package com.async.http.android;
2 |
3 | /**
4 | * Created by admin on 2016-11-05.
5 | */
6 | class ProgressBean {
7 |
8 | public long current;
9 | public long currentFileTotal;
10 | public long total;
11 |
12 |
13 |
14 |
15 |
16 | public ProgressBean(long current, long currentFileTotal, long total) {
17 | this.current=current;
18 | this.currentFileTotal=currentFileTotal;
19 | this.total=total;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/src/main/java/com/async/http/android/RequestProgress.java:
--------------------------------------------------------------------------------
1 | package com.async.http.android;
2 |
3 | /**
4 | * Created by admin on 2016-11-05.
5 | */
6 | class RequestProgress {
7 |
8 | public final static int START = 1;
9 | public final static int CURRENT = 2;
10 | public final static int SUCCESS = 3;
11 | public final static int FINISH = 4;
12 | public final static int FAIL = 5;
13 |
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/src/main/java/com/async/http/android/UploadCallBack.java:
--------------------------------------------------------------------------------
1 | package com.async.http.android;
2 |
3 | import android.os.Handler;
4 | import android.os.Message;
5 |
6 | import com.async.http.callback.UploadProgrossCallback;
7 | import com.async.http.entity.ResponseBody;
8 |
9 |
10 | /**
11 | * Created by admin on 2016-11-05.
12 | */
13 | class UploadCallBack extends DownCallBack implements UploadProgrossCallback> {
14 |
15 | Handler handler;
16 | int what;
17 | public UploadCallBack(Handler handler,int what){
18 | super(handler,what);
19 | this.handler=handler;
20 | this.what=what;
21 | }
22 |
23 | @Override
24 | public void success(ResponseBody result) {
25 | super.success(result);
26 | }
27 |
28 | @Override
29 | public void upload_current(long current, long currentFileTotal, long total) {
30 | Message message=new Message();
31 | message.obj=new ProgressBean(current, currentFileTotal, total);
32 | message.what=what;
33 | message.arg1=RequestProgress.CURRENT;
34 | handler.sendMessage(message);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp-android/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Asynchttp-android
3 |
4 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By defaults, the flags in this file are appended to flags specified
3 | # in D:\as_sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/Interceptor2/RequestInterceptor2.java:
--------------------------------------------------------------------------------
1 | package com.async.http.Interceptor2;
2 |
3 | import com.async.http.request2.BaseRequest;
4 |
5 | public class RequestInterceptor2 {
6 |
7 | private RequestInterceptorActionInterface requestInterceptor;
8 | RequestInterceptor2 requestInterceptor2;
9 |
10 | public RequestInterceptor2(
11 | RequestInterceptorActionInterface requestInterceptor) {
12 |
13 | this.requestInterceptor = requestInterceptor;
14 | }
15 |
16 | public RequestInterceptor2 setRequestInterceptor(
17 | RequestInterceptorActionInterface requestInterceptor,
18 | RequestInterceptor2 requestInterceptor2) {
19 | if (this.requestInterceptor == null)
20 | this.requestInterceptor = requestInterceptor;
21 | this.requestInterceptor2 = requestInterceptor2;
22 | return this;
23 | }
24 |
25 | public RequestInterceptor2 setRequestInterceptor2(
26 | RequestInterceptor2 requestInterceptor2) {
27 | this.requestInterceptor2 = requestInterceptor2;
28 | return this;
29 | }
30 |
31 | public BaseRequest interceptor(BaseRequest baseRequest)
32 | throws Exception {
33 | if (requestInterceptor2 != null) {
34 | baseRequest = requestInterceptor2.interceptor(baseRequest);
35 | }
36 | if (requestInterceptor != null) {
37 | return requestInterceptor.interceptorAction(baseRequest);
38 | }
39 | return baseRequest;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/Interceptor2/RequestInterceptorActionInterface.java:
--------------------------------------------------------------------------------
1 | package com.async.http.Interceptor2;
2 |
3 | import com.async.http.request2.BaseRequest;
4 |
5 | public interface RequestInterceptorActionInterface {
6 | public BaseRequest interceptorAction(BaseRequest baserequest) throws Exception;
7 | }
8 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/Interceptor2/ResponseInterceptor2.java:
--------------------------------------------------------------------------------
1 | package com.async.http.Interceptor2;
2 |
3 | public class ResponseInterceptor2 {
4 | private ResponseInterceptorActionInterface responseInterceptorActionInterface;
5 | private ResponseInterceptor2 responseInterceptor2;
6 |
7 | public ResponseInterceptor2(
8 | ResponseInterceptorActionInterface responseInterceptorActionInterface) {
9 | // TODO Auto-generated constructor stub
10 | this.responseInterceptorActionInterface = responseInterceptorActionInterface;
11 |
12 | }
13 |
14 | public ResponseInterceptor2 setResponseInterceptor(
15 | ResponseInterceptor2 responseInterceptor) {
16 | if (this.responseInterceptor2 == null)
17 | this.responseInterceptor2 = responseInterceptor;
18 | else
19 | this.responseInterceptor2
20 | .setResponseInterceptor(responseInterceptor);
21 | return responseInterceptor;
22 | }
23 |
24 | public ResponseInterceptor2 setResponseInterceptor2(
25 | ResponseInterceptor2 responseInterceptor2) {
26 | this.responseInterceptor2 = responseInterceptor2;
27 | return this;
28 | }
29 |
30 | public T interceptor(T t) throws Exception {
31 | if (responseInterceptor2 != null) {
32 | t = responseInterceptor2.interceptor(t);
33 |
34 | }
35 | if (responseInterceptorActionInterface != null) {
36 | return responseInterceptorActionInterface.interceptorAction(t);
37 | }
38 | return t;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/Interceptor2/ResponseInterceptorActionInterface.java:
--------------------------------------------------------------------------------
1 | package com.async.http.Interceptor2;
2 |
3 |
4 | public interface ResponseInterceptorActionInterface {
5 |
6 | public T interceptorAction(T t) throws Exception;
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/JsonConvertInterface.java:
--------------------------------------------------------------------------------
1 | package com.async.http;
2 |
3 | import java.lang.reflect.Type;
4 |
5 | /**
6 | * Created by ML on 2018/3/15.
7 | */
8 |
9 | public interface JsonConvertInterface {
10 |
11 | public String serialize(Object object) ;
12 |
13 | public T deserialize(String json, Class clz);
14 | public T deserialize(String json, Type type);
15 |
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/DELETE.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface DELETE {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/DOWNLOAD.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface DOWNLOAD {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 |
21 | boolean MultitierDownload()default true;
22 |
23 |
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/GET.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface GET {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/HEAD.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface HEAD {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/JSONPOST.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a POST request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface JSONPOST {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/OPTIONS.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface OPTIONS {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/PATCH.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface PATCH {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/POST.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a POST request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface POST {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/PUT.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface PUT {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/TRACE.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface TRACE {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/UPLOAD.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.METHOD;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a GET request. */
11 | @Documented
12 | @Target(METHOD)
13 | @Retention(RUNTIME)
14 | public @interface UPLOAD {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/param/Param.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation.param;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.PARAMETER;
8 | import static java.lang.annotation.ElementType.METHOD;
9 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
10 |
11 | /** Make a POST request. */
12 | @Documented
13 | @Target(PARAMETER)
14 | @Retention(RUNTIME)
15 | public @interface Param {
16 | /**
17 | * A relative or absolute path, or full URL of the endpoint.
18 | *
19 | */
20 | String value() default "";
21 | }
22 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/annotation/param/PathParam.java:
--------------------------------------------------------------------------------
1 | package com.async.http.annotation.param;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.Target;
6 |
7 | import static java.lang.annotation.ElementType.PARAMETER;
8 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
9 |
10 | /** Make a POST request. */
11 | @Documented
12 | @Target(PARAMETER)
13 | @Retention(RUNTIME)
14 | public @interface PathParam {
15 | /**
16 | * A relative or absolute path, or full URL of the endpoint.
17 | *
18 | */
19 | String value() default "";
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/callback/DownProgrossCallback.java:
--------------------------------------------------------------------------------
1 | package com.async.http.callback;
2 |
3 | import com.async.http.entity.ResponseBody;
4 |
5 | public interface DownProgrossCallback extends
6 | HttpCallBack {
7 |
8 |
9 |
10 | public void download_current(long current, long total);
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/callback/HttpCallBack.java:
--------------------------------------------------------------------------------
1 | package com.async.http.callback;
2 |
3 | public interface HttpCallBack {
4 | /**
5 | * 获取网络数据总量
6 | * @param total
7 | */
8 | public void start();
9 | public void finish();
10 | public void success(ResponseBody result);
11 | public void fail(Exception e,ResponseBody request);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/callback/UploadProgrossCallback.java:
--------------------------------------------------------------------------------
1 | package com.async.http.callback;
2 |
3 | import com.async.http.entity.ResponseBody;
4 |
5 | public interface UploadProgrossCallback extends
6 | HttpCallBack {
7 |
8 |
9 | public void upload_current(long current,long currentFileTotal ,long total);
10 |
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/client/AsyncHttpClient.java:
--------------------------------------------------------------------------------
1 | package com.async.http.client;
2 |
3 | import java.io.InputStream;
4 | import java.io.OutputStream;
5 |
6 | import com.async.http.entity.ResponseBody;
7 | import com.async.http.request2.BaseRequest;
8 |
9 |
10 | public interface AsyncHttpClient {
11 |
12 | public void write(OutputStream out, BaseRequest> req)throws Exception;
13 |
14 | public T read(BaseRequest request, InputStream input, long len) throws Exception;
15 |
16 | public ResponseBody request(BaseRequest request, ResponseBody responseBody) throws Exception;
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/client/BoundaryBuilder.java:
--------------------------------------------------------------------------------
1 | package com.async.http.client;
2 |
3 | import java.util.Random;
4 |
5 | public class BoundaryBuilder {
6 |
7 | private String Enter = "\r\n";
8 |
9 | private String start_tag;
10 |
11 | private String end_tag;
12 |
13 | private String boundary;
14 |
15 | public BoundaryBuilder() {
16 | createBoundary();
17 | }
18 |
19 | void createBoundary() {
20 | String base = "abcdefghijklmnopqrstuvwxyz0123456789";
21 | Random random = new Random();
22 | StringBuffer sb = new StringBuffer();
23 | for (int i = 0; i < 30; i++) {
24 | int number = random.nextInt(base.length());
25 | sb.append(base.charAt(number));
26 | }
27 | boundary = sb.toString();
28 |
29 | start_tag = "--" + boundary;
30 | end_tag = "--" + boundary + "--" + Enter;
31 | }
32 |
33 | public String getBoundary() {
34 |
35 | return boundary;
36 | }
37 |
38 | public String getEnd_tag() {
39 | return end_tag;
40 | }
41 |
42 | public String getStart_tag() {
43 | return start_tag;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/client/HttpMethod.java:
--------------------------------------------------------------------------------
1 | package com.async.http.client;
2 |
3 | public enum HttpMethod {
4 |
5 | /**
6 | * get
7 | */
8 | Get("GET"),
9 | /**
10 | * get http header only
11 | */
12 | Head("HEAD"),
13 | /**
14 | * debug
15 | */
16 | Trace("TRACE"),
17 | /**
18 | * query
19 | */
20 | Options("OPTIONS"),
21 | /**
22 | * delete
23 | */
24 | Delete("DELETE"),
25 | /**
26 | * update
27 | */
28 | Put("PUT"),
29 | /**
30 | * add
31 | */
32 | Post("POST"),
33 | /**
34 | * incremental update
35 | */
36 | Patch("PATCH");
37 |
38 | private String methodName;
39 |
40 | HttpMethod(String methodName) {
41 | this.methodName = methodName;
42 | }
43 |
44 | public String getMethodName() {
45 | return methodName;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/constant/Charsets.java:
--------------------------------------------------------------------------------
1 | package com.async.http.constant;
2 |
3 | import java.nio.charset.Charset;
4 |
5 | public class Charsets {
6 | public static final String ASCII = "ASCII";
7 | public static final String US_ASCII = "US-ASCII";
8 |
9 | public static final String ISO_8859_1 = "ISO-8859-1";
10 |
11 | public static final String Unicode = "Unicode";
12 |
13 | public static final String BIG5 = "BIG5";
14 |
15 | public static final String UTF_8 = "UTF-8";
16 | public static final String UTF_16 = "UTF-16";
17 |
18 | public static final String GB2312 = "GB2312";
19 | public static final String GBK = "GBK";
20 | public static final String GB18030 = "GB18030";
21 |
22 |
23 | public static final String POST="POST";
24 | public static final String GET="GET";
25 | public static final String DELETE="delete";
26 | public static final String PUT="PUT";
27 |
28 |
29 |
30 | public static Charset getCharset(String charsetName){
31 | return Charset.forName(charsetName);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/constant/Constents.java:
--------------------------------------------------------------------------------
1 | package com.async.http.constant;
2 |
3 | public class Constents {
4 | public static final String ENCODE_DEFAULT="utf-8";
5 |
6 | public static final String TYPE_TEXT = "text/plain";
7 | public static final String TYPE_IMAGE = "text/image";
8 |
9 | public static final String CONTENT_TYPE = "Content-Type";
10 |
11 |
12 | public static final String TYPE_STREAM = "application/octet-stream";
13 | public static final String TYPE_FORM_URLENCODE = "application/x-www-form-urlencoded";
14 | public static final String TYPE_FORM_DATA = "multipart/form-data";
15 | public final static String BOUNDARY_PARAM = "; boundary=";
16 |
17 |
18 |
19 |
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/constant/RequestType.java:
--------------------------------------------------------------------------------
1 | package com.async.http.constant;
2 |
3 | public final class RequestType {
4 | public static final int POST=12;
5 | public static final int GET=13;
6 | }
7 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/entity/RequestBody.java:
--------------------------------------------------------------------------------
1 | package com.async.http.entity;
2 |
3 | import java.util.Hashtable;
4 | import java.util.Set;
5 |
6 | public class RequestBody {
7 |
8 | private Hashtable table;
9 |
10 | public RequestBody() {
11 | if (table == null)
12 | table = new Hashtable();
13 |
14 | }
15 |
16 | public final void addParam(String key, String param) {
17 | table.put(key, param);
18 |
19 | }
20 |
21 | public final Object queryParamByKey(String key) {
22 | return table.get(key);
23 | }
24 |
25 | public final Set getParamKeys() {
26 | return table.entrySet();
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/exception/CancledOrInterruptedExcetion.java:
--------------------------------------------------------------------------------
1 | package com.async.http.exception;
2 |
3 | public class CancledOrInterruptedExcetion extends HttpException{
4 |
5 | /**
6 | * 用户取消请求或打断请求
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public CancledOrInterruptedExcetion() {
11 | // TODO Auto-generated constructor stub
12 | super("the request cancled by user");
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/exception/HttpException.java:
--------------------------------------------------------------------------------
1 | package com.async.http.exception;
2 |
3 | public abstract class HttpException extends Exception {
4 |
5 | public HttpException() {
6 | }
7 |
8 | public HttpException(String name) {
9 | super(name);
10 | }
11 |
12 | public HttpException(String name, Throwable cause) {
13 | super(name, cause);
14 | }
15 |
16 | public HttpException(Throwable cause) {
17 | super(cause);
18 | }
19 |
20 | @Override
21 | public String toString() {
22 | // TODO Auto-generated method stub
23 | StringBuilder sb = new StringBuilder();
24 | sb.append("--------------------");
25 | sb.append("" + getClass().getName());
26 | sb.append("--------------------");
27 | sb.append("\n");
28 | sb.append(getMessage());
29 | sb.append("\n");
30 | sb.append("--------------------");
31 | sb.append("end");
32 | sb.append("--------------------");
33 |
34 | return sb.toString();
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/handler/TaskHandler.java:
--------------------------------------------------------------------------------
1 | package com.async.http.handler;
2 |
3 |
4 |
5 | /**
6 | * 任务的句柄
7 | *
8 | * @author ML
9 | *
10 | */
11 |
12 | public interface TaskHandler {
13 |
14 | public void stop();
15 | public void excute();
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/Creator.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy;
2 |
3 | import com.async.http.proxy.entity.CreatorBeans;
4 | import com.async.http.proxy.reflex.Analysis;
5 | import com.async.http.proxy.reflex.AssemblyDevice;
6 | import com.async.http.proxy.reflex.ProxyCache;
7 |
8 | import java.lang.reflect.InvocationHandler;
9 | import java.lang.reflect.Method;
10 | import java.lang.reflect.Proxy;
11 |
12 | /**
13 | * 创建者
14 | * @author ML
15 | *
16 | */
17 |
18 | public class Creator {
19 |
20 | public static T creator(final Class tclass)
21 | throws Exception {
22 |
23 | return (T) Proxy.newProxyInstance(tclass.getClassLoader(),
24 | new Class>[] { tclass }, new InvocationHandler() {
25 |
26 | public Object invoke(Object arg0, Method method,
27 | Object[] param) throws Throwable {
28 | // TODO Auto-generated method stub
29 |
30 | CreatorBeans creatorcache = ProxyCache.getCache(method
31 | .toGenericString());
32 | if (creatorcache != null) {
33 |
34 | } else {
35 | creatorcache = new Analysis().dealWith(method);
36 | ProxyCache.cache(method.toGenericString(),
37 | creatorcache);
38 | }
39 | CreatorBeans creatorcache2= new AssemblyDevice().startAssembly(creatorcache, param);
40 | ProxyRequester proxyRequester =new ProxyRequester();
41 | proxyRequester.setCreatorBeans(creatorcache2);
42 | return proxyRequester;
43 | }
44 |
45 | });
46 |
47 |
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/MIO.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy;
2 |
3 | public enum MIO {
4 |
5 | MainThread(2),
6 |
7 | IOThread(12);
8 |
9 | private int val=0;
10 |
11 | MIO(int i){
12 | val=i;
13 | }
14 | protected int val() {
15 | return val;
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/annotation/RequestImpl.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.annotation;
2 |
3 |
4 | import com.async.http.request2.BaseRequest;
5 |
6 | import java.lang.annotation.Inherited;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.Target;
9 |
10 | import static java.lang.annotation.ElementType.METHOD;
11 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
12 |
13 | /**
14 | * Created by admin on 2017-04-27.
15 | */
16 | @Inherited
17 | @Target(METHOD)
18 | @Retention(RUNTIME)
19 | public @interface RequestImpl {
20 |
21 | public Class extends BaseRequest> impl();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/dao/RequesyTypeFactory.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.dao;
2 |
3 | import com.async.http.annotation.DOWNLOAD;
4 | import com.async.http.proxy.dao.impl.CustomRequestImpl;
5 | import com.async.http.proxy.dao.impl.MultitierDownloadImpl;
6 | import com.async.http.proxy.dao.impl.JsonImpl;
7 | import com.async.http.proxy.dao.impl.SingleThreadImpl;
8 | import com.async.http.proxy.dao.impl.StringImpl;
9 | import com.async.http.proxy.dao.impl.UploadImpl;
10 | import com.async.http.proxy.entity.CreatorBeans;
11 |
12 |
13 | public class RequesyTypeFactory {
14 |
15 |
16 | public RequesyTypeInterface getRequestType( CreatorBeans creatorBeans){
17 |
18 | if(creatorBeans.isDownload()){
19 | if(creatorBeans.MultitierDownload()){
20 | return new MultitierDownloadImpl(creatorBeans);
21 | }else {
22 | return new SingleThreadImpl(creatorBeans);
23 | }
24 | }else if(creatorBeans.isUpload()){
25 | return new UploadImpl(creatorBeans);
26 |
27 | }else if(creatorBeans.isJSONPOST()) {
28 | return new JsonImpl(creatorBeans);
29 | }else if(creatorBeans.getRequestImpl()!=null){
30 | return new CustomRequestImpl(creatorBeans);
31 | }
32 |
33 |
34 |
35 | return new StringImpl(creatorBeans);
36 | }
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/dao/RequesyTypeInterface.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.dao;
2 |
3 |
4 | import com.async.http.request2.BaseRequest;
5 |
6 | public interface RequesyTypeInterface {
7 |
8 | public BaseRequest holdRequest() throws Exception ;
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/dao/impl/CustomRequestImpl.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.dao.impl;
2 |
3 |
4 | import com.async.http.constant.Charsets;
5 | import com.async.http.proxy.dao.RequesyTypeInterface;
6 | import com.async.http.proxy.entity.CreatorBeans;
7 | import com.async.http.proxy.entity.ParamBean;
8 | import com.async.http.proxy.request.ProxyBaseHttpRequest;
9 |
10 | import com.async.http.request2.BaseRequest;
11 |
12 |
13 | import java.lang.reflect.Constructor;
14 | import java.util.List;
15 |
16 | public class CustomRequestImpl implements RequesyTypeInterface {
17 |
18 | CreatorBeans creatorBeans;
19 |
20 | public CustomRequestImpl(CreatorBeans creatorBeans) {
21 | this.creatorBeans = creatorBeans;
22 | }
23 |
24 | public BaseRequest holdRequest() throws Exception{
25 | // TODO Auto-generated method stub
26 | ProxyBaseHttpRequest request;
27 | String url = creatorBeans.getUrl();
28 | Class extends BaseRequest> cls=creatorBeans.getRequestImpl();
29 | Constructor constructor=cls.getConstructor(String.class,String.class);
30 | request=(ProxyBaseHttpRequest) constructor.newInstance(url,Charsets.UTF_8);
31 |
32 |
33 |
34 | List params = creatorBeans.getList();
35 | request.addParams(params);
36 |
37 |
38 | request.setRequestMethod(creatorBeans.getHttpMethod());
39 | return request;
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/dao/impl/JsonImpl.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.dao.impl;
2 |
3 | import android.util.Log;
4 |
5 | import com.async.http.constant.Charsets;
6 | import com.async.http.proxy.dao.RequesyTypeInterface;
7 | import com.async.http.proxy.entity.CreatorBeans;
8 | import com.async.http.proxy.entity.ParamBean;
9 | import com.async.http.request2.BaseRequest;
10 | import com.async.http.request2.JSONRequest;
11 | import com.async.http.request2.entity.Header;
12 | import com.async.http.request2.part.JsonParamPart;
13 | import com.async.http.request2.part.StringParamPart;
14 |
15 | import java.util.List;
16 |
17 | public class JsonImpl implements RequesyTypeInterface {
18 |
19 | CreatorBeans creatorBeans;
20 |
21 | public JsonImpl(CreatorBeans creatorBeans) {
22 | this.creatorBeans = creatorBeans;
23 | }
24 |
25 | public BaseRequest holdRequest() throws Exception{
26 | // TODO Auto-generated method stub
27 |
28 | String url = creatorBeans.getUrl();
29 | JSONRequest resReques = new JSONRequest(url, Charsets.UTF_8);
30 | resReques.addHead(new Header("Content-Type",
31 | "application/json;charset=UTF-8"));
32 |
33 | List params = creatorBeans.getList();
34 | if(params!=null)
35 | for (int i = 0; i < params.size(); i++) {
36 | ParamBean paramBean = params.get(i);
37 | if(paramBean.getVal()!=null)
38 | resReques.addParam(new JsonParamPart(paramBean.getKey(),
39 | paramBean.getVal()));
40 | }
41 | resReques.setRequestMethod(creatorBeans.getHttpMethod());
42 | return resReques;
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/dao/impl/MultitierDownloadImpl.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.dao.impl;
2 |
3 | import com.async.http.AsyncHttp;
4 | import com.async.http.proxy.dao.RequesyTypeInterface;
5 | import com.async.http.proxy.entity.CreatorBeans;
6 | import com.async.http.request2.BaseRequest;
7 | import com.async.http.request2.FileRequest;
8 | import com.async.http.request2.download;
9 |
10 | public class MultitierDownloadImpl implements RequesyTypeInterface {
11 |
12 | public CreatorBeans creatorBeans;
13 |
14 | public MultitierDownloadImpl(CreatorBeans creatorBeans) {
15 | this.creatorBeans = creatorBeans;
16 | }
17 |
18 | public BaseRequest holdRequest() throws Exception{
19 | // TODO Auto-generated method stub
20 | String url = creatorBeans.getUrl();
21 | String filepath = creatorBeans.getList().get(0).getVal().toString();
22 |
23 | download resReques = new download(url);
24 | resReques.setFilepath(filepath);
25 | resReques.setRequestMethod(creatorBeans.getHttpMethod());
26 | resReques.setRetry(true);
27 | return resReques;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/dao/impl/SingleThreadImpl.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.dao.impl;
2 |
3 | import com.async.http.proxy.dao.RequesyTypeInterface;
4 | import com.async.http.proxy.entity.CreatorBeans;
5 | import com.async.http.request2.BaseRequest;
6 | import com.async.http.request2.FileRequest;
7 | /**
8 | * Created by admin on 2017-03-31.
9 | */
10 |
11 | public class SingleThreadImpl implements RequesyTypeInterface {
12 | public CreatorBeans creatorBeans;
13 |
14 | public SingleThreadImpl(CreatorBeans creatorBeans) {
15 | this.creatorBeans = creatorBeans;
16 | }
17 | @Override
18 | public BaseRequest holdRequest() throws Exception {
19 | String url = creatorBeans.getUrl();
20 | String filepath = creatorBeans.getList().get(0).getVal().toString();
21 | final FileRequest resReques = new FileRequest(url);
22 | resReques.setFilepath(filepath);
23 | resReques.setRequestMethod(creatorBeans.getHttpMethod());
24 | resReques.setRetry(true);
25 | return resReques;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/dao/impl/StringImpl.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.dao.impl;
2 |
3 | import com.async.http.constant.Charsets;
4 | import com.async.http.proxy.dao.RequesyTypeInterface;
5 | import com.async.http.proxy.entity.CreatorBeans;
6 | import com.async.http.proxy.entity.ParamBean;
7 | import com.async.http.request2.BaseRequest;
8 | import com.async.http.request2.StringRequest;
9 | import com.async.http.request2.part.StringParamPart;
10 |
11 | import java.util.List;
12 |
13 | public class StringImpl implements RequesyTypeInterface {
14 |
15 | CreatorBeans creatorBeans;
16 | public StringImpl(CreatorBeans creatorBeans){
17 | this.creatorBeans=creatorBeans;
18 | }
19 |
20 | public BaseRequest holdRequest() throws Exception {
21 | // TODO Auto-generated method stub
22 |
23 | String url = creatorBeans.getUrl();
24 | StringRequest resReques = new StringRequest(url, Charsets.UTF_8);
25 | List params = creatorBeans.getList();
26 | if(params!=null)
27 | for (int i = 0; i < params.size(); i++) {
28 | ParamBean paramBean = params.get(i);
29 | if(paramBean.getVal()!=null)
30 | resReques.addParam(new StringParamPart(paramBean.getKey(),
31 | paramBean.getVal().toString()));
32 | }
33 | resReques.setRequestMethod(creatorBeans.getHttpMethod());
34 | return resReques;
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/entity/AnnotationKey.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.entity;
2 |
3 | public class AnnotationKey {
4 | private Class clas;
5 | private String key;
6 | public Class getClas() {
7 | return clas;
8 | }
9 | public void setClas(Class clas) {
10 | this.clas = clas;
11 | }
12 | public String getKey() {
13 | return key;
14 | }
15 | public void setKey(String key) {
16 | this.key = key;
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/entity/MultiPart.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.entity;
2 |
3 | public class MultiPart {
4 | private String filepath;
5 | private String filetype;
6 | public String getFilepath() {
7 | return filepath;
8 | }
9 | public void setFilepath(String filepath) {
10 | this.filepath = filepath;
11 | }
12 | public String getFiletype() {
13 | return filetype;
14 | }
15 | public void setFiletype(String filetype) {
16 | this.filetype = filetype;
17 | }
18 |
19 |
20 |
21 |
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/entity/ParamBean.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.entity;
2 |
3 | public class ParamBean {
4 |
5 | private String key;
6 | private T val;
7 |
8 | public void setKey(String key) {
9 | this.key = key;
10 | }
11 | public String getKey() {
12 | return key;
13 | }
14 | public T getVal() {
15 | return val;
16 | }
17 | public void setVal(T val) {
18 | this.val = val;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/MethodParseTypeInteface.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method;
2 |
3 | import java.lang.reflect.Method;
4 |
5 |
6 | public interface MethodParseTypeInteface {
7 |
8 |
9 | public String getType(Method method);
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/DeleteMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.DELETE;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class DeleteMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | DELETE get= method.getAnnotation(DELETE.class);
13 | return get.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/DownloadMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.DOWNLOAD;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class DownloadMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | DOWNLOAD download= method.getAnnotation(DOWNLOAD.class);
13 |
14 | return download.value();
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/GetMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.GET;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class GetMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | GET get= method.getAnnotation(GET.class);
13 | return get.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/HeadMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.HEAD;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class HeadMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | HEAD head= method.getAnnotation(HEAD.class);
13 | return head.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/JSONPostMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import com.async.http.annotation.JSONPOST;
4 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
5 |
6 | import java.lang.reflect.Method;
7 |
8 | public class JSONPostMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | JSONPOST post= method.getAnnotation(JSONPOST.class);
13 | return post.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/OptionsMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.OPTIONS;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class OptionsMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | OPTIONS options= method.getAnnotation(OPTIONS.class);
13 | return options.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/PatchMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.PATCH;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class PatchMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | PATCH patch= method.getAnnotation(PATCH.class);
13 | return patch.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/PostMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.POST;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class PostMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | POST post= method.getAnnotation(POST.class);
13 | return post.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/PutMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.PUT;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class PutMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | PUT put= method.getAnnotation(PUT.class);
13 | return put.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/TraceMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.TRACE;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class TraceMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | TRACE trace= method.getAnnotation(TRACE.class);
13 | return trace.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/method/impl/UploadMethodParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.method.impl;
2 |
3 | import java.lang.reflect.Method;
4 |
5 | import com.async.http.annotation.UPLOAD;
6 | import com.async.http.proxy.parseType.method.MethodParseTypeInteface;
7 |
8 | public class UploadMethodParse implements MethodParseTypeInteface {
9 |
10 | public String getType(Method method) {
11 | // TODO Auto-generated method stub
12 | UPLOAD get= method.getAnnotation(UPLOAD.class);
13 | return get.value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/param/ParamParseTypeFactory.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.param;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.async.http.annotation.param.Param;
6 | import com.async.http.annotation.param.PathParam;
7 | import com.async.http.proxy.parseType.param.impl.ParamParse;
8 | import com.async.http.proxy.parseType.param.impl.PathParse;
9 |
10 |
11 | public class ParamParseTypeFactory {
12 | private static HashMap parserMap=new HashMap();
13 |
14 | static {
15 | PathParse stringParser=new PathParse();
16 | parserMap.put(PathParam.class.getName(),stringParser );
17 |
18 |
19 | ParamParse paramParser=new ParamParse();
20 | parserMap.put(Param.class.getName(),paramParser );
21 |
22 |
23 | }
24 |
25 | public static ParamParseTypeInteface getParseType(Class type){
26 | return parserMap.get(type.getName());
27 | }
28 |
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/param/ParamParseTypeInteface.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.param;
2 |
3 | import java.lang.annotation.Annotation;
4 |
5 | public interface ParamParseTypeInteface {
6 |
7 | public String getType(Annotation c);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/param/impl/ParamParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.param.impl;
2 |
3 | import com.async.http.annotation.param.Param;
4 | import com.async.http.proxy.parseType.param.ParamParseTypeInteface;
5 |
6 | import java.lang.annotation.Annotation;
7 |
8 | public class ParamParse implements ParamParseTypeInteface{
9 |
10 | public String getType(Annotation field) {
11 | // TODO Auto-generated method stub
12 | return ((Param)field).value();
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/parseType/param/impl/PathParse.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.parseType.param.impl;
2 |
3 | import com.async.http.annotation.param.PathParam;
4 | import com.async.http.proxy.parseType.param.ParamParseTypeInteface;
5 |
6 | import java.lang.annotation.Annotation;
7 |
8 | public class PathParse implements ParamParseTypeInteface{
9 |
10 | public String getType(Annotation field) {
11 | // TODO Auto-generated method stub
12 |
13 | return ((PathParam)field).value();
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/reflex/ProxyCache.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.reflex;
2 |
3 | import com.async.http.proxy.entity.CreatorBeans;
4 |
5 | import java.util.HashMap;
6 |
7 | public class ProxyCache {
8 |
9 | private static HashMap cache = new HashMap();
10 |
11 | public static void cache(String key, CreatorBeans creatorBeans) {
12 | synchronized (cache) {
13 | if (!cache.containsKey(key)) {
14 | cache.put(key, creatorBeans);
15 | }
16 |
17 | }
18 |
19 | }
20 |
21 | public static CreatorBeans getCache(String key) {
22 |
23 | return cache.get(key);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/proxy/request/ProxyBaseHttpRequest.java:
--------------------------------------------------------------------------------
1 | package com.async.http.proxy.request;
2 |
3 | import java.util.List;
4 |
5 | import com.async.http.proxy.entity.ParamBean;
6 | import com.async.http.request2.BaseHttpRequest;
7 |
8 | public abstract class ProxyBaseHttpRequest extends BaseHttpRequest {
9 |
10 | public ProxyBaseHttpRequest(String url, String charcode) {
11 | super(url, charcode);
12 | // TODO Auto-generated constructor stub
13 | }
14 |
15 | public abstract void addParams(List paramBeans);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/BaseHttpRequest.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2;
2 |
3 | import com.async.http.callback.HttpCallBack;
4 | import com.async.http.entity.ResponseBody;
5 | import com.async.http.request2.conn.BaseConn;
6 | import com.async.http.request2.conn.HttpConn;
7 | import com.async.http.request2.conn.HttpsConn;
8 |
9 | public abstract class BaseHttpRequest extends BaseRequest{
10 |
11 | public BaseHttpRequest(HttpCallBack> httpLifeCycleInterface) {
12 | super(httpLifeCycleInterface);
13 | // TODO Auto-generated constructor stub
14 | }
15 |
16 | public BaseHttpRequest(String url) {
17 | // TODO Auto-generated constructor stub
18 | super(url);
19 | }
20 |
21 | public BaseHttpRequest(String url,String charcode) {
22 | super(url,charcode);
23 | }
24 |
25 | @Override
26 | public BaseConn> getConn() {
27 | // TODO Auto-generated method stub
28 | if(!isHaveSSL())
29 | return new HttpConn(this);
30 |
31 | return new HttpsConn(this);
32 | }
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/BaseSocketRequest.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2;
2 |
3 | import com.async.http.callback.HttpCallBack;
4 | import com.async.http.entity.ResponseBody;
5 | import com.async.http.request2.conn.BaseConn;
6 | import com.async.http.request2.conn.SocketConn;
7 |
8 | public abstract class BaseSocketRequest extends BaseRequest{
9 |
10 | public BaseSocketRequest(HttpCallBack> httpLifeCycleInterface) {
11 | super(httpLifeCycleInterface);
12 | // TODO Auto-generated constructor stub
13 | }
14 |
15 | public BaseSocketRequest(String url) {
16 | // TODO Auto-generated constructor stub
17 | super(url);
18 | }
19 |
20 | public BaseSocketRequest(String url,String charcode) {
21 | super(url,charcode);
22 | }
23 |
24 | @Override
25 | public BaseConn> getConn() {
26 | // TODO Auto-generated method stub
27 | return new SocketConn(this);
28 | }
29 |
30 |
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/JSONRequest.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2;
2 |
3 | import com.async.http.request2.writer.BaseWriter;
4 | import com.async.http.request2.writer.JSONWriter;
5 |
6 | /**
7 | * Created by admin on 2016-11-08.
8 | */
9 | public class JSONRequest extends StringRequest {
10 |
11 |
12 | public JSONRequest(String url) {
13 | super(url);
14 | }
15 |
16 | public JSONRequest(String url, String charCncode) {
17 | super(url, charCncode);
18 | }
19 |
20 | @Override
21 | public BaseWriter getWriter() {
22 | return new JSONWriter(this);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/ManagerConnectionInterface.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2;
2 |
3 | public interface ManagerConnectionInterface {
4 | public void stop();
5 | public void start();
6 | public void continueRun();
7 | public void cancle();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/StringRequest.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2;
2 |
3 | import com.async.http.request2.convert.BaseDataConvert;
4 | import com.async.http.request2.convert.StringDataConvert;
5 | import com.async.http.request2.writer.BaseWriter;
6 | import com.async.http.request2.writer.OneByOneWriter;
7 |
8 | public class StringRequest extends BaseHttpRequest {
9 |
10 | public StringRequest(String url){
11 | super(url);
12 |
13 | }
14 |
15 | public StringRequest(String url,String charCncode){
16 | super(url);
17 | setDataConverCharset(charCncode);
18 | }
19 |
20 | @Override
21 | public BaseDataConvert getConvert() {
22 | // TODO Auto-generated method stub
23 | return new StringDataConvert();
24 | }
25 |
26 |
27 | @Override
28 | public BaseWriter getWriter() {
29 | return new OneByOneWriter(this);
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/UploadRequest.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2;
2 |
3 | /**
4 | * Created by admin on 2016/10/22.
5 | */
6 | public class UploadRequest extends StringRequest {
7 | public UploadRequest(String url, String charCncode) {
8 | super(url, charCncode);
9 | }
10 |
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/convert/BaseDataConvert.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2.convert;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | import com.async.http.exception.HttpException;
7 | import com.async.http.request2.BaseRequest;
8 |
9 | public abstract class BaseDataConvert {
10 |
11 |
12 | protected T data;
13 |
14 | public T convert(BaseRequest request, InputStream input, long len) throws IOException, HttpException {
15 |
16 | this.data = read(request,input,len);
17 |
18 | input.close();
19 |
20 | return this.data;
21 | }
22 |
23 | public abstract T read(BaseRequest request, InputStream input, long len) throws IOException, HttpException;
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/convert/StringDataConvert.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2.convert;
2 |
3 | import com.async.http.exception.CancledOrInterruptedExcetion;
4 | import com.async.http.exception.HttpException;
5 | import com.async.http.request2.BaseRequest;
6 |
7 | import java.io.ByteArrayOutputStream;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | public class StringDataConvert extends BaseDataConvert {
12 |
13 | @Override
14 | public String read(BaseRequest request, InputStream input,
15 | long len) throws IOException,HttpException {
16 | // TODO Auto-generated method stub
17 |
18 | ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
19 | try {
20 | byte[] buff = new byte[1024];
21 | int readLength = 0;
22 | int l = 0;
23 | while (!request.isCancledOrInterrupted()
24 | && (l = input.read(buff)) > 0) {
25 | arrayOutputStream.write(buff, 0, l);
26 | readLength += l;
27 | if (request.isCancledOrInterrupted()) {
28 | input.close();
29 | throw new CancledOrInterruptedExcetion();
30 | }
31 | }
32 | return arrayOutputStream.toString(request.getDataConverCharset());
33 | } finally {
34 | arrayOutputStream.close();
35 | }
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/entity/Header.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2.entity;
2 |
3 |
4 |
5 | /**
6 | * 网络请求链接的头部信息
7 | * @author ml
8 | *
9 | */
10 | public class Header {
11 |
12 |
13 | private String key;
14 | private String val;
15 | public Header(String key2, String val2) {
16 | // TODO Auto-generated constructor stub
17 | this.key=key2;
18 | this.val=val2;
19 | }
20 | public String getKey() {
21 | return key;
22 | }
23 | public void setKey(String key) {
24 | this.key = key;
25 | }
26 | public String getVal() {
27 | return val;
28 | }
29 | public void setVal(String val) {
30 | this.val = val;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/record/RecordManagerHandler.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2.record;
2 |
3 | import java.util.LinkedList;
4 |
5 | import com.async.http.request2.download;
6 |
7 | public interface RecordManagerHandler {
8 |
9 | public RecordEntity getErrorTask();
10 |
11 | public LinkedList getErrorTasks();
12 |
13 | public LinkedList getErrorDownloadTasks();
14 |
15 | public void addErrorTask(RecordEntity recordEntity);
16 |
17 | public void removeErrorTasks(RecordEntity recordEntity);
18 |
19 |
20 | public LinkedList getErrorDownloadTasksFromDisk();
21 |
22 |
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/writer/BaseWriter.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2.writer;
2 |
3 | import com.async.http.client.BoundaryBuilder;
4 | import com.async.http.request2.BaseRequest;
5 |
6 | import java.io.OutputStream;
7 |
8 | /**
9 | * Created by ml on 2016-11-08.
10 | */
11 | public abstract class BaseWriter {
12 | BaseRequest> baseRequest;
13 |
14 | public BaseWriter(BaseRequest> baseRequest) {
15 | this.baseRequest = baseRequest;
16 | }
17 |
18 | public abstract void write(OutputStream out, BoundaryBuilder boundaryBuilder) throws Exception;
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/writer/JSONWriter.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2.writer;
2 |
3 | import com.async.http.client.BoundaryBuilder;
4 | import com.async.http.request2.BaseRequest;
5 | import com.async.http.request2.part.BaseParamPart;
6 | import com.async.http.utils.LogUtils;
7 |
8 | import org.json.JSONObject;
9 |
10 | import java.io.DataOutputStream;
11 | import java.io.OutputStream;
12 |
13 |
14 | /**
15 | * Created by admin on 2016-11-08.
16 | */
17 | public class JSONWriter extends BaseWriter {
18 | public JSONWriter(BaseRequest> baseRequest) {
19 | super(baseRequest);
20 | }
21 | @Override
22 | public void write(OutputStream out, BoundaryBuilder boundaryBuilder) throws Exception {
23 | DataOutputStream dataOutputStream = new DataOutputStream(out);
24 | JSONObject jsonObject=new JSONObject();
25 | for (BaseParamPart baseParamPart: baseRequest.getParamParts()){
26 | String key= baseParamPart.getKey();
27 | Object val= baseParamPart.getVal();
28 | jsonObject.put(key,val);
29 | }
30 | String json=jsonObject.toString();
31 | // String jsons=new String(json.getBytes("utf8"),baseRequest.getDataConverCharset());
32 | LogUtils.e(json+" "+ baseRequest.getDataConverCharset());
33 |
34 | dataOutputStream.write(json.getBytes(baseRequest.getDataConverCharset()));
35 | dataOutputStream.flush();
36 | dataOutputStream.close();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/request2/writer/OneByOneWriter.java:
--------------------------------------------------------------------------------
1 | package com.async.http.request2.writer;
2 |
3 | import com.async.http.client.BoundaryBuilder;
4 | import com.async.http.request2.BaseRequest;
5 | import com.async.http.request2.part.BaseParamPart;
6 |
7 | import java.io.OutputStream;
8 |
9 | /**
10 | * Created by admin on 2016-11-08.
11 | */
12 | public class OneByOneWriter extends BaseWriter {
13 | public OneByOneWriter(BaseRequest> baseRequest) {
14 | super(baseRequest);
15 | }
16 |
17 | @Override
18 | public void write(OutputStream out, BoundaryBuilder boundaryBuilder) throws Exception {
19 |
20 | for (BaseParamPart> baseParamPart : baseRequest.getParamParts()) {
21 | baseParamPart.setBoundaryStart(boundaryBuilder.getStart_tag());
22 | baseParamPart.setBoundaryBuilder(boundaryBuilder);
23 | baseParamPart.createHead();
24 | baseParamPart.write(out, baseRequest);
25 | }
26 | if (baseRequest.getParamParts() != null && baseRequest.getParamParts().size() != 0) {
27 | out.write(boundaryBuilder.getEnd_tag().getBytes());
28 | out.flush();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/task2/BaseResultInterceptorObsever.java:
--------------------------------------------------------------------------------
1 | package com.async.http.task2;
2 |
3 | import com.async.http.Interceptor2.ResponseInterceptor2;
4 | import com.async.http.callback.HttpCallBack;
5 | import com.async.http.entity.ResponseBody;
6 | /*import com.async.pool.msg.ResultObsever;*/
7 |
8 | /*public class BaseResultInterceptorObsever implements ResultObsever {*/
9 | public class BaseResultInterceptorObsever /*implements ResultObsever*/ {
10 |
11 | private ResponseInterceptor2 responseInterceptor2;
12 |
13 | private HttpCallBack> httpCallBack;
14 |
15 | public void setResponseInterceptor2(
16 | ResponseInterceptor2 responseInterceptor2) {
17 | this.responseInterceptor2 = responseInterceptor2;
18 | }
19 |
20 | public void setHttpCallBack(HttpCallBack> httpCallBack) {
21 | this.httpCallBack = httpCallBack;
22 | }
23 |
24 | @SuppressWarnings("unchecked")
25 | public void setResult(T arg0) {
26 | // TODO Auto-generated method stub
27 | try {
28 | if (responseInterceptor2 != null)
29 | arg0 = responseInterceptor2.interceptor(arg0);
30 | ResponseBody res = (ResponseBody) arg0;
31 |
32 | if (res != null && res.getException() == null)
33 | httpCallBack.success(res);
34 | else
35 | httpCallBack.fail(res.getException(),res);
36 |
37 | } catch (Exception e) {
38 | // TODO Auto-generated catch block
39 | ResponseBody res = (ResponseBody) arg0;
40 | httpCallBack.fail(e,res);
41 | return;
42 | }finally{
43 | httpCallBack.finish();
44 | }
45 |
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/utils/DeleteDirectory.java:
--------------------------------------------------------------------------------
1 | package com.async.http.utils;
2 |
3 | import java.io.File;
4 |
5 | public class DeleteDirectory {
6 | /**
7 | * 删除空目录
8 | *
9 | * @param dir
10 | * 将要删除的目录路径
11 | */
12 | private static void doDeleteEmptyDir(String dir) {
13 | boolean success = (new File(dir)).delete();
14 | if (success) {
15 | System.out.println("Successfully deleted empty directory: " + dir);
16 | } else {
17 | System.out.println("Failed to delete empty directory: " + dir);
18 | }
19 | }
20 |
21 | /**
22 | * 递归删除目录下的所有文件及子目录下所有文件
23 | *
24 | * @param dir
25 | * 将要删除的文件目录
26 | * @return boolean Returns "true" if all deletions were successful. If a
27 | * deletion fails, the method stops attempting to delete and returns
28 | * "false".
29 | */
30 | public static boolean deleteDir(File dir) {
31 | try{
32 | if (dir.isDirectory()) {
33 | String[] children = dir.list();
34 | // 递归删除目录中的子目录下
35 | for (int i = 0; i < children.length; i++) {
36 | boolean success = deleteDir(new File(dir, children[i]));
37 | if (!success) {
38 | return false;
39 | }
40 | }
41 | }
42 | // 目录此时为空,可以删除
43 | return dir.delete();
44 | }catch(Exception e){
45 | e.printStackTrace();
46 | }
47 | return false;
48 | }
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/utils/LogUtils.java:
--------------------------------------------------------------------------------
1 | package com.async.http.utils;
2 |
3 | import android.util.Log;
4 |
5 | public class LogUtils {
6 |
7 | private static boolean isOpenDebug=true;
8 | private static boolean isOpenLogHeaders=false;
9 |
10 | public static boolean isDebug(){
11 |
12 | return isOpenDebug;
13 | }
14 |
15 | public static void setDebug(boolean isOpenOrClose){
16 | isOpenDebug=isOpenOrClose;
17 | }
18 |
19 | public static boolean isOpenLogHeaders() {
20 | return isOpenLogHeaders;
21 | }
22 |
23 | public static void setIsOpenLogHeaders(boolean isOpenLogHeaders) {
24 | LogUtils.isOpenLogHeaders = isOpenLogHeaders;
25 | }
26 |
27 | public static void e(String string) {
28 | // TODO Auto-generated method stub
29 |
30 | if(!isOpenDebug)return;
31 |
32 | StringBuilder sb=new StringBuilder();
33 | sb.append("=======start=======\n");
34 | sb.append(string);
35 | sb.append("\n");
36 | sb.append("=======end=======\n");
37 | Log.e("tag",sb.toString());
38 |
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/utils/StringUtils.java:
--------------------------------------------------------------------------------
1 | package com.async.http.utils;
2 |
3 | public class StringUtils {
4 |
5 | /**
6 | * Description:判断字段空null
7 | *
8 | * @param s
9 | * @return boolean
10 | */
11 | public static boolean isNull(String s) {
12 | if (s == null || "".equals(s.trim())) {
13 | return true;
14 | }
15 |
16 | return false;
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/utils/UrlEncodeUtils.java:
--------------------------------------------------------------------------------
1 | package com.async.http.utils;
2 |
3 | import java.util.HashMap;
4 | import java.util.Iterator;
5 |
6 | public class UrlEncodeUtils {
7 |
8 | public static String encodeUrl(String url){
9 |
10 | HashMap hashMap=new HashMap();
11 | hashMap.put(" ", "%20");
12 | hashMap.put("-", "%22");
13 | hashMap.put("#", "%23");
14 | hashMap.put("\\(", "%28");
15 | hashMap.put("\\)", "%29");
16 | hashMap.put("\\+", "%2B");
17 | hashMap.put(",", "%2C");
18 | hashMap.put(";", "%3B");
19 | hashMap.put("<", "%3C");
20 | hashMap.put(">", "%3E");
21 | hashMap.put("@", "%40");
22 | hashMap.put("\\|", "%7C");
23 | hashMap.put("\\\\", "%5C");
24 | Iterator iterator=hashMap.keySet().iterator();
25 | while(iterator.hasNext()){
26 | String key=iterator.next();
27 | String val=hashMap.get(key);
28 | url=url.replaceAll(key, val);
29 | }
30 |
31 | return url;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/java/com/async/http/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package com.async.http.utils;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 |
6 | public class Utils {
7 | public static String getNowTime() {
8 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
9 | return df.format(new Date());// new Date()为获取当前系统时间
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asynchttp/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | asyhttp
3 |
4 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By defaults, the flags in this file are appended to flags specified
3 | # in D:\as_sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/AfterService/AfterDataManager.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.AfterService;
2 |
3 | import java.util.LinkedList;
4 |
5 | import com.async.pool.msg.Result;
6 |
7 | public class AfterDataManager {
8 |
9 | private LinkedList resultQuece = null;
10 |
11 | private static AfterDataManager afterDataManager;
12 |
13 |
14 | public static AfterDataManager Call( ) {
15 |
16 | if (afterDataManager == null)
17 | afterDataManager = new AfterDataManager();
18 |
19 | return afterDataManager;
20 | }
21 |
22 | public AfterDataManager(){
23 | resultQuece = new LinkedList();
24 | }
25 | public void notice(Result result) {
26 | // TODO Auto-generated method stub
27 | if(result!=null&&result.getObj()!=null)//防止 任务取消之后,添加到 完成队列中
28 | resultQuece.add(result);
29 |
30 | }
31 | public LinkedList getResultQuece(){
32 | return resultQuece;
33 | }
34 |
35 | public void remove(Result result){
36 | resultQuece.remove(result);
37 | }
38 |
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/BeforeService/BeforeCustomerService.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.BeforeService;
2 |
3 | import java.util.LinkedList;
4 |
5 | import com.async.pool.msg.CustomMessage;
6 |
7 |
8 | /**
9 | * 接受请求,上交到客服中心,任务管理中心
10 | * @author ml
11 | *
12 | */
13 | public class BeforeCustomerService {
14 |
15 | private Observer observer;
16 |
17 | private static BeforeCustomerService beforeCustomerService;
18 |
19 | public synchronized static BeforeCustomerService call(){
20 | if(beforeCustomerService==null){
21 | beforeCustomerService=new BeforeCustomerService();
22 | }
23 |
24 | return beforeCustomerService;
25 | }
26 |
27 | public void registerObserver(Observer observer){
28 | this.observer=observer;
29 | }
30 |
31 |
32 | /**
33 | * 客户将任务发送给客服人员
34 | * @param msg
35 | */
36 | public void send(CustomMessage msg){
37 | //通知观察者,(客服中心领导)
38 | notifyObserver( msg);
39 | }
40 |
41 | public void sendMsgs(LinkedList msglist){
42 | observer.Observe(msglist);
43 | }
44 |
45 |
46 | private void notifyObserver(CustomMessage msg) {
47 | // TODO Auto-generated method stub
48 | observer.Observe(msg);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/BeforeService/Observer.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.BeforeService;
2 |
3 | import java.util.LinkedList;
4 |
5 |
6 | public interface Observer {
7 |
8 | public void Observe(T msg);
9 |
10 | public void Observe(LinkedList listmsg);
11 | }
12 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/ConstructionCenter/TaskInterface.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.ConstructionCenter;
2 |
3 | public interface TaskInterface {
4 | /**
5 | * 第一个参数表示 当前任务的下标 第二个参数表示 当前任务是否是 取消掉了
6 | * @param objects
7 | * @return
8 | */
9 |
10 | public Object run(Object ...objects);
11 |
12 | public void registerObsever(TaskLife tasklife);
13 |
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/ConstructionCenter/TaskLife.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.ConstructionCenter;
2 |
3 | public interface TaskLife {
4 |
5 | public void stop();
6 |
7 | public void start();
8 |
9 | public void remove();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/ConstructionCenter/TaskPriority.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.ConstructionCenter;
2 |
3 | public enum TaskPriority {
4 |
5 | HIGHEST(1), NORMAL(2), LOWEST(3);
6 | int taskPriority;
7 |
8 | TaskPriority(int taskPriority) {
9 | this.taskPriority = taskPriority;
10 |
11 | }
12 |
13 | public int getValue(){
14 | return taskPriority;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/ConstructionCenter/WorkTaskInterface.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.ConstructionCenter;
2 |
3 | /**
4 | * 具体的任务
5 | *
6 | * @author ml
7 | *
8 | */
9 |
10 | public interface WorkTaskInterface extends TaskLife{
11 |
12 | public Object startTask();
13 |
14 | /**
15 | * 设置任务的优先级
16 | * @param priority
17 | */
18 | public void setTaskPriority(int priority);
19 |
20 | /**
21 | * 获取任务的优先级
22 | * @return
23 | */
24 | public int getTaskPriority();
25 |
26 | /**
27 | * 任务的进度
28 | * @return
29 | */
30 | public boolean isRunning();
31 |
32 | /**
33 | * 设置任务的进度
34 | * @param isruning
35 | */
36 | public void setRunning(boolean isruning);
37 |
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/Log/Log.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.Log;
2 |
3 | public class Log {
4 |
5 | static boolean isWrite=true;
6 | public static void e(String msg){
7 | if(isWrite)
8 | System.err.println(msg);;
9 | }
10 | public static void setDebug(boolean is){
11 | isWrite=is;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/RecordCenter/RecordCenterHandler.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.RecordCenter;
2 |
3 | import com.async.pool.RecordCenter.after.AfterTaskHandler;
4 | import com.async.pool.RecordCenter.before.BeforeTaskHanlder;
5 |
6 | public interface RecordCenterHandler extends BeforeTaskHanlder,AfterTaskHandler{
7 |
8 | public void sortUtils();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/RecordCenter/after/AfterTaskCenter.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.RecordCenter.after;
2 |
3 | import java.util.HashMap;
4 |
5 | import com.async.pool.msg.ResultObsever;
6 |
7 |
8 | /**
9 | * 消息中心,管理问题
10 | *
11 | * @author ml
12 | *
13 | */
14 | public class AfterTaskCenter implements AfterTaskHandler{
15 | private HashMap> response=null;
16 |
17 | private static AfterTaskCenter afterTaskCenter;
18 |
19 | public synchronized static AfterTaskCenter Call(){
20 |
21 | if(afterTaskCenter==null)afterTaskCenter=new AfterTaskCenter();
22 |
23 | return afterTaskCenter;
24 | }
25 |
26 | public AfterTaskCenter(){
27 | response=new HashMap>();
28 |
29 | }
30 |
31 | public void add(String id,ResultObsever> msg) {
32 | // TODO Auto-generated method stub
33 | response.put(id, msg);
34 | }
35 |
36 | public void delete(String mid) {
37 | // TODO Auto-generated method stub
38 | getObsever(mid);
39 | }
40 |
41 | public ResultObsever> getObsever(String mid) {
42 | // TODO Auto-generated method stub
43 | if(!response.containsKey(mid)){
44 | System.out.println("!response.containsKey(mid) ==true");
45 | return null;
46 | }
47 | // ResultObsever> re= response.get(mid);
48 | return response.remove(mid);
49 | }
50 |
51 | public int AfterSize() {
52 | // TODO Auto-generated method stub
53 | return response.size();
54 | }
55 |
56 |
57 |
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/RecordCenter/after/AfterTaskHandler.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.RecordCenter.after;
2 |
3 |
4 | import com.async.pool.msg.ResultObsever;
5 |
6 | public interface AfterTaskHandler {
7 | public void add(String id, ResultObsever> msg);
8 |
9 | public void delete(String mid);
10 |
11 | public ResultObsever> getObsever(String mid);
12 |
13 | public int AfterSize();
14 | }
15 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/RecordCenter/after/AfterTaskManager.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.RecordCenter.after;
2 |
3 | import com.async.pool.msg.ResultObsever;
4 |
5 | /**
6 | * 消息中心,管理者
7 | *
8 | * @author ML
9 | *
10 | */
11 | public class AfterTaskManager implements AfterTaskHandler{
12 |
13 | private static AfterTaskManager afterTaskManager;
14 |
15 | AfterTaskHandler afterTaskHandler;
16 |
17 |
18 | public synchronized static AfterTaskManager Call() {
19 |
20 | if (afterTaskManager == null)
21 | afterTaskManager = new AfterTaskManager();
22 |
23 | return afterTaskManager;
24 | }
25 |
26 | public void setAfterTaskHandler(AfterTaskHandler afterTaskHandler) {
27 | this.afterTaskHandler = afterTaskHandler;
28 | }
29 |
30 | public AfterTaskManager(){
31 |
32 | afterTaskHandler=AfterTaskCenter.Call();
33 | }
34 |
35 |
36 | public void add(String id, ResultObsever> msg) {
37 | // TODO Auto-generated method stub
38 | afterTaskHandler.add(id, msg);
39 | }
40 |
41 |
42 | public void delete(String mid) {
43 | // TODO Auto-generated method stub
44 | afterTaskHandler.delete(mid);
45 | }
46 |
47 |
48 | public ResultObsever> getObsever(String mid) {
49 | // TODO Auto-generated method stub
50 | return afterTaskHandler.getObsever(mid);
51 | }
52 |
53 |
54 | public int AfterSize() {
55 | // TODO Auto-generated method stub
56 | return afterTaskHandler.AfterSize();
57 | }
58 |
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/RecordCenter/before/BeforeTaskHanlder.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.RecordCenter.before;
2 |
3 | import java.util.LinkedList;
4 | import java.util.Vector;
5 |
6 | import com.async.pool.msg.CustomMessage;
7 |
8 | public interface BeforeTaskHanlder {
9 |
10 | public void add(CustomMessage msg);
11 | public void add(LinkedList extends CustomMessage> msg);
12 |
13 |
14 | public void delete(CustomMessage msg);
15 |
16 | public CustomMessage getMsg();
17 |
18 | public CustomMessage getHightMsg();
19 |
20 |
21 | public int BeforeSize();
22 |
23 | public Vector extends CustomMessage> getALLTask();
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/msg/CustomMessage.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.msg;
2 |
3 | import com.async.pool.ConstructionCenter.TaskWork;
4 |
5 | /**
6 | * 用户的消息
7 | * @author m
8 | * @param
9 | *
10 | */
11 | public class CustomMessage {
12 | /*
13 | * 任务id
14 | */
15 | private int mid;
16 | /**
17 | * 任务
18 | */
19 | private TaskWork task;
20 |
21 | public CustomMessage(TaskWork task){
22 | this.task=task;
23 | }
24 |
25 | public int getMid() {
26 | return mid;
27 | }
28 |
29 | public void setMid(int mid) {
30 | this.mid = mid;
31 | }
32 |
33 | public TaskWork getTask() {
34 |
35 | return task;
36 | }
37 |
38 | public void setTask(TaskWork task) {
39 | this.task = task;
40 | }
41 |
42 | private Object obj;
43 | public void setObj(Object obj) {
44 | this.obj = obj;
45 | }
46 | public Object getObj() {
47 | return obj;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/msg/CustomMessageBuilder.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.msg;
2 |
3 | import com.async.pool.ConstructionCenter.TaskWork;
4 |
5 | /**
6 | * 用户的消息
7 | *
8 | * @author m
9 | * @param
10 | *
11 | */
12 | public class CustomMessageBuilder {
13 |
14 | private int num;
15 |
16 | public static CustomMessageBuilder customMessageBuilder;
17 |
18 | public synchronized static CustomMessageBuilder Call() {
19 |
20 | if (customMessageBuilder == null)
21 | customMessageBuilder = new CustomMessageBuilder();
22 | return customMessageBuilder;
23 | }
24 |
25 | public CustomMessage builder(TaskWork taskWork,
26 | ResultObsever resultObsever) {
27 |
28 | CustomMessage customMessage = new CustomMessage(taskWork);
29 | customMessage.setObj(resultObsever);
30 | customMessage.setMid(num++);
31 | return customMessage;
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/msg/DefaultMsgFilter.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.msg;
2 |
3 |
4 | public class DefaultMsgFilter implements MsgFilter {
5 |
6 | public CustomMessage isQualified(CustomMessage msg) {
7 | // TODO Auto-generated method stub
8 | //System.out.println("=========MyMsgFilter========");
9 | return msg;
10 | }
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/msg/MsgFilter.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.msg;
2 |
3 | public interface MsgFilter {
4 |
5 | public CustomMessage isQualified(CustomMessage msg);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/msg/Result.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.msg;
2 |
3 | public class Result {
4 |
5 | private String id;
6 | private Object obj;
7 |
8 |
9 | public Result(String id,Object obj){
10 | this.id=id;
11 | this.obj=obj;
12 | }
13 | public String getId() {
14 | return id;
15 | }
16 | public void setId(String id) {
17 | this.id = id;
18 | }
19 | public Object getObj() {
20 | return obj;
21 | }
22 | public void setObj(Object obj) {
23 | this.obj = obj;
24 | }
25 |
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/java/com/async/pool/msg/ResultObsever.java:
--------------------------------------------------------------------------------
1 | package com.async.pool.msg;
2 |
3 | public interface ResultObsever {
4 |
5 | public void setResult(T result) ;
6 |
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/asyncpool/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AsyncPool
3 |
4 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.3.3'
10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 |
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | android.useDeprecatedNdk=true
20 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/AsyncHttpForAndroid/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Jun 05 15:22:47 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/AsyncHttpForAndroid/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app';
2 | include ':appupdate';
3 | /*include ':asynchttp';
4 |
5 | include ':asyncpool';
6 | include ':asynchttp-android';*/
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MengLeiGitHub/AsyncHttp/9877b4aff6dbf77f75bd1582541515360a635915/README.md
--------------------------------------------------------------------------------