├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── values-v21 │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ └── menu_main.xml │ │ │ └── layout │ │ │ │ ├── activity_main.xml │ │ │ │ └── content_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── im │ │ │ └── wangchao │ │ │ └── mhttpdemo │ │ │ ├── SampleApi.java │ │ │ ├── SampleDefaultApi.java │ │ │ ├── GetExample.java │ │ │ ├── PostExample.java │ │ │ ├── Cache.java │ │ │ ├── MainActivity.java │ │ │ └── Android5SSL.java │ ├── androidTest │ │ └── java │ │ │ └── im │ │ │ └── wangchao │ │ │ └── mhttpdemo │ │ │ ├── ApplicationTest.java │ │ │ └── ExampleInstrumentedTest.java │ └── test │ │ └── java │ │ └── im │ │ └── wangchao │ │ └── mhttp │ │ └── ExampleUnitTest.java ├── proguard-rules.pro └── build.gradle ├── mhttp ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── im │ │ └── wangchao │ │ └── mhttp │ │ ├── Converter.java │ │ ├── internal │ │ ├── exception │ │ │ ├── ParserException.java │ │ │ └── ResponseFailException.java │ │ ├── Version.java │ │ ├── Singleton.java │ │ ├── cookie │ │ │ ├── ClearableCookieJar.java │ │ │ ├── cache │ │ │ │ ├── CookieCache.java │ │ │ │ ├── SetCookieCache.java │ │ │ │ └── IdentifiableCookie.java │ │ │ ├── persistence │ │ │ │ ├── CookiePersistor.java │ │ │ │ ├── SharedPrefsCookiePersistor.java │ │ │ │ └── SerializableCookie.java │ │ │ ├── MemoryCookieJar.java │ │ │ └── PersistentCookieJar.java │ │ ├── log │ │ │ └── LoggerImpl.java │ │ └── interceptor │ │ │ └── MBridgeInterceptor.java │ │ ├── URLInterceptor.java │ │ ├── executor │ │ ├── BACKGROUND.java │ │ ├── MAIN.java │ │ └── SENDING.java │ │ ├── Method.java │ │ ├── BindApi.java │ │ ├── callback │ │ ├── BitmapCallbackHandler.java │ │ ├── TextCallbackHandler.java │ │ ├── BinaryCallbackHandler.java │ │ ├── GSONCallbackHandler.java │ │ ├── JSONCallbackHandler.java │ │ └── FileCallbackHandler.java │ │ ├── Callback.java │ │ ├── Accept.java │ │ ├── ThreadMode.java │ │ ├── body │ │ ├── FileBody.java │ │ ├── JSONBody.java │ │ ├── MediaTypeUtils.java │ │ ├── ProgressRequestBody.java │ │ └── OctetStreamBody.java │ │ ├── Response.java │ │ ├── rxjava2 │ │ ├── ResponseExecuteObservable.java │ │ ├── ResponseEnqueueObservable.java │ │ └── RxRequest.java │ │ ├── Android5SSL.java │ │ ├── HTTPS.java │ │ ├── MHttp.java │ │ └── AbsCallbackHandler.java ├── gradle.properties ├── build.gradle ├── proguard-rules.pro └── mhttp.iml ├── mhttp-adapter ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── im │ │ │ └── wangchao │ │ │ └── mhttp │ │ │ └── adapter │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── im │ │ └── wangchao │ │ └── mhttp │ │ └── adapter │ │ └── ApplicationTest.java ├── proguard-rules.pro ├── build.gradle └── mhttp-adapter.iml ├── mhttp-compiler ├── .gitignore ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ └── javax.annotation.processing.Processor │ │ └── java │ │ │ └── im │ │ │ └── wangchao │ │ │ └── http │ │ │ └── compiler │ │ │ ├── MyClass.java │ │ │ ├── BindClass.java │ │ │ └── BindMethod.java │ └── test │ │ └── java │ │ └── im │ │ └── wangchao │ │ └── http │ │ └── compiler │ │ └── JavaPoetTest.java ├── build.gradle └── gradle.properties ├── mhttp-annotations ├── .gitignore ├── build.gradle ├── src │ └── main │ │ └── java │ │ └── im │ │ └── wangchao │ │ └── http │ │ └── annotations │ │ ├── Tag.java │ │ ├── Callback.java │ │ ├── Timeout.java │ │ ├── RootURL.java │ │ ├── CommonParamsMethod.java │ │ ├── Header.java │ │ ├── RequestContentType.java │ │ ├── Get.java │ │ └── Post.java └── gradle.properties ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── upload.sh ├── makeProcessor.sh ├── gradle.properties ├── MHttp.iml ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /mhttp/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml -------------------------------------------------------------------------------- /mhttp-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /mhttp-compiler/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml 3 | -------------------------------------------------------------------------------- /mhttp-annotations/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | *.iml 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':mhttp', ':mhttp-compiler', ':mhttp-annotations', ':mhttp-adapter' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jymot/MHttp/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /mhttp-adapter/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MHttp-adapter 3 | 4 | -------------------------------------------------------------------------------- /mhttp-compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | im.wangchao.http.compiler.HttpProcessor 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | *.iml -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jymot/MHttp/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jymot/MHttp/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jymot/MHttp/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /upload.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | source ~/.bash_profile 3 | #gradle bintrayUpload --stacktrace 4 | ./gradlew bintrayUpload --stacktrace -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jymot/MHttp/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jymot/MHttp/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MHttp 3 | Settings 4 | 5 | -------------------------------------------------------------------------------- /mhttp/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue May 15 11:42:08 CST 2018 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-4.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/Converter.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp; 2 | 3 | /** 4 | *

Description : Converter.

5 | *

Author : wangchao.

6 | *

Date : 2018/3/20.

7 | *

Time : 下午10:26.

8 | */ 9 | public interface Converter { 10 | 11 | R apply(T t) throws Exception; 12 | } 13 | -------------------------------------------------------------------------------- /makeProcessor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ./gradlew :mhttp-compiler:build 4 | 5 | cp ./mhttp-compiler/build/libs/mhttp-compiler.jar ./mhttp/libs/mhttp-compiler.jar 6 | 7 | ./gradlew :mhttp-annotations:build 8 | 9 | cp ./mhttp-annotations/build/libs/mhttp-annotations.jar ./mhttp/libs/mhttp-annotations.jar 10 | 11 | ./gradlew compileDebugJava 12 | 13 | 14 | -------------------------------------------------------------------------------- /mhttp-adapter/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 8 | 9 | -------------------------------------------------------------------------------- /mhttp-annotations/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | sourceCompatibility = rootProject.ext.sourceCompatibilityVersion 4 | targetCompatibility = rootProject.ext.targetCompatibilityVersion 5 | 6 | dependencies { 7 | implementation fileTree(dir: 'libs', include: ['*.jar']) 8 | } 9 | 10 | //apply from: 'https://raw.githubusercontent.com/motcwang/Utils/master/bintray-publish/bintray-java.gradle' -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /mhttp-adapter/src/test/java/im/wangchao/mhttp/adapter/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.adapter; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/internal/exception/ParserException.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.internal.exception; 2 | 3 | /** 4 | *

Description : ParserException.

5 | *

Author : wangchao.

6 | *

Date : 16/4/26.

7 | *

Time : 下午8:38.

8 | */ 9 | public class ParserException extends Exception{ 10 | public ParserException(){ 11 | super("Response parse exception."); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/androidTest/java/im/wangchao/mhttpdemo/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttpdemo; 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 | } -------------------------------------------------------------------------------- /mhttp-adapter/src/androidTest/java/im/wangchao/mhttp/adapter/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.adapter; 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 | } -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/internal/exception/ResponseFailException.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.internal.exception; 2 | 3 | /** 4 | *

Description : ResponseFailException.

5 | *

Author : wangchao.

6 | *

Date : 16/4/25.

7 | *

Time : 下午4:06.

8 | */ 9 | public class ResponseFailException extends Exception{ 10 | //Response Non Successful 11 | public ResponseFailException(){ 12 | super("Response failure exception."); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/URLInterceptor.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp; 2 | 3 | import java.net.URL; 4 | 5 | import okhttp3.HttpUrl; 6 | 7 | /** 8 | *

Description : URLInterceptor.

9 | *

Author : wangchao.

10 | *

Date : 2018/1/15.

11 | *

Time : 上午11:01.

12 | */ 13 | public interface URLInterceptor { 14 | 15 | String interceptor(String origin); 16 | 17 | HttpUrl interceptor(HttpUrl origin); 18 | 19 | URL interceptor(URL origin); 20 | } 21 | -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/executor/BACKGROUND.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.executor; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import java.util.concurrent.Executor; 6 | 7 | /** 8 | *

Description : BACKGROUND.

9 | *

Author : wangchao.

10 | *

Date : 16/9/2.

11 | *

Time : 下午4:50.

12 | */ 13 | public final class BACKGROUND implements Executor { 14 | @Override public void execute(@NonNull Runnable command) { 15 | command.run(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /mhttp-annotations/src/main/java/im/wangchao/http/annotations/Tag.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.http.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | *

Description : Tag.

10 | *

11 | *

Author : wangchao.

12 | *

Date : 16/3/22.

13 | *

Time : 上午10:58.

14 | */ 15 | @Retention(RetentionPolicy.CLASS) 16 | @Target(ElementType.PARAMETER) 17 | public @interface Tag { 18 | } 19 | -------------------------------------------------------------------------------- /mhttp-compiler/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | sourceCompatibility = rootProject.ext.sourceCompatibilityVersion 4 | targetCompatibility = rootProject.ext.targetCompatibilityVersion 5 | 6 | dependencies { 7 | implementation deps.mhttpannotations 8 | // implementation project(':mhttp-annotations') 9 | implementation deps.autoservice 10 | implementation deps.autocommon 11 | implementation deps.javapoet 12 | 13 | testImplementation deps.junit 14 | } 15 | 16 | //apply from: 'https://raw.githubusercontent.com/motcwang/Utils/master/bintray-publish/bintray-java.gradle' -------------------------------------------------------------------------------- /mhttp-annotations/src/main/java/im/wangchao/http/annotations/Callback.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.http.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | *

Description : Callback.

10 | *

11 | *

Author : wangchao.

12 | *

Date : 15/10/17.

13 | *

Time : 下午6:02.

14 | */ 15 | @Retention(RetentionPolicy.CLASS) 16 | @Target(ElementType.PARAMETER) 17 | public @interface Callback { 18 | } 19 | -------------------------------------------------------------------------------- /mhttp-annotations/src/main/java/im/wangchao/http/annotations/Timeout.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.http.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | *

Description : Timeout.废弃,不处理该 Annotation

10 | *

11 | *

Author : wangchao.

12 | *

Date : 15/10/31.

13 | *

Time : 下午1:13.

14 | */ 15 | @Retention(RetentionPolicy.SOURCE) 16 | @Target(ElementType.FIELD) 17 | @Deprecated 18 | public @interface Timeout { 19 | int value(); 20 | } 21 | -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/internal/Version.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.internal; 2 | 3 | import im.wangchao.mhttp.BuildConfig; 4 | 5 | /** 6 | *

Description : Version.

7 | *

Author : wangchao.

8 | *

Date : 16/8/24.

9 | *

Time : 下午2:47.

10 | */ 11 | public class Version { 12 | private Version(){ 13 | throw new AssertionError(); 14 | } 15 | 16 | public static String userAgent() { 17 | return moduleName().concat(BuildConfig.VERSION_NAME); 18 | } 19 | 20 | public static String moduleName() { 21 | return "mhttp"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mhttp-annotations/src/main/java/im/wangchao/http/annotations/RootURL.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.http.annotations; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.RetentionPolicy.CLASS; 8 | 9 | /** 10 | *

Description : RootURL.

11 | *

12 | *

Author : wangchao.

13 | *

Date : 15/10/31.

14 | *

Time : 上午10:17.

15 | */ 16 | @Retention(CLASS) 17 | @Target(FIELD) 18 | public @interface RootURL { 19 | /** 20 | * request root address 21 | */ 22 | String value(); 23 | } 24 | -------------------------------------------------------------------------------- /mhttp-annotations/src/main/java/im/wangchao/http/annotations/CommonParamsMethod.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.http.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | *

Description : CommonParamsMethod. 10 | * method name will return Map(String, Object)

11 | *

Author : wangchao.

12 | *

Date : 15/11/2.

13 | *

Time : 下午8:23.

14 | */ 15 | @Retention(RetentionPolicy.SOURCE) 16 | @Target(ElementType.METHOD) 17 | public @interface CommonParamsMethod { 18 | } 19 | -------------------------------------------------------------------------------- /mhttp-annotations/src/main/java/im/wangchao/http/annotations/Header.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.http.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | *

Description : Header.

10 | *

11 | *

Author : wangchao.

12 | *

Date : 15/10/31.

13 | *

Time : 下午1:17.

14 | */ 15 | @Retention(RetentionPolicy.SOURCE) 16 | @Target(ElementType.FIELD) 17 | public @interface Header { 18 | /** 19 | * the common header of request 20 | */ 21 | String[] value(); 22 | } 23 | -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/executor/MAIN.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.executor; 2 | 3 | import android.os.Handler; 4 | import android.os.Looper; 5 | import android.support.annotation.NonNull; 6 | 7 | import java.util.concurrent.Executor; 8 | 9 | /** 10 | *

Description : MainThread.

11 | *

Author : wangchao.

12 | *

Date : 16/9/2.

13 | *

Time : 下午4:45.

14 | */ 15 | public final class MAIN implements Executor{ 16 | private final Handler handler = new Handler(Looper.getMainLooper()); 17 | 18 | @Override public void execute(@NonNull Runnable command) { 19 | handler.post(command); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /mhttp/src/main/java/im/wangchao/mhttp/internal/Singleton.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttp.internal; 2 | 3 | /** 4 | *

Description : Singleton.

5 | *

Author : wangchao.

6 | *

Date : 16/8/25.

7 | *

Time : 上午10:37.

8 | */ 9 | public abstract class Singleton { 10 | private T instance; 11 | 12 | protected abstract T create(); 13 | 14 | public T get(){ 15 | if (instance == null){ 16 | synchronized (this){ 17 | if (instance == null){ 18 | instance = create(); 19 | } 20 | } 21 | } 22 | 23 | return instance; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/test/java/im/wangchao/mhttp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.mhttpdemo; 2 | 3 | import android.util.Log; 4 | 5 | import org.junit.Test; 6 | 7 | import java.nio.charset.Charset; 8 | 9 | import im.wangchao.mhttp.Request; 10 | import im.wangchao.mhttp.Response; 11 | import im.wangchao.mhttp.callback.TextCallbackHandler; 12 | 13 | import static android.R.attr.data; 14 | import static org.junit.Assert.assertEquals; 15 | 16 | /** 17 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 18 | */ 19 | public class ExampleUnitTest { 20 | @Test 21 | public void addition_isCorrect() throws Exception { 22 | assertEquals(4, 2 + 2); 23 | } 24 | } -------------------------------------------------------------------------------- /mhttp-annotations/src/main/java/im/wangchao/http/annotations/RequestContentType.java: -------------------------------------------------------------------------------- 1 | package im.wangchao.http.annotations; 2 | 3 | import java.lang.annotation.Retention; 4 | import java.lang.annotation.Target; 5 | 6 | import static java.lang.annotation.ElementType.FIELD; 7 | import static java.lang.annotation.RetentionPolicy.CLASS; 8 | 9 | /** 10 | *

Description : RequestContentType.

11 | *

12 | *

Author : wangchao.

13 | *

Date : 15/10/31.

14 | *

Time : 下午1:09.

15 | */ 16 | @Retention(CLASS) 17 | @Target(FIELD) 18 | public @interface RequestContentType { 19 | /** 20 | * request Content-Type 21 | */ 22 | String value(); 23 | } 24 | -------------------------------------------------------------------------------- /app/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 /Users/wangchao/Work/android-sdk/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 | -------------------------------------------------------------------------------- /mhttp-adapter/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 /Users/wangchao/Android/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 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 14 |