response) {
38 | ARouter.getInstance()
39 | .build(ARouterConstant.ROUTE_LOGIN_LOGINSUCCESSACTIVITY)
40 | .withString(Constant.USER_NAME,response.getData().getUsername())
41 | .navigation();
42 | }
43 | });
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/login/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | LoginModule
3 |
4 |
--------------------------------------------------------------------------------
/login/src/test/java/com/login/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.login;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/module_home/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_home/build.gradle:
--------------------------------------------------------------------------------
1 | //if (isHomeNeedDebug.toBoolean()) {//需要单独调试的话,则可以单独运行
2 | // apply plugin: 'com.android.application'
3 | //} else {//不需要单独调试则作为一个library包被引入
4 | apply plugin: 'com.android.library'
5 | //}
6 | apply plugin: 'com.jakewharton.butterknife'
7 |
8 | android {
9 | compileSdkVersion rootProject.ext.compileSdkVersion
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.minSdkVersion
12 | targetSdkVersion rootProject.ext.targetSdkVersion
13 | versionCode rootProject.ext.versionCode
14 | versionName rootProject.ext.versionName
15 | multiDexEnabled true
16 |
17 | javaCompileOptions {
18 | annotationProcessorOptions {
19 | arguments = [moduleName: project.getName()]
20 | }
21 | }
22 |
23 | }
24 |
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 |
32 | //根据是否为单独调试,来加载不同的清单文件
33 | sourceSets {
34 | main {
35 | if (isHomeNeedDebug.toBoolean()) {//需要单独调试的话
36 | manifest.srcFile 'src/debug/AndroidManifest.xml'
37 | } else {//不需要单独调试
38 | manifest.srcFile 'src/main/AndroidManifest.xml'
39 | java {
40 | //全部Module一起编译的时候剔除debug目录
41 | exclude '**/debug/**'
42 | }
43 | }
44 | }
45 | }
46 |
47 | compileOptions {
48 | sourceCompatibility JavaVersion.VERSION_1_8
49 | targetCompatibility JavaVersion.VERSION_1_8
50 | }
51 |
52 | }
53 |
54 | dependencies {
55 | implementation fileTree(dir: 'libs', include: ['*.jar'])
56 |
57 | api project(':rthttp')
58 |
59 | annotationProcessor rootProject.ext.arouterCompiler
60 | annotationProcessor rootProject.ext.daggerCompiler
61 | annotationProcessor rootProject.ext.butterknifeCompiler
62 | }
63 |
--------------------------------------------------------------------------------
/module_home/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/module_home/src/androidTest/java/com/home/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.home;
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 | * Instrumented 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("com.home", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module_home/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/module_home/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/module_home/src/main/java/com/home/HomeActivity.java:
--------------------------------------------------------------------------------
1 | package com.home;
2 |
3 | import com.alibaba.android.arouter.facade.annotation.Route;
4 | import com.resource.base.BaseActivity;
5 | import com.resource.common.ARouterConstant;
6 |
7 | @Route(path = ARouterConstant.ROUTE_HOME_MAINACTIVITY)
8 | public class HomeActivity extends BaseActivity {
9 | @Override
10 | public int initLayout() {
11 | return R.layout.activity_home;
12 | }
13 |
14 | @Override
15 | public void initView() {
16 |
17 | }
18 |
19 | @Override
20 | public void initData() {
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/module_home/src/main/res/layout/activity_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/module_home/src/test/java/com/home/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.home;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/resource/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/resource/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jakewharton.butterknife'
3 |
4 | android {
5 | compileSdkVersion rootProject.ext.compileSdkVersion
6 | buildToolsVersion rootProject.ext.buildToolsVersion
7 |
8 | defaultConfig {
9 | minSdkVersion rootProject.ext.minSdkVersion
10 | targetSdkVersion rootProject.ext.targetSdkVersion
11 | versionCode rootProject.ext.versionCode
12 | versionName rootProject.ext.versionName
13 |
14 | multiDexEnabled true
15 |
16 | javaCompileOptions {
17 | annotationProcessorOptions {
18 | arguments = [moduleName: project.getName()]
19 | }
20 | }
21 |
22 | }
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | sourceSets {
30 | main {
31 | res.srcDirs =
32 | [
33 | 'src/main/res/layout/activity_layout',
34 | 'src/main/res/layout/fragment_layout',
35 | 'src/main/res/layout/dialog_layout',
36 | 'src/main/res/layout/item_layout',
37 | 'src/main/res/layout/common_layout',
38 | 'src/main/res/layout',
39 | 'src/main/res'
40 | ]
41 | }
42 | }
43 |
44 | compileOptions {
45 | sourceCompatibility JavaVersion.VERSION_1_8
46 | targetCompatibility JavaVersion.VERSION_1_8
47 | }
48 |
49 | }
50 |
51 | dependencies {
52 | provided fileTree(include: ['*.jar'], dir: 'libs')
53 | testImplementation rootProject.ext.junit
54 | androidTestCompile rootProject.ext.junit
55 | testCompile rootProject.ext.junit
56 | compile rootProject.ext.appcompat
57 | compile rootProject.ext.support
58 | compile rootProject.ext.contraintLayout
59 | //RecyclerView列表
60 | compile rootProject.ext.recyclerView
61 | //Metrail Design
62 | compile rootProject.ext.design
63 | //Glide图片加载
64 | compile(rootProject.ext.glide) {
65 | exclude group: "com.android.support"
66 | }
67 | annotationProcessor rootProject.ext.glideCompiler
68 | //EventBus
69 | compile rootProject.ext.eventBus
70 | //权限
71 | compile rootProject.ext.easyPermission
72 | //dagger
73 | compile rootProject.ext.dagger
74 | annotationProcessor rootProject.ext.daggerCompiler
75 | //Rxlifecycle
76 | compile rootProject.ext.rxlifecyxle
77 | compile rootProject.ext.rxlifecyxleComponents
78 | //ButterKnife
79 | compile rootProject.ext.butterknife
80 | annotationProcessor rootProject.ext.butterknifeCompiler
81 | //ARouter路由跳转
82 | compile rootProject.ext.arouterApi
83 | annotationProcessor rootProject.ext.arouterCompiler
84 | }
85 |
--------------------------------------------------------------------------------
/resource/libs/mpandroidchartlibrary-2-1-3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/libs/mpandroidchartlibrary-2-1-3.jar
--------------------------------------------------------------------------------
/resource/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 | -ignorewarning
--------------------------------------------------------------------------------
/resource/src/androidTest/java/com/resource/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.resource;
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 | * Instrumented 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("com.resource.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/resource/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.resource.base;
2 |
3 |
4 | import android.content.pm.ActivityInfo;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.view.WindowManager;
9 | import android.widget.Toast;
10 |
11 | import org.greenrobot.eventbus.EventBus;
12 | import org.greenrobot.eventbus.Subscribe;
13 |
14 | import butterknife.ButterKnife;
15 |
16 | /**
17 | * Author: 张
18 | * Email: 1271396448@qq.com
19 | * Date 2018/10/15
20 | *
21 | * Activity基类
22 | */
23 |
24 | public abstract class BaseActivity extends AppCompatActivity {
25 |
26 | // /***是否显示标题栏*/
27 | // private boolean isshowtitle = true;
28 | // /***是否显示标题栏*/
29 | // private boolean isshowstate = true;
30 | /***封装toast对象**/
31 | private static Toast toast;
32 | /***获取TAG的activity名称**/
33 | protected final String TAG = this.getClass().getSimpleName();
34 | @Subscribe
35 | @Override
36 | protected void onCreate(@Nullable Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 |
39 | if(useEventBus())//如果使用EventBus,请在子类实现此方法,返回true
40 | EventBus.getDefault().register(this);
41 | //设置布局
42 | setContentView(initLayout());
43 | ButterKnife.bind(this);
44 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
45 | initIntent();
46 | //初始化控件
47 | initView();
48 | //设置数据
49 | initListener();
50 | initData();
51 | }
52 |
53 | //如果使用EventBus,请在子类实现此方法,返回true
54 | public boolean useEventBus(){
55 | return false;
56 | }
57 |
58 | /**
59 | * 设置布局
60 | *
61 | * @return
62 | */
63 | public abstract int initLayout();
64 |
65 | /**
66 | * 初始化布局
67 | */
68 | public abstract void initView();
69 |
70 | /**
71 | * 初始化intent
72 | */
73 | public void initIntent(){};
74 |
75 | /**
76 | * 设置数据
77 | */
78 | public abstract void initData();
79 |
80 | /**
81 | * 点击事件
82 | */
83 | public void initListener(){};
84 |
85 | @Override
86 | protected void onDestroy() {
87 | super.onDestroy();
88 | if(useEventBus())//如果使用EventBus,请在子类实现此方法,返回true
89 | EventBus.getDefault().unregister(this);
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.resource.base;
2 |
3 | import android.app.Application;
4 |
5 | import com.alibaba.android.arouter.launcher.ARouter;
6 | import com.resource.BuildConfig;
7 | import com.resource.base.di.AppModule;
8 | import com.resource.base.di.component.AppComponent;
9 | import com.resource.base.di.component.DaggerAppComponent;
10 | import com.resource.util.AppComponentUtil;
11 | import com.resource.util.SpUtil;
12 | import com.resource.util.Utils;
13 |
14 |
15 | /**
16 | * Author: 张
17 | * Email: 1271396448@qq.com
18 | * Date 2018/10/16
19 | *
20 | * 全局配置类
21 | */
22 |
23 | public class BaseApplication extends Application {
24 |
25 | @Override
26 | public void onCreate() {
27 | super.onCreate();
28 | Utils.init(this);
29 | SpUtil.init(this);
30 | initDagger();
31 | initARouter();
32 | // FileDownloader.setupOnApplicationOnCreate(this);
33 | }
34 |
35 | //初始化Dagger
36 | private void initDagger() {
37 | AppComponent appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build();
38 | AppComponentUtil.setAppComponent(appComponent);
39 | }
40 |
41 | private void initARouter(){
42 | //如果是调试模式
43 | if(BuildConfig.DEBUG){
44 | ARouter.openLog();//打印日志
45 | ARouter.openDebug();//开启调试模式
46 | ARouter.printStackTrace();//打印日志的时候,打印线程信息
47 | }
48 | //初始化ARouter路由跳转
49 | ARouter.init(this);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.resource.base;
2 |
3 |
4 | import android.annotation.SuppressLint;
5 | import android.os.Bundle;
6 | import android.os.StrictMode;
7 | import android.support.v4.app.Fragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.view.WindowManager;
12 |
13 | import org.greenrobot.eventbus.EventBus;
14 | import org.greenrobot.eventbus.Subscribe;
15 |
16 | import butterknife.ButterKnife;
17 |
18 |
19 | /**
20 | * Author: 张
21 | * Email: 1271396448@qq.com
22 | * Date 2018/10/15
23 | *
24 | * Fragment基类
25 | */
26 |
27 |
28 | public abstract class BaseFragment extends Fragment {
29 |
30 |
31 | protected abstract int setView();
32 |
33 | protected abstract void init(View view);
34 |
35 | protected abstract void initData(Bundle savedInstanceState);
36 |
37 | protected abstract void initListener();
38 |
39 | @SuppressLint("NewApi")
40 | @Override
41 | @Subscribe
42 | public void onCreate(Bundle savedInstanceState) {
43 | super.onCreate(savedInstanceState);
44 | StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
45 | StrictMode.setVmPolicy(builder.build());
46 | builder.detectFileUriExposure();
47 | if (useEventBus()) {//如果使用EventBus,请将此方法返回true
48 | if (!EventBus.getDefault().isRegistered(this))
49 | EventBus.getDefault().register(this);
50 | }
51 | getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
52 | }
53 |
54 | @Override
55 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
56 | Bundle savedInstanceState) {
57 | View rootView = inflater.inflate(setView(), container, false);
58 | ButterKnife.bind(this, rootView);
59 | return rootView;
60 | }
61 |
62 | @Override
63 | public void onViewCreated(View view, Bundle savedInstanceState) {
64 | super.onViewCreated(view, savedInstanceState);
65 | init(view);
66 | initData(savedInstanceState);
67 | initListener();
68 | }
69 |
70 | public boolean useEventBus() {
71 | return false;
72 | }
73 |
74 | @Override
75 | public void onResume() {
76 | super.onResume();
77 | }
78 |
79 | @Override
80 | public void onDestroyView() {
81 | super.onDestroyView();
82 | }
83 |
84 | @Override
85 | public void onDestroy() {
86 | super.onDestroy();
87 | if (useEventBus()) {//如果使用EventBus,请将此方法返回true
88 | if (EventBus.getDefault().isRegistered(this))
89 | EventBus.getDefault().unregister(this);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/di/AppModule.java:
--------------------------------------------------------------------------------
1 | package com.resource.base.di;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.LinearLayoutManager;
5 |
6 | import dagger.Module;
7 | import dagger.Provides;
8 |
9 | /*
10 | * Author: 张
11 | * Email: 1271396448@qq.com
12 | * Date: 2018/10/19.
13 | */
14 | @Module
15 | public class AppModule {
16 | private Context context;
17 |
18 |
19 | public AppModule(Context context) {
20 | this.context = context;
21 | }
22 |
23 | @Provides
24 | public Context context(){
25 | return context;
26 | }
27 |
28 | @Provides
29 | public LinearLayoutManager provideLinearLayoutManager() {
30 | return new LinearLayoutManager(context);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/di/component/AppComponent.java:
--------------------------------------------------------------------------------
1 | package com.resource.base.di.component;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import android.support.v7.widget.LinearLayoutManager;
6 |
7 |
8 | import com.resource.base.di.AppModule;
9 |
10 | import dagger.Component;
11 |
12 |
13 | /*
14 | * Author: 张
15 | * Email: 1271396448@qq.com
16 | * Date: 2018/10/19.
17 | * 基类Model
18 | */
19 |
20 | @Component(modules = {AppModule.class})
21 | public interface AppComponent {
22 | Context context();
23 | LinearLayoutManager provideLinearLayoutManager();
24 | void inject(Application application);
25 | }
26 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/di/scope/ActivityScope.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2015 Fernando Cejas Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /**
17 | * Copyright 2017 JessYan
18 | *
19 | * Licensed under the Apache License, Version 2.0 (the "License");
20 | * you may not use this file except in compliance with the License.
21 | * You may obtain a copy of the License at
22 | *
23 | * http://www.apache.org/licenses/LICENSE-2.0
24 | *
25 | * Unless required by applicable law or agreed to in writing, software
26 | * distributed under the License is distributed on an "AS IS" BASIS,
27 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 | * See the License for the specific language governing permissions and
29 | * limitations under the License.
30 | */
31 | package com.resource.base.di.scope;
32 |
33 | import java.lang.annotation.Documented;
34 | import java.lang.annotation.Retention;
35 |
36 | import javax.inject.Scope;
37 |
38 | import static java.lang.annotation.RetentionPolicy.RUNTIME;
39 |
40 | /*
41 | * Author: 张
42 | * Email: 1271396448@qq.com
43 | * Date: 2018/10/19.
44 | * 基类Model
45 | */
46 |
47 | @Scope
48 | @Documented
49 | @Retention(RUNTIME)
50 | public @interface ActivityScope {}
51 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/mvp/BaseModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.resource.base.mvp;
17 |
18 | import android.arch.lifecycle.Lifecycle;
19 | import android.arch.lifecycle.LifecycleObserver;
20 | import android.arch.lifecycle.LifecycleOwner;
21 | import android.arch.lifecycle.OnLifecycleEvent;
22 |
23 | import com.resource.base.mvp.interfaces.IModel;
24 |
25 | /*
26 | * Author: 张
27 | * Email: 1271396448@qq.com
28 | * Date: 2018/10/19.
29 | * 基类Model
30 | */
31 |
32 | public class BaseModel implements IModel, LifecycleObserver {
33 | // protected IRepositoryManager mRepositoryManager;//用于管理网络请求层,以及数据缓存层
34 |
35 | public BaseModel(/*IRepositoryManager repositoryManager*/) {
36 | //this.mRepositoryManager = repositoryManager;
37 | }
38 |
39 | /**
40 | * 在框架中 {@link BasePresenter#onDestroy()} 时会默认调用 {@link IModel#onDestroy()}
41 | */
42 | @Override
43 | public void onDestroy() {
44 | //mRepositoryManager = null;
45 | }
46 |
47 | @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
48 | void onDestroy(LifecycleOwner owner) {
49 | owner.getLifecycle().removeObserver(this);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/mvp/interfaces/IActivity.java:
--------------------------------------------------------------------------------
1 | package com.resource.base.mvp.interfaces;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentManager;
6 |
7 | import com.resource.base.di.component.AppComponent;
8 |
9 | /*
10 | * Author: 张
11 | * Email: 1271396448@qq.com
12 | * Date: 2018/10/19.
13 | * 框架要求框架中的每个 {@link Activity} 都需要实现此类,以满足规范
14 | */
15 |
16 | public interface IActivity {
17 |
18 |
19 |
20 | /**
21 | * 提供 AppComponent(提供所有的单例对象)给实现类,进行 Component 依赖
22 | *
23 | * @param appComponent
24 | */
25 | void setupActivityComponent(AppComponent appComponent);
26 |
27 | /**
28 | * 是否使用 {@link org.greenrobot.eventbus.EventBus}
29 | *
30 | * @return
31 | */
32 | boolean useEventBus();
33 |
34 | /**
35 | * 初始化 View,如果initView返回0,框架则不会调用{@link Activity#setContentView(int)}
36 | *
37 | * @param savedInstanceState
38 | * @return
39 | */
40 | int setContentView(Bundle savedInstanceState);
41 |
42 | void initView();
43 | /**
44 | * 初始化数据
45 | *
46 | * @param savedInstanceState
47 | */
48 | void initData(Bundle savedInstanceState);
49 |
50 | /**
51 | * 这个Activity是否会使用Fragment,框架会根据这个属性判断是否注册{@link FragmentManager.FragmentLifecycleCallbacks}
52 | * 如果返回false,那意味着这个Activity不需要绑定Fragment,那你再在这个Activity中绑定继承于 {@link MvpBaseFragment} 的Fragment将不起任何作用
53 | *
54 | * @return
55 | */
56 | boolean useFragment();
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/mvp/interfaces/IModel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.resource.base.mvp.interfaces;
17 | /*
18 | * Author: 张
19 | * Email: 1271396448@qq.com
20 | * Date: 2018/10/19.
21 | * 框架要求框架中的每个 Model 都需要实现此类,以满足规范
22 | */
23 |
24 |
25 | import com.resource.base.mvp.BasePresenter;
26 |
27 | public interface IModel {
28 |
29 | /**
30 | * 在框架中 {@link BasePresenter#onDestroy()} 时会默认调用 {@link IModel#onDestroy()}
31 | */
32 | void onDestroy();
33 | }
34 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/mvp/interfaces/IPresenter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.resource.base.mvp.interfaces;
17 |
18 | import android.app.Activity;
19 |
20 | /*
21 | * Author: 张
22 | * Email: 1271396448@qq.com
23 | * Date: 2018/10/19.
24 | * 框架要求框架中的每个 Presenter 都需要实现此类,以满足规范
25 | */
26 |
27 | public interface IPresenter {
28 |
29 | /**
30 | * 做一些初始化操作
31 | */
32 | void onStart();
33 |
34 | /**
35 | * 在框架中 {@link Activity#onDestroy()} 时会默认调用 {@link IPresenter#onDestroy()}
36 | */
37 | void onDestroy();
38 | }
39 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/mvp/interfaces/IView.java:
--------------------------------------------------------------------------------
1 | package com.resource.base.mvp.interfaces;
2 | /*
3 | * Author: 张
4 | * Email: 1271396448@qq.com
5 | * Date: 2018/10/19.
6 | * 框架要求框架中的每个 View 都需要实现此类,以满足规范
7 | */
8 | public interface IView {
9 |
10 | /**
11 | * 显示信息
12 | */
13 | void showMessage(String message);
14 |
15 | }
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/other/AppLifecycles.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 JessYan
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.resource.base.other;
17 |
18 | import android.app.Application;
19 | import android.content.Context;
20 | import android.support.annotation.NonNull;
21 | /*
22 | * Author: 张
23 | * Email: 1271396448@qq.com
24 | * Date: 2018/10/19.
25 | * 用于代理 {@link Application} 的生命周期
26 | */
27 |
28 | public interface AppLifecycles {
29 | void attachBaseContext(@NonNull Context base);
30 |
31 | void onCreate(@NonNull Application application);
32 |
33 | void onTerminate(@NonNull Application application);
34 | }
35 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/base/other/AppManager.java:
--------------------------------------------------------------------------------
1 | package com.resource.base.other;
2 |
3 | import android.app.Activity;
4 | import android.app.ActivityManager;
5 | import android.content.Context;
6 | import android.util.Log;
7 |
8 | import java.util.Iterator;
9 | import java.util.Stack;
10 |
11 | /*
12 | * Author: 张
13 | * Email: 1271396448@qq.com
14 | * Date: 2018/10/19.
15 | */
16 |
17 | public class AppManager {
18 | private static Stack activityStack;
19 | private static AppManager instance;
20 |
21 | /**
22 | * 单例模式实例
23 | */
24 | public static AppManager getAppManager() {
25 | if (instance == null) {
26 | instance = new AppManager();
27 | }
28 | return instance;
29 | }
30 |
31 | /**
32 | * 添加Activity到堆栈
33 | */
34 | public void addActivity(Activity activity) {
35 | if (activityStack == null) {
36 | activityStack = new Stack();
37 | }
38 | activityStack.add(activity);
39 | }
40 |
41 | /**
42 | * 获取当前Activity(堆栈中最后一个压入的)
43 | */
44 | public Activity currentActivity() {
45 | return activityStack.lastElement();
46 | }
47 |
48 | /**
49 | * 结束当前Activity(堆栈中最后一个压入的)
50 | */
51 | public void finishActivity() {
52 | Activity activity = activityStack.lastElement();
53 | if (activity != null) {
54 | activity.finish();
55 | activity = null;
56 | }
57 | }
58 |
59 | /**
60 | * 结束指定的Activity
61 | */
62 | public void finishActivity(Activity activity) {
63 | if (activity != null && activityStack != null) {
64 | activityStack.remove(activity);
65 | activity.finish();
66 | activity = null;
67 | }
68 | }
69 |
70 | /**
71 | * 结束指定类名的Activity
72 | */
73 | public void finishActivity(Class> cls) {
74 | for (Activity activity : activityStack) {
75 | if (activity.getClass().equals(cls)) {
76 | finishActivity(activity);
77 | }
78 | }
79 | }
80 |
81 | /**
82 | * 结束所有Activity
83 | */
84 | public void finishAllActivity() {
85 | for (int i = 0, size = activityStack.size(); i < size; i++) {
86 | if (null != activityStack.get(i)) {
87 | activityStack.get(i).finish();
88 | }
89 | }
90 | activityStack.clear();
91 | }
92 |
93 | /**
94 | * 结束除当前传入以外所有Activity
95 | */
96 | public void finishOthersActivity(Class> cls) {
97 | if (activityStack != null) {
98 | Iterator iterator = activityStack.iterator();
99 | while (iterator.hasNext()) {
100 | Activity activity = iterator.next();
101 | if (!activity.getClass().equals(cls)) {
102 | iterator.remove();
103 | activity.finish();
104 | }
105 | }
106 | }
107 | }
108 |
109 | /**
110 | * 退出应用程序
111 | */
112 | public void AppExit(Context context) {
113 | try {
114 | finishAllActivity();
115 | ActivityManager activityMgr = (ActivityManager) context
116 | .getSystemService(Context.ACTIVITY_SERVICE);
117 | activityMgr.restartPackage(context.getPackageName());
118 | System.exit(0);
119 | } catch (Exception e) {
120 | }
121 | }
122 |
123 | public void getAllClass(Class clazz) {
124 | for (int i = 0; i < activityStack.size(); i++) {
125 | String name = activityStack.get(i).getClass().getName();
126 | Log.i("----",clazz.getName() + ": " + name);
127 | }
128 | }
129 |
130 | }
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/bean/CustomPieChartBean.java:
--------------------------------------------------------------------------------
1 | package com.resource.bean;
2 |
3 | /**
4 | * Author: 张
5 | * Email: 1271396448@qq.com
6 | * Date 2018/11/29
7 | *
8 | * 饼状图颜色,值,bean类
9 | */
10 |
11 | public class CustomPieChartBean {
12 | public float percent;//值,占比
13 | public String content;//名字,
14 | public int color;//颜色
15 |
16 | public CustomPieChartBean(float percent, int color) {
17 | this.percent = percent;
18 | this.color = color;
19 | }
20 |
21 | public float getPercent() {
22 | return percent;
23 | }
24 |
25 | public void setPercent(float percent) {
26 | this.percent = percent;
27 | }
28 |
29 | public String getContent() {
30 | return content;
31 | }
32 |
33 | public void setContent(String content) {
34 | this.content = content;
35 | }
36 |
37 | public int getColor() {
38 | return color;
39 | }
40 |
41 | public void setColor(int color) {
42 | this.color = color;
43 | }
44 |
45 | public CustomPieChartBean() {
46 | super();
47 | }
48 |
49 | public CustomPieChartBean(float percent, String content, int color) {
50 | this.percent = percent;
51 | this.content = content;
52 | this.color = color;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/common/ARouterConstant.java:
--------------------------------------------------------------------------------
1 | package com.resource.common;
2 |
3 | /**
4 | * Author: 张
5 | * Email: 1271396448@qq.com
6 | * Date 2018/10/31
7 | *
8 | * ARouter 路由跳转 路径封装类
9 | */
10 |
11 | public class ARouterConstant {
12 | //主模块
13 | public final static String ROUTE_MAIN_MAINACTIVITY = "/app/activity/mainactivity";
14 |
15 | //登录模块
16 | public final static String ROUTE_LOGIN_LOGINACTIVITY = "/login/activity/loginactivity";
17 | public final static String ROUTE_LOGIN_LOGINSUCCESSACTIVITY = "/login/activity/loginsuccessactivity";
18 |
19 | //首页模块
20 | public final static String ROUTE_HOME_MAINACTIVITY = "/home/activity/mainactivity";
21 | }
22 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/common/Constant.java:
--------------------------------------------------------------------------------
1 | package com.resource.common;
2 |
3 | /**
4 | * Author: 张
5 | * Email: 1271396448@qq.com
6 | * Date 2018/10/16
7 | *
8 | * 全局参数封装类
9 | */
10 |
11 | public class Constant {
12 |
13 | public final static String GIF1 = "https://gss0.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/zhidao/wh%3D600%2C800/sign=c88da0db16178a82ce6977a6c6335fb5/c83d70cf3bc79f3db277be27b2a1cd11728b2916.jpg";
14 |
15 | public final static int IMAGE_SURFACE_CODE = 100;
16 | public final static int IMAGE_CAMERA_CODE = 101;
17 | public final static int IMAGE_PICK_CODE = 102;
18 | public final static int IMAGE_MORE_PICK_CODE = 104;
19 |
20 | public final static int MY_PERMISSION_CODE = 105;
21 |
22 | public final static String BASE_URL = "base_url";
23 |
24 | //定位基本信息
25 | public final static String LOCATION_ADDRESS = "location_address";//地址
26 | public final static String LOCATION_LONGITUDE = "location_longitude";//经度
27 | public final static String LOCATION_LATITUDE = "location_latitude";//维度
28 | public final static String LOCATION_COUNTRY = "location_country";//国家信息
29 | public final static String LOCATION_PROVINCE = "location_province";//省
30 | public final static String LOCATION_CITY = "location_city";//市
31 | public final static String LOCATION_DISTRICT = "location_district";//区县
32 | public final static String LOCATION_STREET = "location_street";//街道
33 | public final static String LOCATION_STREET_NUM = "location_street_num";//街道门牌号
34 | public final static String LOCATION_CITY_CODE = "location_city_code";//城市编码
35 | public final static String LOCATION_AD_CODE = "location_ad_code";//地区编码
36 | public final static String LOCATION_AOI_NAME = "location_aoi_name";//当前定位点的AOI信息
37 |
38 | //用户基本信息
39 | public final static String USER_TOKEN = "user_token";
40 | public final static String USER_NAME = "user_name";
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/ARouterUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 |
4 | import com.alibaba.android.arouter.launcher.ARouter;
5 |
6 | /**
7 | * Author: 张
8 | * Email: 1271396448@qq.com
9 | * Date 2018/10/31
10 | *
11 | * ARouter路由跳转
12 | */
13 |
14 | public class ARouterUtil {
15 |
16 | public static void start(String path){
17 | ARouter.getInstance().build(path).navigation();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/AppComponentUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 |
4 | import com.resource.base.di.component.AppComponent;
5 |
6 | /**
7 | * Author: 张
8 | * Email: 1271396448@qq.com
9 | * Date 2017/9/15
10 | */
11 |
12 | public class AppComponentUtil {
13 | private static AppComponent sAppComponent;
14 |
15 | public static void setAppComponent(AppComponent appComponent){
16 | sAppComponent = appComponent;
17 | }
18 |
19 | public static AppComponent getAppComponent(){
20 | return sAppComponent;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/Base64Util.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.graphics.Bitmap;
4 | import android.graphics.BitmapFactory;
5 | import android.util.Base64;
6 |
7 | /**
8 | * Author: 张
9 | * Email: 1271396448@qq.com
10 | * Date 2018/10/24
11 | *
12 | * Base64转码解码工具类
13 | */
14 |
15 | public class Base64Util {
16 |
17 |
18 | /**
19 | * Base64码转为图片文件
20 | * @return
21 | */
22 | public static Bitmap base64ToBitmap(String string) {
23 | Bitmap bitmap = null;
24 | try {
25 | byte[] bitmapArray = Base64.decode(string.split(",")[1], Base64.DEFAULT);
26 | bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
27 | } catch (Exception e) {
28 | e.printStackTrace();
29 | }
30 | return bitmap;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/DestroyActivityUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.app.Activity;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import java.util.Set;
8 |
9 | /**
10 | * Author: 张
11 | * Email: 1271396448@qq.com
12 | * Date 2018/12/5
13 | *
14 | * 销毁指定Activity
15 | */
16 |
17 | public class DestroyActivityUtil {
18 |
19 | private static Map destoryMap = new HashMap<>();
20 |
21 | //将Activity添加到队列中
22 | public static void addDestoryActivityToMap(Activity activity, String activityName) {
23 | destoryMap.put(activityName, activity);
24 | }
25 |
26 | //根据名字销毁制定Activity
27 | public static void destoryActivity(String activityName) {
28 | Set keySet = destoryMap.keySet();
29 | LogUtil.i(keySet.size());
30 | if (keySet.size() > 0) {
31 | for (String key : keySet) {
32 | if (activityName.equals(key)) {
33 | destoryMap.get(key).finish();
34 | }
35 | }
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/FileUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.os.AsyncTask;
4 | import android.os.Environment;
5 |
6 | import java.io.BufferedInputStream;
7 | import java.io.File;
8 | import java.io.FileInputStream;
9 | import java.io.FileOutputStream;
10 | import java.io.IOException;
11 | import java.io.InputStream;
12 | import java.io.OutputStream;
13 | import java.net.HttpURLConnection;
14 | import java.net.URL;
15 | import java.net.URLConnection;
16 | import java.text.DecimalFormat;
17 |
18 | /**
19 | * Author: 张
20 | * Email: 1271396448@qq.com
21 | * Date 2018/11/12
22 | *
23 | * 文件工具类
24 | */
25 |
26 | public class FileUtil {
27 |
28 |
29 | private static URL url;
30 |
31 | /**
32 | * 判断文件是否存在
33 | * @param fileName
34 | * @return
35 | */
36 | public static boolean isFileExist(String fileName){
37 | File file = new File(BitmapUtil.getSDPath() + fileName);
38 | return file.exists();
39 | }
40 |
41 | public static InputStream getInputStearmFormUrl(String urlStr) throws IOException {
42 | url = new URL(urlStr);
43 | HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
44 | InputStream input = urlConn.getInputStream();
45 | return input;
46 | }
47 | public static File createDir(String dirName){
48 | File dir = new File(BitmapUtil.getSDPath() + dirName);
49 | dir.mkdir();
50 | return dir;
51 | }
52 |
53 | public static File createSDFile(String fileName) throws IOException {
54 | File file = new File(BitmapUtil.getSDPath() + fileName);
55 | file.createNewFile();
56 | return file;
57 | }
58 |
59 |
60 | public static File write2SDFromInput(String path, String fileName, InputStream input){
61 | File file = null;
62 | OutputStream output = null;
63 |
64 | try {
65 | createDir(path);
66 | file =createSDFile(path + fileName);
67 | output = new FileOutputStream(file);
68 | byte [] buffer = new byte[4 * 1024];
69 | while(input.read(buffer) != -1){
70 | output.write(buffer);
71 | output.flush();
72 | }
73 | } catch (IOException e) {
74 | e.printStackTrace();
75 | }
76 | finally {
77 | try {
78 | output.close();
79 | } catch (IOException e) {
80 | e.printStackTrace();
81 | }
82 | }
83 | return file;
84 | }
85 |
86 | public static int downlaodFile(String urlStr, String path, String fileName) {
87 | InputStream input = null;
88 | try {
89 | if (isFileExist(path + fileName)) {
90 | return 1;
91 | } else {
92 | input = getInputStearmFormUrl(urlStr);
93 | File resultFile = write2SDFromInput(path,fileName,input);
94 | if (resultFile == null)
95 | return -1;
96 | }
97 | } catch (IOException e) {
98 | e.printStackTrace();
99 | return -1;
100 | }
101 | try {
102 | input.close();
103 | } catch (IOException e) {
104 | e.printStackTrace();
105 | }
106 | return 0;
107 | }
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/LogUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.util.Log;
4 |
5 | import java.util.Locale;
6 |
7 |
8 | /**
9 | * Author: 张
10 | * Email: 1271396448@qq.com
11 | * Date 2016/05/18
12 | *
13 | * 日志工具类
14 | */
15 |
16 | public class LogUtil {
17 | private static boolean LOGV = true;
18 | private static boolean LOGD = true;
19 | private static boolean LOGI = true;
20 | private static boolean LOGW = true;
21 | private static boolean LOGE = true;
22 |
23 | /**
24 | * 获取到调用者的类名
25 | * @return 调用者的类名
26 | */
27 | private static String getTag() {
28 | StackTraceElement[] trace = new Throwable().fillInStackTrace()
29 | .getStackTrace();
30 | String callingClass = "";
31 | for (int i = 2; i < trace.length; i++) {
32 | Class> clazz = trace[i].getClass();
33 | if (!clazz.equals(LogUtil.class)) {
34 | callingClass = trace[i].getClassName();
35 | callingClass = callingClass.substring(callingClass
36 | .lastIndexOf('.') + 1);
37 | break;
38 | }
39 | }
40 | return callingClass;
41 | }
42 |
43 | //维护找不到当前页面时,打开该页面,log日志搜索--->当前页面
44 | public static void showClassName(){
45 | if(LOGI){
46 | Log.i("当前页面--->",getTag());
47 | }
48 | }
49 |
50 | //不需要再在类中定义TAG,直接打印日志信息
51 | public static void v(String mess) {
52 | if (LOGV) { Log.v(getTag(), mess); }
53 | }
54 | public static void d(Object mess) {
55 | if (LOGD) { Log.d(getTag(), String.valueOf(mess)); }
56 | }
57 | public static void i(Object mess) {
58 | if (LOGI) { Log.i(getTag(), String.valueOf(mess)); }
59 | }
60 | public static void w(String mess) {
61 | if (LOGW) { Log.w(getTag(), mess); }
62 | }
63 | public static void e(String mess) {
64 | if (LOGE) { Log.e(getTag(), mess); }
65 | }
66 |
67 |
68 |
69 | /**
70 | * 获取线程ID,方法名和输出信息
71 | * @param msg
72 | * @return
73 | */
74 | private static String buildMessage(String msg) {
75 | StackTraceElement[] trace = new Throwable().fillInStackTrace()
76 | .getStackTrace();
77 | String caller = "";
78 | for (int i = 2; i < trace.length; i++) {
79 | Class> clazz = trace[i].getClass();
80 | if (!clazz.equals(LogUtil.class)) {
81 | caller = trace[i].getMethodName();
82 | break;
83 | }
84 | }
85 | return String.format(Locale.US, "[%d] %s: %s", Thread.currentThread()
86 | .getId(), caller, msg);
87 | }
88 |
89 | //不需要再在类中定义TAG,打印线程ID,方法名和输出信息
90 | public static void v1(String mess) {
91 | if (LOGV) { Log.v(getTag(), buildMessage(mess)); }
92 | }
93 | public static void d1(String mess) {
94 | if (LOGD) { Log.d(getTag(), buildMessage(mess)); }
95 | }
96 | public static void i1(String mess) {
97 | if (LOGI) { Log.i(getTag(), buildMessage(mess)); }
98 | }
99 | public static void w1(String mess) {
100 | if (LOGW) { Log.w(getTag(), buildMessage(mess)); }
101 | }
102 | public static void e1(String mess) {
103 | if (LOGE) { Log.e(getTag(), buildMessage(mess)); }
104 | }
105 |
106 |
107 | //不需要再在类中定义TAG,打印类名,方法名,行号等.并定位行
108 | public static void v2(String mess) {
109 | if (LOGV) { Log.v(getTag(), getMsgFormat(mess)); }
110 | }
111 | public static void d2(String mess) {
112 | if (LOGD) { Log.d(getTag(), getMsgFormat(mess)); }
113 | }
114 | public static void i2(String mess) {
115 | if (LOGI) { Log.i(getTag(), getMsgFormat(mess)); }
116 | }
117 | public static void w2(String mess) {
118 | if (LOGW) { Log.w(getTag(), getMsgFormat(mess)); }
119 | }
120 | public static void e2(String mess) {
121 | if (LOGE) { Log.e(getTag(), getMsgFormat(mess)); }
122 | }
123 |
124 | /**
125 | * 获取相关数据:类名,方法名,行号等.用来定位行
126 | * @return
127 | */
128 | private static String getFunctionName() {
129 | StackTraceElement[] sts = Thread.currentThread().getStackTrace();
130 | if (sts != null) {
131 | for (StackTraceElement st : sts) {
132 | if (st.isNativeMethod()) {
133 | continue;
134 | }
135 | if (st.getClassName().equals(Thread.class.getName())) {
136 | continue;
137 | }
138 | if (st.getClassName().equals(LogUtil.class.getName())) {
139 | continue;
140 | }
141 | return "[ Thread:" + Thread.currentThread().getName() + ", at " + st.getClassName() + "." + st.getMethodName()
142 | + "(" + st.getFileName() + ":" + st.getLineNumber() + ")" + " ]";
143 | }
144 | }
145 | return null;
146 | }
147 |
148 | /**
149 | * 输出格式定义
150 | * @param msg
151 | * @return
152 | */
153 | private static String getMsgFormat(String msg) {
154 | return msg + " ;" + getFunctionName();
155 | }
156 | }
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/NetworkUtils.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.content.Context;
4 | import android.location.LocationManager;
5 | import android.net.ConnectivityManager;
6 | import android.net.NetworkInfo;
7 | import android.telephony.TelephonyManager;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * Author: 张
13 | * Email: 1271396448@qq.com
14 | * Date 2018/11/30
15 | *
16 | * 网络工具类
17 | */
18 |
19 | public class NetworkUtils {
20 |
21 | /**
22 | * 网络是否可用
23 | */
24 | public static boolean isNetworkAvailable() {
25 | ConnectivityManager connectivity = (ConnectivityManager) Utils.getApp()
26 | .getSystemService(Context.CONNECTIVITY_SERVICE);
27 | if (connectivity == null) {
28 | } else {
29 | NetworkInfo[] info = connectivity.getAllNetworkInfo();
30 | if (info != null) {
31 | for (int i = 0; i < info.length; i++) {
32 | if (info[i].getState() == NetworkInfo.State.CONNECTED) {
33 | return true;
34 | }
35 | }
36 | }
37 | }
38 | return false;
39 | }
40 |
41 | /**
42 | * Gps是否打开
43 | */
44 | public static boolean isGpsEnabled(Context context) {
45 | LocationManager locationManager = ((LocationManager) context
46 | .getSystemService(Context.LOCATION_SERVICE));
47 | List accessibleProviders = locationManager.getProviders(true);
48 | return accessibleProviders != null && accessibleProviders.size() > 0;
49 | }
50 |
51 | /**
52 | * 判断当前网络是否是wifi网络
53 | * if(activeNetInfo.getType()==ConnectivityManager.TYPE_MOBILE) {
54 | */
55 | public static boolean isWifi(Context context) {
56 | ConnectivityManager connectivityManager = (ConnectivityManager) context
57 | .getSystemService(Context.CONNECTIVITY_SERVICE);
58 | NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
59 | if (activeNetInfo != null
60 | && activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) {
61 | return true;
62 | }
63 | return false;
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/SoftKeyBoardUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.view.View;
6 | import android.view.inputmethod.InputMethodManager;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Author: 张
12 | * Email: 1271396448@qq.com
13 | * Date 2018/11/8
14 | *
15 | * 软键盘隐藏显示 工具类
16 | */
17 |
18 | public class SoftKeyBoardUtil {
19 |
20 |
21 | //隐藏软键盘
22 | public static void hideSoftKeyboard(Context context, List viewList) {
23 | if (viewList == null) return;
24 |
25 | InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
26 |
27 | for (View v : viewList) {
28 | inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
29 | }
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/SpUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | /**
7 | * Author: 张
8 | * Email: 1271396448@qq.com
9 | * Date 2016/10/16
10 | *
11 | * SharedPrefences数据库工具类
12 | */
13 |
14 | public class SpUtil {
15 |
16 | public static SharedPreferences sp;
17 | public static SharedPreferences.Editor edit;
18 |
19 | public static void init(Context context){
20 | sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
21 | edit = sp.edit();
22 | }
23 |
24 |
25 | /**
26 | * obj仅限int,float,boolean,long,String类型
27 | */
28 | public static void put(String key, Object obj) {
29 | SharedPreferences.Editor editor = sp.edit();
30 | if (obj instanceof String) {
31 | editor.putString(key, (String) obj);
32 | } else if (obj instanceof Integer) {
33 | editor.putInt(key, (int) obj);
34 | } else if (obj instanceof Boolean) {
35 | editor.putBoolean(key, (boolean) obj);
36 | } else if (obj instanceof Float) {
37 | editor.putFloat(key, (float) obj);
38 | }
39 | editor.apply();
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/SurfaceCameraUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.hardware.Camera;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * @Author: 张
9 | * @Email: 1271396448@qq.com
10 | * @Date 2019/1/22 13:38
11 | *
12 | * 自定义相机工具类
13 | */
14 |
15 | public class SurfaceCameraUtil {
16 |
17 | /**
18 | * 打开相机
19 | */
20 | public static Camera openCamera() {
21 | Camera c = null;
22 | try {
23 | c = Camera.open();
24 | } catch (Exception e) {
25 | }
26 | return c;
27 | }
28 |
29 | /**
30 | * Android相机的预览尺寸都是4:3或者16:9,这里遍历所有支持的预览尺寸,得到16:9的最大尺寸,保证成像清晰度
31 | *
32 | * @param sizes
33 | * @return 最佳尺寸
34 | */
35 | public static Camera.Size getBestSize(List sizes) {
36 | Camera.Size bestSize = null;
37 | for (Camera.Size size : sizes) {
38 | if ((float) size.width / (float) size.height == 16.0f / 9.0f) {
39 | if (bestSize == null) {
40 | bestSize = size;
41 | } else {
42 | if (size.width > bestSize.width) {
43 | bestSize = size;
44 | }
45 | }
46 | }
47 | }
48 | return bestSize;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.view.Gravity;
4 | import android.view.View;
5 | import android.widget.Toast;
6 |
7 | import com.resource.R;
8 |
9 | /**
10 | * Author: 张
11 | * Email: 1271396448@qq.com
12 | * Date 2017/6/12
13 | *
14 | * 吐司工具类
15 | */
16 |
17 | public class ToastUtil {
18 |
19 | private static Toast mToast;
20 |
21 | //中间弹窗
22 | public static void showCenterToast(int resId){
23 | if(mToast == null){
24 | mToast = Toast.makeText(Utils.getApp(),resId,Toast.LENGTH_LONG);
25 | mToast.setGravity(Gravity.CENTER,0,0);
26 | }else{
27 | mToast.setText(resId);
28 | }
29 | mToast.show();
30 | }
31 |
32 | //中间弹窗
33 | public static void showCenterToast(String msg){
34 | if(mToast == null){
35 | mToast = Toast.makeText(Utils.getApp(),msg,Toast.LENGTH_LONG);
36 | mToast.setGravity(Gravity.CENTER,0,0);
37 | }else{
38 | mToast.setText(msg);
39 | }
40 | mToast.show();
41 | }
42 | }
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/Utils.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Application;
5 | import android.support.annotation.NonNull;
6 |
7 | /**
8 | * Author: 张
9 | * Email: 1271396448@qq.com
10 | * Date 2017/10/16
11 | *
12 | * 全局上下文工具类
13 | */
14 |
15 | public class Utils {
16 |
17 | @SuppressLint("StaticFieldLeak")
18 | private static Application sApplication;
19 |
20 | public static void init(@NonNull Application app) {
21 | Utils.sApplication = app;
22 | }
23 |
24 | public static Application getApp() {
25 | if (sApplication != null) {
26 | return sApplication;
27 | } else {
28 | throw new NullPointerException("u should init Utils first");
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/util/WaitLoadingDialogUtill.java:
--------------------------------------------------------------------------------
1 | package com.resource.util;
2 |
3 | import android.content.Context;
4 | import android.support.v7.app.AlertDialog;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.Window;
9 | import android.view.WindowManager;
10 | import android.view.animation.Animation;
11 | import android.view.animation.AnimationUtils;
12 | import android.widget.ImageView;
13 |
14 | import com.resource.R;
15 |
16 | /**
17 | * Author: 张
18 | * Email: 1271396448@qq.com
19 | * Date 2018/11/30
20 | *
21 | * 加载框
22 | */
23 |
24 | public class WaitLoadingDialogUtill {
25 |
26 | //显示加载框
27 | public static AlertDialog showLoadingDialog(Context context) {
28 | AlertDialog loadingDialog = new AlertDialog.Builder(context)
29 | .create();
30 | View inflate = LayoutInflater.from(context).inflate(R.layout.dialog_wait_loading, null);
31 | ImageView ivWaitLoading = inflate.findViewById(R.id.iv_wait_loading);
32 | loadingDialog.setView(inflate);
33 | Animation loadAnimation = AnimationUtils.loadAnimation(context, R.anim.dialog_wait_loading_rotate);
34 | ivWaitLoading.startAnimation(loadAnimation);
35 | loadingDialog.setCanceledOnTouchOutside(false);
36 | if (!loadingDialog.isShowing()) {
37 | loadingDialog.show();
38 | }
39 | Window window = loadingDialog.getWindow();
40 | WindowManager.LayoutParams lp = window.getAttributes();
41 | lp.gravity = Gravity.CENTER;
42 | lp.width = 350;
43 | lp.height = 200;
44 | loadingDialog.getWindow().setAttributes(lp);
45 | return loadingDialog;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/CustomSwipeRefreshLayout.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight;
2 |
3 | import android.content.Context;
4 | import android.support.v4.widget.SwipeRefreshLayout;
5 | import android.util.AttributeSet;
6 |
7 | import com.resource.R;
8 |
9 | /**
10 | * Author: 张
11 | * Email: 1271396448@qq.com
12 | * Date 2018/11/1
13 | *
14 | * 自定义SwiperRefresLayout
15 | */
16 |
17 | public class CustomSwipeRefreshLayout extends SwipeRefreshLayout {
18 |
19 | public CustomSwipeRefreshLayout(Context context, AttributeSet attrs) {
20 | super(context, attrs);
21 | setColorSchemeResources(
22 | R.color.red,
23 | R.color.blue,
24 | R.color.orange,
25 | R.color.black,
26 | R.color.green
27 | );
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/CustomTabLayout.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight;
2 |
3 | import android.content.Context;
4 | import android.support.design.widget.TabLayout;
5 | import android.util.AttributeSet;
6 |
7 | import com.resource.R;
8 |
9 |
10 | /**
11 | * Author: 张
12 | * Email: 1271396448@qq.com
13 | * Date 2018/11/29
14 | *
15 | * 自定义TabLayout 免于每次使用写一堆重复的属性
16 | */
17 |
18 | public class CustomTabLayout extends TabLayout {
19 |
20 | public CustomTabLayout(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | setTabTextColors(getResources().getColor(R.color.black),getResources().getColor(R.color.blue));
23 | setSelectedTabIndicatorColor(getResources().getColor(R.color.blue));
24 | setTabMode(MODE_FIXED);
25 | setTabGravity(GRAVITY_FILL);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/CustomToolbar.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.support.annotation.Nullable;
7 | import android.util.AttributeSet;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.widget.LinearLayout;
11 | import android.widget.RelativeLayout;
12 | import android.widget.TextView;
13 |
14 | import com.resource.R;
15 |
16 | /**
17 | * Author: 张
18 | * Email: 1271396448@qq.com
19 | * Date 2018/11/23
20 | *
21 | * 自定义标题栏
22 | */
23 |
24 | public class CustomToolbar extends LinearLayout {
25 |
26 | private TextView tvBack;
27 | private TextView tvTitle;
28 | private RelativeLayout rlBgRoot;
29 | private OnBackClickListener onBackClickListener;
30 | private OnTitleClickListener onTitleClickListener;
31 |
32 | public CustomToolbar(Context context, @Nullable AttributeSet attrs) {
33 | super(context, attrs);
34 | initView(context, attrs);
35 | }
36 |
37 | private void initView(Context context, @Nullable AttributeSet attrs){
38 | View inflate = LayoutInflater.from(getContext()).inflate(R.layout.layout_custom_toolbar,this);
39 | rlBgRoot = inflate.findViewById(R.id.rl_bg_root);
40 | tvBack = inflate.findViewById(R.id.tv_back);
41 | tvTitle = inflate.findViewById(R.id.tv_title);
42 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CustomToolbar);
43 | String title = typedArray.getString(R.styleable.CustomToolbar_text_title);
44 | int backType = typedArray.getInt(R.styleable.CustomToolbar_back_type, 10);
45 | int bgType = typedArray.getInt(R.styleable.CustomToolbar_bg_type, 10);
46 | tvTitle.setText(title);
47 | if(backType==10){//无返回按钮
48 | tvBack.setVisibility(GONE);
49 | }else if(bgType==11){//有返回按钮
50 | tvBack.setVisibility(VISIBLE);
51 | }
52 | if(bgType==10){//蓝底白字
53 | rlBgRoot.setBackground(getResources().getDrawable(R.drawable.icon_bg_toolbar));
54 | tvTitle.setTextColor(getResources().getColor(R.color.white));
55 | //白色返回图片
56 | Drawable drawable = getResources().getDrawable(R.drawable.icon_back_white);
57 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
58 | tvBack.setCompoundDrawables(drawable,null,null,null);
59 | }else if(bgType==11){//白底黑字
60 | rlBgRoot.setBackgroundColor(getResources().getColor(R.color.white));
61 | tvTitle.setTextColor(getResources().getColor(R.color.black));
62 | tvBack.setTextColor(getResources().getColor(R.color.black));
63 | //灰色返回图片
64 | Drawable drawable = getResources().getDrawable(R.drawable.icon_back_gray);
65 | drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
66 | tvBack.setCompoundDrawables(drawable,null,null,null);
67 | }
68 | tvBack.setOnClickListener(new OnClickListener() {//返回点击监听
69 | @Override
70 | public void onClick(View v) {
71 | if(onBackClickListener!=null)
72 | onBackClickListener.onBackClick(v);
73 | }
74 | });
75 | tvTitle.setOnClickListener(new OnClickListener() {//标题点击监听
76 | @Override
77 | public void onClick(View v) {
78 | if(onTitleClickListener!=null)
79 | onTitleClickListener.onTitleClick(v);
80 | }
81 | });
82 | }
83 |
84 | public interface OnBackClickListener{
85 | void onBackClick(View v);
86 | }
87 |
88 | public void setOnBackClickListener(OnBackClickListener onBackClickListener) {
89 | this.onBackClickListener = onBackClickListener;
90 | }
91 |
92 | public interface OnTitleClickListener{
93 | void onTitleClick(View v);
94 | }
95 | public void setOnTitleClickListener(OnTitleClickListener onTitleClickListener) {
96 | this.onTitleClickListener = onTitleClickListener;
97 | }
98 |
99 | public void setTitle(String str){
100 | tvTitle.setText(str);
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/EndLessOnScrollListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight;
2 |
3 |
4 | import android.support.v7.widget.LinearLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.util.Log;
7 |
8 |
9 | /**
10 | * Author: 张
11 | * Email: 1271396448@qq.com
12 | * Date 2018/10/17
13 | *
14 | * RecyclerView上拉加载
15 | **/
16 | public abstract class EndLessOnScrollListener extends RecyclerView.OnScrollListener{
17 |
18 | //声明一个LinearLayoutManager
19 | private LinearLayoutManager mLinearLayoutManager;
20 |
21 | //当前页,从0开始
22 | private int currentPage = 10;
23 |
24 | //已经加载出来的Item的数量
25 | private int totalItemCount;
26 |
27 | //主要用来存储上一个totalItemCount
28 | private int previousTotal = 0;
29 |
30 | //在屏幕上可见的item数量
31 | private int visibleItemCount;
32 |
33 | //在屏幕可见的Item中的第一个
34 | private int firstVisibleItem;
35 |
36 | //是否正在上拉数据
37 | private boolean loading = true;
38 |
39 | public EndLessOnScrollListener(LinearLayoutManager linearLayoutManager) {
40 | this.mLinearLayoutManager = linearLayoutManager;
41 | }
42 |
43 | @Override
44 | public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
45 | super.onScrolled(recyclerView, dx, dy);
46 | visibleItemCount = recyclerView.getChildCount();
47 | totalItemCount = mLinearLayoutManager.getItemCount();
48 | firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();
49 |
50 | if(loading){
51 |
52 | Log.d("wnwn","firstVisibleItem: " +firstVisibleItem);
53 | Log.d("wnwn","totalPageCount:" +totalItemCount);
54 | Log.d("wnwn", "visibleItemCount:" + visibleItemCount);
55 |
56 | if(totalItemCount > previousTotal){
57 | //说明数据已经加载结束
58 | loading = false;
59 | previousTotal = totalItemCount;
60 | }
61 | }
62 |
63 | //这里需要好好理解
64 | if (!loading && totalItemCount-visibleItemCount <= firstVisibleItem){
65 | currentPage += 10;
66 | onLoadMore(currentPage);
67 | // loading = true;
68 | }
69 | }
70 |
71 | /**
72 | * 提供一个抽闲方法,在Activity中监听到这个EndLessOnScrollListener
73 | * 并且实现这个方法
74 | * */
75 | public abstract void onLoadMore(int currentPage);
76 | }
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/NoScrollViewPager.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | /**
9 | * 禁止滑动的ViewPager
10 | */
11 |
12 | public class NoScrollViewPager extends ViewPager {
13 |
14 | private boolean isScroll = false;
15 |
16 | public NoScrollViewPager(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public NoScrollViewPager(Context context) {
21 | super(context);
22 | }
23 |
24 | /**
25 | * 1.dispatchTouchEvent一般情况不做处理
26 | * ,如果修改了默认的返回值,子孩子都无法收到事件
27 | */
28 | @Override
29 | public boolean dispatchTouchEvent(MotionEvent ev) {
30 | return super.dispatchTouchEvent(ev); //
31 | }
32 |
33 | /**
34 | * 是否拦截
35 | * 拦截:会走到自己的onTouchEvent方法里面来
36 | * 不拦截:事件传递给子孩子
37 | */
38 | @Override
39 | public boolean onInterceptTouchEvent(MotionEvent ev) {
40 | // return false;//可行,不拦截事件,
41 | // return true;//不行,孩子无法处理事件
42 | //return super.onInterceptTouchEvent(ev);//不行,会有细微移动
43 | if (isScroll) {
44 | return super.onInterceptTouchEvent(ev);
45 | } else {
46 | return false;
47 | }
48 | }
49 |
50 | /**
51 | * 是否消费事件
52 | * 消费:事件就结束
53 | * 不消费:往父控件传
54 | */
55 | @Override
56 | public boolean onTouchEvent(MotionEvent ev) {
57 | //return false;// 可行,不消费,传给父控件
58 | //return true;// 可行,消费,拦截事件
59 | //super.onTouchEvent(ev); //不行,
60 | //虽然onInterceptTouchEvent中拦截了,
61 | //但是如果viewpage里面子控件不是viewgroup,还是会调用这个方法.
62 | if (isScroll) {
63 | return super.onTouchEvent(ev);
64 | } else {
65 | return true;// 可行,消费,拦截事件
66 | }
67 | }
68 |
69 | //去除页面切换的滑动翻页效果
70 | @Override
71 | public void setCurrentItem(int item) {
72 | super.setCurrentItem(item, false);
73 | }
74 |
75 | @Override
76 | public void setCurrentItem(int item, boolean smoothScroll) {
77 | super.setCurrentItem(item, smoothScroll);
78 | }
79 |
80 | public void setScroll(boolean scroll) {
81 | isScroll = scroll;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/Compat.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2011, 2012 Chris Banes.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.resource.weight.photoView;
17 |
18 | import android.annotation.TargetApi;
19 | import android.os.Build.VERSION;
20 | import android.os.Build.VERSION_CODES;
21 | import android.view.View;
22 |
23 | class Compat {
24 |
25 | private static final int SIXTY_FPS_INTERVAL = 1000 / 60;
26 |
27 | public static void postOnAnimation(View view, Runnable runnable) {
28 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
29 | postOnAnimationJellyBean(view, runnable);
30 | } else {
31 | view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
32 | }
33 | }
34 |
35 | @TargetApi(16)
36 | private static void postOnAnimationJellyBean(View view, Runnable runnable) {
37 | view.postOnAnimation(runnable);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnGestureListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2011, 2012 Chris Banes.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package com.resource.weight.photoView;
17 |
18 | interface OnGestureListener {
19 |
20 | void onDrag(float dx, float dy);
21 |
22 | void onFling(float startX, float startY, float velocityX,
23 | float velocityY);
24 |
25 | void onScale(float scaleFactor, float focusX, float focusY);
26 |
27 | }
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnMatrixChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 | import android.graphics.RectF;
4 |
5 | /**
6 | * Interface definition for a callback to be invoked when the internal Matrix has changed for
7 | * this View.
8 | */
9 | public interface OnMatrixChangedListener {
10 |
11 | /**
12 | * Callback for when the Matrix displaying the Drawable has changed. This could be because
13 | * the View's bounds have changed, or the user has zoomed.
14 | *
15 | * @param rect - Rectangle displaying the Drawable's new bounds.
16 | */
17 | void onMatrixChanged(RectF rect);
18 | }
19 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnOutsidePhotoTapListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 | import android.widget.ImageView;
4 |
5 | /**
6 | * Callback when the user tapped outside of the photo
7 | */
8 | public interface OnOutsidePhotoTapListener {
9 |
10 | /**
11 | * The outside of the photo has been tapped
12 | */
13 | void onOutsidePhotoTap(ImageView imageView);
14 | }
15 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnPhotoTapListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 | import android.widget.ImageView;
4 |
5 | /**
6 | * A callback to be invoked when the Photo is tapped with a single
7 | * tap.
8 | */
9 | public interface OnPhotoTapListener {
10 |
11 | /**
12 | * A callback to receive where the user taps on a photo. You will only receive a callback if
13 | * the user taps on the actual photo, tapping on 'whitespace' will be ignored.
14 | *
15 | * @param view ImageView the user tapped.
16 | * @param x where the user tapped from the of the Drawable, as percentage of the
17 | * Drawable width.
18 | * @param y where the user tapped from the top of the Drawable, as percentage of the
19 | * Drawable height.
20 | */
21 | void onPhotoTap(ImageView view, float x, float y);
22 | }
23 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnScaleChangedListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 |
4 | /**
5 | * Interface definition for callback to be invoked when attached ImageView scale changes
6 | */
7 | public interface OnScaleChangedListener {
8 |
9 | /**
10 | * Callback for when the scale changes
11 | *
12 | * @param scaleFactor the scale factor (less than 1 for zoom out, greater than 1 for zoom in)
13 | * @param focusX focal point X position
14 | * @param focusY focal point Y position
15 | */
16 | void onScaleChange(float scaleFactor, float focusX, float focusY);
17 | }
18 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnSingleFlingListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 | import android.view.MotionEvent;
4 |
5 | /**
6 | * A callback to be invoked when the ImageView is flung with a single
7 | * touch
8 | */
9 | public interface OnSingleFlingListener {
10 |
11 | /**
12 | * A callback to receive where the user flings on a ImageView. You will receive a callback if
13 | * the user flings anywhere on the view.
14 | *
15 | * @param e1 MotionEvent the user first touch.
16 | * @param e2 MotionEvent the user last touch.
17 | * @param velocityX distance of user's horizontal fling.
18 | * @param velocityY distance of user's vertical fling.
19 | */
20 | boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
21 | }
22 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnViewDragListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 | /**
4 | * Interface definition for a callback to be invoked when the photo is experiencing a drag event
5 | */
6 | public interface OnViewDragListener {
7 |
8 | /**
9 | * Callback for when the photo is experiencing a drag event. This cannot be invoked when the
10 | * user is scaling.
11 | *
12 | * @param dx The change of the coordinates in the x-direction
13 | * @param dy The change of the coordinates in the y-direction
14 | */
15 | void onDrag(float dx, float dy);
16 | }
17 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/OnViewTapListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 | import android.view.View;
4 |
5 | public interface OnViewTapListener {
6 |
7 | /**
8 | * A callback to receive where the user taps on a ImageView. You will receive a callback if
9 | * the user taps anywhere on the view, tapping on 'whitespace' will not be ignored.
10 | *
11 | * @param view - View the user tapped.
12 | * @param x - where the user tapped from the left of the View.
13 | * @param y - where the user tapped from the top of the View.
14 | */
15 | void onViewTap(View view, float x, float y);
16 | }
17 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/photoView/PhotoViewUtil.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.photoView;
2 |
3 | import android.view.MotionEvent;
4 | import android.widget.ImageView;
5 |
6 | class PhotoViewUtil {
7 |
8 | static void checkZoomLevels(float minZoom, float midZoom,
9 | float maxZoom) {
10 | if (minZoom >= midZoom) {
11 | throw new IllegalArgumentException(
12 | "Minimum zoom has to be less than Medium zoom. Call setMinimumZoom() with a more appropriate value");
13 | } else if (midZoom >= maxZoom) {
14 | throw new IllegalArgumentException(
15 | "Medium zoom has to be less than Maximum zoom. Call setMaximumZoom() with a more appropriate value");
16 | }
17 | }
18 |
19 | static boolean hasDrawable(ImageView imageView) {
20 | return imageView.getDrawable() != null;
21 | }
22 |
23 | static boolean isSupportedScaleType(final ImageView.ScaleType scaleType) {
24 | if (scaleType == null) {
25 | return false;
26 | }
27 | switch (scaleType) {
28 | case MATRIX:
29 | throw new IllegalStateException("Matrix scale type is not supported");
30 | }
31 | return true;
32 | }
33 |
34 | static int getPointerIndex(int action) {
35 | return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/recyclerview/BaseRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.recyclerview;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.StringRes;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 |
14 | /**
15 | * Author: 张
16 | * Email: 1271396448@qq.com
17 | * Date 2017/08/13
18 | *
19 | * RecyclerView适配器父类
20 | */
21 |
22 | public abstract class BaseRecyclerAdapter extends RecyclerView.Adapter {
23 |
24 | protected List mData;
25 | protected Context mContext;
26 | private OnRecyclerViewItemClickListener mClickListener;
27 | private OnRecyclerViewItemLongClickListener mLongClickListener;
28 |
29 | public BaseRecyclerAdapter(List list) {
30 | mData = list == null ? (List) new ArrayList<>() : list;
31 | }
32 |
33 | public BaseRecyclerAdapter() {
34 | mData = new ArrayList<>();
35 | }
36 |
37 | public void change(int pos, T item) {
38 | mData.remove(pos);
39 | mData.add(pos, item);
40 | notifyItemChanged(pos);
41 | }
42 |
43 | public void addAll(List list) {
44 | if (list.size() > 0) {
45 | mData.clear();
46 | mData.addAll(list);
47 | notifyDataSetChanged();
48 | }
49 | }
50 |
51 | public void add(List list) {
52 | if (list.size() > 0) {
53 | mData.addAll(list);
54 | notifyDataSetChanged();
55 | }
56 | }
57 |
58 | public void add(int position, T data) {
59 | mData.add(position, data);
60 | notifyDataSetChanged();
61 | }
62 |
63 | public void remove(int position) {
64 | mData.remove(position);
65 | notifyDataSetChanged();
66 | }
67 |
68 | public void clear() {
69 | mData.clear();
70 | notifyDataSetChanged();
71 | }
72 |
73 | public List getData() {
74 | return mData;
75 | }
76 |
77 |
78 | @Override
79 | public RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
80 | mContext = parent.getContext();
81 | View view = LayoutInflater.from(mContext).inflate(getItemLayoutId(viewType), parent, false);
82 | final RecyclerViewHolder holder = new RecyclerViewHolder(view);
83 | holder.itemView.setOnClickListener(new View.OnClickListener() {
84 | @Override
85 | public void onClick(View v) {
86 | if (mClickListener != null) {
87 | mClickListener.onItemClick(holder.itemView, holder.getLayoutPosition());
88 | }
89 | }
90 | });
91 | holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
92 | @Override
93 | public boolean onLongClick(View v) {
94 | if (mLongClickListener!= null) {
95 | mLongClickListener.onItemLongClick(holder.itemView, holder.getLayoutPosition());
96 | return true;
97 | }
98 | return false;
99 | }
100 | });
101 | return holder;
102 | }
103 |
104 | @Override
105 | public void onBindViewHolder(RecyclerViewHolder holder, int position) {
106 | bindData(holder, position, mData.get(position));
107 | }
108 |
109 | @Override
110 | public int getItemCount() {
111 | return mData.size();
112 | }
113 |
114 | protected abstract int getItemLayoutId(int viewType);
115 |
116 | protected abstract void bindData(RecyclerViewHolder holder, int position, T item);
117 |
118 | protected String getString(@StringRes int resId) {
119 | return mContext.getString(resId);
120 | }
121 |
122 | public void setOnItemClickListener(OnRecyclerViewItemClickListener listener) {
123 | mClickListener = listener;
124 | }
125 |
126 | public void setOnItemLongClickListener(OnRecyclerViewItemLongClickListener listener) {
127 | mLongClickListener = listener;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/recyclerview/OnRecyclerViewItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.recyclerview;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Author: 张
7 | * Email: 1271396448@qq.com
8 | * Date 2017/08/13
9 | */
10 |
11 | public interface OnRecyclerViewItemClickListener {
12 | void onItemClick(View view, int position);
13 | }
14 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/recyclerview/OnRecyclerViewItemLongClickListener.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.recyclerview;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Author: 张
7 | * Email: 1271396448@qq.com
8 | * Date 2017/08/13
9 | */
10 |
11 | public interface OnRecyclerViewItemLongClickListener {
12 | void onItemLongClick(View view, int position);
13 | }
14 |
--------------------------------------------------------------------------------
/resource/src/main/java/com/resource/weight/recyclerview/RecyclerViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.resource.weight.recyclerview;
2 |
3 | import android.support.annotation.IdRes;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.util.SparseArray;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.CheckBox;
9 | import android.widget.ImageView;
10 | import android.widget.LinearLayout;
11 | import android.widget.ProgressBar;
12 | import android.widget.RelativeLayout;
13 | import android.widget.TextView;
14 |
15 | /**
16 | * Author: 张
17 | * Email: 1271396448@qq.com
18 | * Date 2017/08/13
19 | */
20 |
21 | public class RecyclerViewHolder extends RecyclerView.ViewHolder {
22 |
23 | private final SparseArray mViews;
24 |
25 | public RecyclerViewHolder(View itemView) {
26 | super(itemView);
27 | mViews = new SparseArray<>();
28 | }
29 |
30 | public T findViewById(@IdRes int viewId) {
31 | View view = mViews.get(viewId);
32 | if (view == null) {
33 | view = itemView.findViewById(viewId);
34 | mViews.put(viewId, view);
35 | }
36 | return (T) view;
37 | }
38 |
39 | public View getView(@IdRes int viewId) {
40 | return findViewById(viewId);
41 | }
42 |
43 | public TextView getTextView(@IdRes int viewId) {
44 | return findViewById(viewId);
45 | }
46 |
47 | public ImageView getImageView(@IdRes int viewId) {
48 | return findViewById(viewId);
49 | }
50 |
51 | public RelativeLayout getRelativeLayout(@IdRes int viewId) {
52 | return findViewById(viewId);
53 | }
54 |
55 | public LinearLayout getLinearLayout(@IdRes int viewId) {
56 | return findViewById(viewId);
57 | }
58 |
59 | public CheckBox getCheckBox(@IdRes int viewId) {
60 | return findViewById(viewId);
61 | }
62 | public Button getButton(@IdRes int viewId) {
63 | return findViewById(viewId);
64 | }
65 | public ProgressBar getProgressBar(@IdRes int viewId) {
66 | return findViewById(viewId);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/resource/src/main/res/anim/dialog_wait_loading_rotate.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
14 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable-xxhdpi/icon_back_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/drawable-xxhdpi/icon_back_gray.png
--------------------------------------------------------------------------------
/resource/src/main/res/drawable-xxhdpi/icon_back_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/drawable-xxhdpi/icon_back_white.png
--------------------------------------------------------------------------------
/resource/src/main/res/drawable-xxhdpi/icon_bg_toolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/drawable-xxhdpi/icon_bg_toolbar.png
--------------------------------------------------------------------------------
/resource/src/main/res/drawable-xxhdpi/icon_wait_loading.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/drawable-xxhdpi/icon_wait_loading.png
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_blue_corner_15.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_blue_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_gray999_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_gray_corner_15.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_gray_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_orange_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_red_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_white_corner_15.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/bg_white_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/border_black_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/border_blue_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/border_gray999_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/border_gray_corner_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/border_gray_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/border_orange_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/border_white_corner_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/resource/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/resource/src/main/res/layout/activity_layout/anim/progressbar_transplate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/resource/src/main/res/layout/activity_layout/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
19 |
25 |
26 |
32 |
33 |
34 |
41 |
42 |
48 |
49 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/resource/src/main/res/layout/activity_layout/layout/activity_login_success.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
22 |
23 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/resource/src/main/res/layout/dialog_layout/layout/dialog_wait_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
23 |
24 |
35 |
36 |
--------------------------------------------------------------------------------
/resource/src/main/res/layout/layout_custom_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
24 |
25 |
33 |
34 |
35 |
39 |
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/resource/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/resource/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/resource/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/resource/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #007DFF
6 |
7 |
8 | #FFFFFF
9 | #007DFF
10 | #333333
11 | #666666
12 | #999999
13 | #F3F4F8
14 | #EDF4FE
15 | #FE453D
16 | #FF9500
17 | #3cda38
18 | #FFF9E6
19 |
20 |
21 | #80000000
22 | #cc000000
23 | #80000000
24 | #4c000000
25 | #00000000
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/resource/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Mvp
3 |
4 | 网络好像有点问题,请稍后重试
5 | 解析异常
6 | 网络超时,请检查你的ip和网络状态
7 | 服务器请求错误
8 | 数据解析异常
9 |
10 |
11 |
--------------------------------------------------------------------------------
/resource/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/resource/src/test/java/com/resource/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.resource;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/rthttp/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/rthttp/.idea/.name:
--------------------------------------------------------------------------------
1 | mvp-Retrofit-Rxjava
--------------------------------------------------------------------------------
/rthttp/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
20 |
21 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/__local_aars___F__android_code_mvp_Retrofit_Rxjava_resource_libs_mpandroidchartlibrary_2_1_3_jar_unspecified_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/android_arch_core_common_1_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/android_arch_lifecycle_common_1_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/android_arch_lifecycle_runtime_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_alibaba_arouter_annotation_1_0_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_alibaba_arouter_api_1_2_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_animated_vector_drawable_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_appcompat_v7_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_constraint_constraint_layout_1_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_constraint_constraint_layout_solver_1_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_design_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_multidex_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_multidex_instrumentation_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_recyclerview_v7_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_annotations_26_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_compat_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_core_ui_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_core_utils_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_fragment_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_media_compat_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_v4_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_support_vector_drawable_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_android_support_transition_26_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_github_bumptech_glide_annotations_4_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_github_bumptech_glide_disklrucache_4_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_github_bumptech_glide_gifdecoder_4_5_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_github_bumptech_glide_glide_4_5_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_google_code_findbugs_jsr305_3_0_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_google_code_gson_gson_2_7_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_google_dagger_dagger_2_9_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_jakewharton_butterknife_8_8_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_jakewharton_butterknife_annotations_8_8_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_jakewharton_rxbinding_rxbinding_0_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_squareup_okhttp3_logging_interceptor_3_4_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_squareup_okhttp3_okhttp_3_12_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_squareup_okio_okio_1_15_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_squareup_retrofit2_adapter_rxjava2_2_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_squareup_retrofit2_converter_gson_2_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_squareup_retrofit2_retrofit_2_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_trello_rxlifecycle_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_trello_rxlifecycle_android_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/com_trello_rxlifecycle_components_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/io_reactivex_rxandroid_1_1_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/io_reactivex_rxjava2_rxandroid_2_1_2_SNAPSHOT.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/io_reactivex_rxjava2_rxjava_2_2_7_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/io_reactivex_rxjava_1_2_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/javax_inject_javax_inject_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/junit_junit_4_12_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/org_greenrobot_eventbus_3_0_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/org_reactivestreams_reactive_streams_1_0_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/rthttp/.idea/libraries/pub_devrel_easypermissions_1_0_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | 1.8
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/rthttp/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/rthttp/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/rthttp/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jakewharton.butterknife'
3 |
4 | android {
5 | compileSdkVersion rootProject.ext.compileSdkVersion
6 | defaultConfig {
7 | minSdkVersion rootProject.ext.minSdkVersion
8 | targetSdkVersion rootProject.ext.targetSdkVersion
9 | versionCode rootProject.ext.versionCode
10 | versionName rootProject.ext.versionName
11 |
12 | multiDexEnabled true
13 |
14 | javaCompileOptions {
15 | annotationProcessorOptions {
16 | arguments = [moduleName: project.getName()]
17 | }
18 | }
19 |
20 | }
21 |
22 | buildTypes {
23 | release {
24 | minifyEnabled false
25 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26 | }
27 | }
28 |
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 |
34 | }
35 |
36 | dependencies {
37 | provided fileTree(dir: 'libs', include: ['*.jar'])
38 | //retrofit2.0
39 | compile rootProject.ext.retrofit2
40 | //retrofit2.0的gson解析支持
41 | compile rootProject.ext.retrofit2ConverterGson
42 | //rxjava2.0
43 | compile rootProject.ext.rxjava2
44 | //rxandroid
45 | compile rootProject.ext.rxjava2Rxandroid
46 | //让retrofit2.0适配rxjava2.0
47 | compile rootProject.ext.retrofit2AdapterRxjava2
48 | //okhttp
49 | compile rootProject.ext.okHttp
50 | //拦截器
51 | compile rootProject.ext.okHttpLogIntercept
52 |
53 | compile project(':resource')
54 |
55 | annotationProcessor rootProject.ext.arouterCompiler
56 | annotationProcessor rootProject.ext.daggerCompiler
57 | annotationProcessor rootProject.ext.butterknifeCompiler
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/rthttp/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/mvp-Retrofit-Rxjava/f0cf6b75e7addd6d7fda03609dc20bb834f8ecc6/rthttp/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/rthttp/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Mar 14 15:50:13 CST 2019
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.1-all.zip
7 |
--------------------------------------------------------------------------------
/rthttp/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/rthttp/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Thu Mar 14 15:50:11 CST 2019
11 | sdk.dir=E\:\\SDK
12 |
--------------------------------------------------------------------------------
/rthttp/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 | -ignorewarning
--------------------------------------------------------------------------------
/rthttp/src/androidTest/java/com/rthttp/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.rthttp;
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 | * Instrumented 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("com.rthttp.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/rthttp/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/Mobile.java:
--------------------------------------------------------------------------------
1 | package com.rthttp;
2 |
3 |
4 | import java.util.HashMap;
5 |
6 |
7 | /**
8 | * Author: 张
9 | * Email: 1271396448@qq.com
10 | * Date 2018/10/16
11 | *
12 | * 接口参数封装
13 | */
14 |
15 | public class Mobile {
16 |
17 |
18 | public final static String LOCAL_BASE_URL = "http://140.143.80.58:8888/";
19 |
20 | //全局 获取用户的图片
21 | public static HashMap login(String username, String password) {
22 | HashMap map = new HashMap();
23 | map.put("username", username);
24 | map.put("password", password);
25 | return map;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/RetrofitFactory.java:
--------------------------------------------------------------------------------
1 | package com.rthttp;
2 |
3 |
4 | import com.rthttp.api.ApiService;
5 | import com.rthttp.intercept.MyIntercept;
6 |
7 | import java.util.concurrent.TimeUnit;
8 |
9 | import okhttp3.OkHttpClient;
10 | import retrofit2.Retrofit;
11 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
12 | import retrofit2.converter.gson.GsonConverterFactory;
13 |
14 | /**
15 | * @Author: 张
16 | * @Email: 1271396448@qq.com
17 | * @Date 2018/10/16 13:16
18 | *
19 | * 网络请求总入口
20 | */
21 |
22 | public class RetrofitFactory {
23 |
24 | private Retrofit mRetrofit;
25 | private static ApiService apiService;
26 |
27 | private RetrofitFactory() {
28 | initRetrofit();
29 | }
30 |
31 | public static RetrofitFactory getInstance() {
32 | return Holder.INSTANCE;
33 | }
34 |
35 | //请求网络的方法入口
36 | public static ApiService getApi(){
37 | if(apiService==null){
38 | synchronized (ApiService.class){
39 | if(apiService==null){
40 | apiService = getInstance().initRetrofit().create(ApiService.class);
41 | }
42 | }
43 | }
44 | return apiService;
45 | }
46 |
47 | // 内部类单利
48 | private static class Holder {
49 | private static final RetrofitFactory INSTANCE = new RetrofitFactory();
50 |
51 | }
52 |
53 | private Retrofit initRetrofit() {
54 |
55 | mRetrofit = new Retrofit.Builder()
56 | .baseUrl(Mobile.LOCAL_BASE_URL)
57 | .addConverterFactory(GsonConverterFactory.create())
58 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
59 | .client(initClient())
60 | .build();
61 | return mRetrofit;
62 | }
63 |
64 |
65 | private OkHttpClient initClient() {
66 |
67 | return new OkHttpClient.Builder()
68 | .addInterceptor(new MyIntercept())
69 | .connectTimeout(10, TimeUnit.SECONDS)
70 | .readTimeout(10, TimeUnit.SECONDS)
71 | .build();
72 | }
73 |
74 | }
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/RxJavaHelper.java:
--------------------------------------------------------------------------------
1 | package com.rthttp;
2 | /*
3 | * Author: 张
4 | * Email: 1271396448@qq.com
5 | * Date: 2018/12/14.
6 | *
7 | * Rxjava2线程切换操作封装
8 | */
9 |
10 | import io.reactivex.Observable;
11 | import io.reactivex.ObservableSource;
12 | import io.reactivex.ObservableTransformer;
13 | import io.reactivex.android.schedulers.AndroidSchedulers;
14 | import io.reactivex.schedulers.Schedulers;
15 |
16 | public class RxJavaHelper {
17 |
18 | public static ObservableTransformer observeOnMainThread(){
19 | return new ObservableTransformer() {
20 | @Override
21 | public ObservableSource apply(Observable upstream) {
22 | return upstream.subscribeOn(Schedulers.io())
23 | .unsubscribeOn(Schedulers.io())
24 | .observeOn(AndroidSchedulers.mainThread());
25 | }
26 | };
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/api/ApiService.java:
--------------------------------------------------------------------------------
1 | package com.rthttp.api;
2 |
3 | import com.rthttp.base.BaseResponse;
4 | import com.rthttp.bean.LoginBean;
5 |
6 | import java.util.HashMap;
7 |
8 | import io.reactivex.Observable;
9 | import retrofit2.http.POST;
10 | import retrofit2.http.QueryMap;
11 |
12 | /**
13 | * @Author: 张
14 | * @Email: 1271396448@qq.com
15 | * @Date 2018/10/16 16:49
16 | *
17 | * 参数封装类
18 | */
19 |
20 | public interface ApiService {
21 |
22 | //登录
23 | @POST("user/login")
24 | Observable> login(@QueryMap HashMap map);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/base/BaseObserver.java:
--------------------------------------------------------------------------------
1 | package com.rthttp.base;
2 |
3 |
4 | import android.content.Context;
5 | import android.support.v7.app.AlertDialog;
6 |
7 | import com.google.gson.JsonSyntaxException;
8 | import com.resource.util.LogUtil;
9 | import com.resource.util.NetworkUtils;
10 | import com.resource.util.ToastUtil;
11 | import com.resource.util.WaitLoadingDialogUtill;
12 | import com.rthttp.R;
13 |
14 | import java.net.ConnectException;
15 | import java.net.SocketException;
16 | import java.net.SocketTimeoutException;
17 | import java.net.UnknownHostException;
18 |
19 | import io.reactivex.Observer;
20 | import io.reactivex.disposables.Disposable;
21 | import retrofit2.HttpException;
22 |
23 | /**
24 | * @Author: 张
25 | * @Email: 1271396448@qq.com
26 | * @Date 2018/11/14 10:26
27 | *
28 | * 统一错误码处理
29 | */
30 |
31 | public abstract class BaseObserver implements Observer> {
32 |
33 | private Context context;
34 | private AlertDialog dialog;
35 |
36 | public BaseObserver() {
37 | super();
38 | }
39 |
40 | public BaseObserver(Context context) {
41 | this.context = context;
42 | dialog = WaitLoadingDialogUtill.showLoadingDialog(context);
43 | }
44 |
45 |
46 | @Override
47 | public void onSubscribe(Disposable d) {
48 |
49 | }
50 |
51 | @Override
52 | public void onNext(BaseResponse response) {
53 | if (response.getCode() == 10000) {//数据请求成功
54 | onSuccess(response);
55 | } else {
56 | ToastUtil.showCenterToast(response.getMsg());
57 | }
58 | dialog.cancel();
59 | }
60 |
61 | @Override
62 | public void onError(Throwable e) {
63 | LogUtil.e(e.getMessage());
64 | //错误码统一处理
65 | if (e instanceof UnknownHostException) {
66 | if (!NetworkUtils.isNetworkAvailable()) {//网络不可用
67 | ToastUtil.showCenterToast(R.string.net_error);
68 | }else {
69 | ToastUtil.showCenterToast(R.string.server_error);
70 | }
71 | } else if (e instanceof ConnectException || e instanceof SocketTimeoutException || e instanceof SocketException) {//连接超时等
72 | ToastUtil.showCenterToast(R.string.time_out_error);
73 | } else if (e instanceof HttpException || e instanceof retrofit2.adapter.rxjava2.HttpException) {
74 | ToastUtil.showCenterToast(R.string.server_error);
75 | }
76 | if(dialog.isShowing())
77 | dialog.cancel();
78 | }
79 |
80 | @Override
81 | public void onComplete() {
82 |
83 | }
84 |
85 | public abstract void onSuccess(BaseResponse response);
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/base/BaseResponse.java:
--------------------------------------------------------------------------------
1 | package com.rthttp.base;
2 |
3 | /**
4 | * @Author: 张
5 | * @Email: 1271396448@qq.com
6 | * @Date 2018/12/14 10:03
7 | *
8 | * 基础实体类
9 | */
10 |
11 | public class BaseResponse {
12 |
13 | private int code;
14 | private String msg;
15 | private T data;
16 |
17 | public int getCode() {
18 | return code;
19 | }
20 |
21 | public void setCode(int code) {
22 | this.code = code;
23 | }
24 |
25 | public String getMsg() {
26 | return msg;
27 | }
28 |
29 | public void setMsg(String msg) {
30 | this.msg = msg;
31 | }
32 |
33 | public T getData() {
34 | return data;
35 | }
36 |
37 | public void setData(T data) {
38 | this.data = data;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/bean/LoginBean.java:
--------------------------------------------------------------------------------
1 | package com.rthttp.bean;
2 |
3 | import com.rthttp.base.BaseResponse;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Author: 张
9 | * Email: 1271396448@qq.com
10 | * Date 2018/10/16
11 | *
12 | * 登陆实体类
13 | */
14 |
15 | public class LoginBean {
16 |
17 | /**
18 | * id : 16
19 | * username : admin
20 | * name : 段哥27134
21 | * sex : 0
22 | * avater : https://github.com/manitozhang/GSYVideoPlayer/blob/master/app/default_avater.png?raw=true
23 | * sign :
24 | * phoneNumber : null
25 | * certifyType : 0
26 | * certifyContent :
27 | */
28 |
29 | private int id;
30 | private String username;
31 | private String name;
32 | private int sex;
33 | private String avater;
34 | private String sign;
35 | private Object phoneNumber;
36 | private int certifyType;
37 | private String certifyContent;
38 |
39 | public int getId() {
40 | return id;
41 | }
42 |
43 | public void setId(int id) {
44 | this.id = id;
45 | }
46 |
47 | public String getUsername() {
48 | return username;
49 | }
50 |
51 | public void setUsername(String username) {
52 | this.username = username;
53 | }
54 |
55 | public String getName() {
56 | return name;
57 | }
58 |
59 | public void setName(String name) {
60 | this.name = name;
61 | }
62 |
63 | public int getSex() {
64 | return sex;
65 | }
66 |
67 | public void setSex(int sex) {
68 | this.sex = sex;
69 | }
70 |
71 | public String getAvater() {
72 | return avater;
73 | }
74 |
75 | public void setAvater(String avater) {
76 | this.avater = avater;
77 | }
78 |
79 | public String getSign() {
80 | return sign;
81 | }
82 |
83 | public void setSign(String sign) {
84 | this.sign = sign;
85 | }
86 |
87 | public Object getPhoneNumber() {
88 | return phoneNumber;
89 | }
90 |
91 | public void setPhoneNumber(Object phoneNumber) {
92 | this.phoneNumber = phoneNumber;
93 | }
94 |
95 | public int getCertifyType() {
96 | return certifyType;
97 | }
98 |
99 | public void setCertifyType(int certifyType) {
100 | this.certifyType = certifyType;
101 | }
102 |
103 | public String getCertifyContent() {
104 | return certifyContent;
105 | }
106 |
107 | public void setCertifyContent(String certifyContent) {
108 | this.certifyContent = certifyContent;
109 | }
110 |
111 | @Override
112 | public String toString() {
113 | return "LoginBean{" +
114 | "id=" + id +
115 | ", username='" + username + '\'' +
116 | ", name='" + name + '\'' +
117 | ", sex=" + sex +
118 | ", avater='" + avater + '\'' +
119 | ", sign='" + sign + '\'' +
120 | ", phoneNumber=" + phoneNumber +
121 | ", certifyType=" + certifyType +
122 | ", certifyContent='" + certifyContent + '\'' +
123 | '}';
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/rthttp/src/main/java/com/rthttp/intercept/MyIntercept.java:
--------------------------------------------------------------------------------
1 | package com.rthttp.intercept;
2 |
3 | import com.resource.common.Constant;
4 | import com.resource.util.LogUtil;
5 | import com.resource.util.SpUtil;
6 |
7 | import java.io.IOException;
8 |
9 | import okhttp3.HttpUrl;
10 | import okhttp3.Interceptor;
11 | import okhttp3.Request;
12 | import okhttp3.Response;
13 |
14 |
15 | /**
16 | * Author: 张
17 | * Email: 1271396448@qq.com
18 | * Date 2018/10/16
19 | *
20 | * 拦截器
21 | */
22 | public class MyIntercept implements Interceptor {
23 | @Override
24 | public Response intercept(Chain chain) throws IOException {
25 | Request request = chain.request();
26 | HttpUrl build = request.url()
27 | .newBuilder()
28 | .build();
29 | LogUtil.i(build);
30 | Request requestNew = request.newBuilder()
31 | .addHeader("Authorization", SpUtil.sp.getString(Constant.USER_TOKEN,""))
32 | .url(build)
33 | .build();
34 | return chain.proceed(requestNew);
35 | }
36 | }
--------------------------------------------------------------------------------
/rthttp/src/test/java/com/rthttp/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.rthttp;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':resource', ':rthttp', ':login', ':module_home'
2 |
--------------------------------------------------------------------------------