├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── xj │ │ └── networklibrary │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── xj │ │ │ └── networklibrary │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── xj │ └── networklibrary │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── library ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── xj │ │ └── network │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── xj │ │ │ └── network │ │ │ ├── HttpException.java │ │ │ ├── IResponseListener.java │ │ │ ├── LogUtil.java │ │ │ ├── NetManger.java │ │ │ ├── NetRequest.java │ │ │ ├── NetUtils.java │ │ │ ├── NetworkOption.java │ │ │ ├── Utils.java │ │ │ ├── mtOkHttp │ │ │ ├── LoggingInterceptor.java │ │ │ ├── OKHttpRequest.java │ │ │ └── OKHttpUtils.java │ │ │ ├── okhttp │ │ │ ├── HttpsUtils.java │ │ │ ├── JsonUtils.java │ │ │ ├── client │ │ │ │ └── CommonOkhttpClient.java │ │ │ ├── exception │ │ │ │ └── OkHttpException.java │ │ │ ├── listener │ │ │ │ ├── DisposeDataHandle.java │ │ │ │ ├── DisposeDataListener.java │ │ │ │ ├── DisposeDownloadListener.java │ │ │ │ └── DisposeHandleCookieListener.java │ │ │ ├── request │ │ │ │ ├── CommonRequest.java │ │ │ │ └── RequestParams.java │ │ │ └── response │ │ │ │ ├── CommonFileCallback.java │ │ │ │ └── CommonJsonCallback.java │ │ │ └── volley │ │ │ └── VolleyRequest.java │ └── res │ │ └── values │ │ └── strings.xml │ └── test │ └── java │ └── xj │ └── network │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | /svip-club/ 11 | /gradle.properties 12 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.1" 6 | defaultConfig { 7 | applicationId "xj.networklibrary" 8 | minSdkVersion 21 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:26.+' 28 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 29 | testCompile 'junit:junit:4.12' 30 | compile project(':library') 31 | } 32 | -------------------------------------------------------------------------------- /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 C:\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 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/androidTest/java/xj/networklibrary/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package xj.networklibrary; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("xj.networklibrary", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/xj/networklibrary/MainActivity.java: -------------------------------------------------------------------------------- 1 | package xj.networklibrary; 2 | 3 | import android.os.Bundle; 4 | import android.os.Looper; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.util.Log; 7 | import android.view.View; 8 | import android.widget.Button; 9 | import android.widget.TextView; 10 | 11 | import java.util.HashMap; 12 | 13 | import xj.network.HttpException; 14 | import xj.network.IResponseListener; 15 | import xj.network.LogUtil; 16 | import xj.network.NetManger; 17 | import xj.network.mtOkHttp.OKHttpRequest; 18 | import xj.network.volley.VolleyRequest; 19 | 20 | public class MainActivity extends AppCompatActivity { 21 | 22 | private static final String TAG = "MainActivity"; 23 | 24 | String url = "http://route.showapi.com/109-34"; 25 | private Button mBtnGet; 26 | private Button mBtnPush; 27 | private TextView mTv; 28 | private HashMap mMap; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_main); 34 | initView(); 35 | NetManger.init(this); 36 | LogUtil.init(this); 37 | mMap = new HashMap<>(); 38 | mMap.put("showapi_appid","29571"); 39 | mMap.put("showapi_sign","5bf00910e04a46998f6979f6da400f1e"); 40 | } 41 | 42 | private void initView() { 43 | mBtnGet = (Button) findViewById(R.id.btn_get); 44 | mBtnPush = (Button) findViewById(R.id.btn_push); 45 | mTv = (TextView) findViewById(R.id.tv); 46 | mBtnGet.setOnClickListener(new View.OnClickListener() { 47 | @Override 48 | public void onClick(View v) { 49 | NetManger.getRequest(OKHttpRequest.class).doGet(url, mMap, new IResponseListener() { 50 | @Override 51 | public void onResponse(String response) { 52 | mTv.setText("GET 请求\n"+response); 53 | boolean b = Looper.getMainLooper() == Looper.myLooper(); 54 | LogUtil.i(TAG,"onResponse: b="+b); 55 | LogUtil.i(TAG,"onResponse: response ="+response); 56 | } 57 | 58 | @Override 59 | public void onFail(HttpException httpException) { 60 | Log.i(TAG, "onFail: httpException=" +httpException.toString()); 61 | } 62 | }); 63 | } 64 | }); 65 | mBtnPush.setOnClickListener(new View.OnClickListener() { 66 | @Override 67 | public void onClick(View v) { 68 | NetManger.getRequest(VolleyRequest.class).doPost(url, mMap, new IResponseListener() { 69 | @Override 70 | public void onResponse(String response) { 71 | mTv.setText("post 请求\n"+response); 72 | LogUtil.i(TAG,"onResponse: response ="+response); 73 | } 74 | 75 | @Override 76 | public void onFail(HttpException httpException) { 77 | Log.i(TAG, "onFail: httpException=" +httpException.toString()); 78 | } 79 | }); 80 | } 81 | }); 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 |