├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── activity_login.xml
│ │ │ │ └── fragment_login.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── comtesting
│ │ │ │ └── atomtry
│ │ │ │ ├── base
│ │ │ │ ├── BaseView.java
│ │ │ │ ├── BaseActivity.java
│ │ │ │ ├── BasePresenter.java
│ │ │ │ └── BaseFragment.java
│ │ │ │ ├── request
│ │ │ │ ├── mCallBack.java
│ │ │ │ ├── mHttpRequest.java
│ │ │ │ ├── RetrofitApi.java
│ │ │ │ ├── HttpRequestFactory.java
│ │ │ │ ├── parameter
│ │ │ │ │ ├── userParameter.java
│ │ │ │ │ └── HttpParameter.java
│ │ │ │ ├── HttpResult.java
│ │ │ │ └── retrofitHttpRequest.java
│ │ │ │ ├── home
│ │ │ │ └── homeActivity.java
│ │ │ │ ├── register
│ │ │ │ └── RegisterActivity.java
│ │ │ │ ├── scope
│ │ │ │ └── fragmentScoped.java
│ │ │ │ ├── login
│ │ │ │ ├── LoginComponent.java
│ │ │ │ ├── LoginContract.java
│ │ │ │ ├── LoginModule.java
│ │ │ │ ├── LoginActivity.java
│ │ │ │ ├── LoginPresenter.java
│ │ │ │ └── LoginFragment.java
│ │ │ │ ├── mAppComponent.java
│ │ │ │ ├── utils
│ │ │ │ ├── ActivityUtils.java
│ │ │ │ ├── ciPherUtils.java
│ │ │ │ ├── ExceptionUtils.java
│ │ │ │ └── RxjavaFactory.java
│ │ │ │ ├── mAppModule.java
│ │ │ │ ├── mApplication.java
│ │ │ │ ├── data
│ │ │ │ ├── greendao
│ │ │ │ │ └── userLogin.java
│ │ │ │ ├── repository
│ │ │ │ │ └── UserRepository.java
│ │ │ │ └── bean
│ │ │ │ │ └── UserLoginBean.java
│ │ │ │ └── rxbus
│ │ │ │ └── RxBus.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── comtesting
│ │ │ └── atomtry
│ │ │ ├── myRobolectricTestRunner.java
│ │ │ └── login
│ │ │ ├── loginPresenterTest.java
│ │ │ └── LoginScreenTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── comtesting
│ │ └── atomtry
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── README.md
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── kotlinc.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
├── inspectionProfiles
│ └── Project_Default.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # atomRXDT-MVP
2 | retrofit2+rxjava2+dagger2+greenDao3+mvp+test
3 |
4 | just a practice project
5 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrqatom/atomRXDT-MVP/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrqatom/atomRXDT-MVP/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrqatom/atomRXDT-MVP/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrqatom/atomRXDT-MVP/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrqatom/atomRXDT-MVP/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrqatom/atomRXDT-MVP/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 13 14:20:23 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/base/BaseView.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.base;
2 |
3 |
4 | /**
5 | * Created by atom on 2017/2/24.
6 | * view层基础接口
7 | */
8 |
9 | public interface BaseView
{
10 | void setPresenter(P presenter);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/request/mCallBack.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.request;
2 |
3 | /**
4 | * Created by atom on 2017/2/24.
5 | * 请求返回
6 | */
7 |
8 | public interface mCallBack {
9 | void success(T response);
10 |
11 | void fail(String message);
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.base;
2 |
3 | import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;
4 |
5 | /**
6 | * Created by atom on 2017/3/23.
7 | * 基础activity
8 | */
9 |
10 | public class BaseActivity extends RxAppCompatActivity {
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/home/homeActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.home;
2 |
3 |
4 | import com.trello.rxlifecycle2.components.support.RxAppCompatActivity;
5 |
6 | /**
7 | * Created by atom on 2017/3/16.
8 | * 主页
9 | */
10 |
11 | public class homeActivity extends RxAppCompatActivity{
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/register/RegisterActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.register;
2 |
3 |
4 | import com.example.comtesting.atomtry.base.BaseActivity;
5 |
6 | /**
7 | * Created by atom on 2017/2/27.
8 | * 注册activity
9 | */
10 |
11 | public class RegisterActivity extends BaseActivity {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/scope/fragmentScoped.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.scope;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 |
7 | import javax.inject.Scope;
8 |
9 | /**
10 | * Created by atom on 2017/4/13.
11 | */
12 | @Documented
13 | @Scope
14 | @Retention(RetentionPolicy.RUNTIME)
15 | public @interface fragmentScoped {
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/login/LoginComponent.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.login;
2 |
3 | import com.example.comtesting.atomtry.mAppComponent;
4 | import com.example.comtesting.atomtry.scope.fragmentScoped;
5 |
6 | import dagger.Component;
7 |
8 | /**
9 | * Created by atom on 2017/2/24.
10 | * dagger的登录component
11 | */
12 | @fragmentScoped
13 | @Component(dependencies = mAppComponent.class,modules = LoginModule.class)
14 | public interface LoginComponent {
15 | void inject(LoginActivity loginActivity);
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/request/mHttpRequest.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.request;
2 |
3 | import com.example.comtesting.atomtry.request.parameter.HttpParameter;
4 | import com.example.comtesting.atomtry.request.parameter.userParameter;
5 |
6 | /**
7 | * Created by atom on 2017/2/24.
8 | * 网络请求
9 | */
10 |
11 | public interface mHttpRequest {
12 | void request(String url, Class clazz, mCallBack callBack);
13 |
14 | void request(String url, HttpParameter param, mCallBack callBack);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AtomTry
3 | 用户名
4 | 密码
5 | 登录
6 | 注册
7 | 手机号
8 | 验证码
9 | 获取验证码
10 | 确认
11 | 取消
12 | 记住密码
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/mAppComponent.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry;
2 |
3 | import android.content.Context;
4 |
5 | import com.example.comtesting.atomtry.request.mHttpRequest;
6 | import com.example.comtesting.atomtry.request.retrofitHttpRequest;
7 |
8 | import javax.inject.Singleton;
9 |
10 | import dagger.Component;
11 |
12 | /**
13 | * Created by atom on 2017/2/24.
14 | * 全局component
15 | */
16 | @Singleton
17 | @Component(modules = mAppModule.class)
18 | public interface mAppComponent {
19 | mHttpRequest getMHttpRequest();
20 | }
21 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/request/RetrofitApi.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.request;
2 |
3 | import java.util.Map;
4 |
5 | import io.reactivex.Observable;
6 | import retrofit2.http.Body;
7 | import retrofit2.http.POST;
8 | import retrofit2.http.Url;
9 |
10 | /**
11 | *
12 | * @author atom
13 | * @date 2017/3/14
14 | * Retrofit API
15 | */
16 |
17 | public interface RetrofitApi {
18 |
19 | @POST
20 | Observable getResponse(@Url String url, @Body Map parameter);
21 |
22 | //这里踩坑记录:retrofit不支持:type泛型
23 | @POST
24 | Observable getResponse(@Url String url);
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/request/HttpRequestFactory.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.request;
2 |
3 | /**
4 | * Created by atom on 2017/2/24.
5 | * 获得请求实例的工厂,实现可替换原则
6 | */
7 |
8 | public class HttpRequestFactory {
9 | private static mHttpRequest mHttpRequest;
10 |
11 | public static mHttpRequest getRetrofitHttpRequest() {
12 | if (mHttpRequest == null) {
13 | synchronized (HttpRequestFactory.class) {
14 | if (mHttpRequest == null) {
15 | mHttpRequest = new retrofitHttpRequest();
16 | }
17 | }
18 | }
19 | return mHttpRequest;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in F:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/utils/ActivityUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.utils;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 |
6 | import java.util.List;
7 |
8 | import static com.google.common.base.Preconditions.checkNotNull;
9 |
10 | /**
11 | * Created by atom on 2017/2/24.
12 | * activity工具包
13 | */
14 |
15 | public class ActivityUtils {
16 |
17 | /**
18 | * 添加fragment
19 | */
20 | public static void addFragment(FragmentManager manager, Fragment fragment, int layoutId) {
21 | checkNotNull(manager);
22 | checkNotNull(fragment);
23 | manager.beginTransaction().add(layoutId, fragment).commit();
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/request/parameter/userParameter.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.request.parameter;
2 |
3 | /**
4 | * Created by atom on 2017/3/19.
5 | */
6 | @Deprecated
7 | public class userParameter{
8 | private String phone;
9 | private String psw;
10 |
11 | public String getPsw() {
12 | return psw;
13 | }
14 |
15 | public void setPsw(String psw) {
16 | this.psw = psw;
17 | }
18 |
19 | public String getPhone() {
20 |
21 | return phone;
22 | }
23 |
24 | public void setPhone(String phone) {
25 | this.phone = phone;
26 | }
27 |
28 | // @Override
29 | // public void setParameterToField() {
30 | // phone = parameters.get("phone");
31 | // psw = parameters.get("psw");
32 | // }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/comtesting/atomtry/myRobolectricTestRunner.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry;
2 |
3 |
4 | import org.junit.runners.model.InitializationError;
5 | import org.robolectric.RoboSettings;
6 | import org.robolectric.RobolectricTestRunner;
7 |
8 | /**
9 | * 继承RobolectricTestRunner改变下载路径,加快Robolectric的下载
10 | */
11 | public class myRobolectricTestRunner extends RobolectricTestRunner {
12 | public myRobolectricTestRunner(Class> testClass) throws InitializationError {
13 | super(testClass);
14 |
15 | // 从源码知道MavenDependencyResolver默认以RoboSettings的repositoryUrl和repositoryId为默认值,因此只需要对RoboSetting进行赋值即可
16 | RoboSettings.setMavenRepositoryId("alimaven");
17 | RoboSettings.setMavenRepositoryUrl("http://maven.aliyun.com/nexus/content/groups/public/");
18 | }
19 | }
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/request/parameter/HttpParameter.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.request.parameter;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | /**
7 | * Created by atom on 2017/3/15.
8 | */
9 |
10 | public class HttpParameter {
11 | public Map parameters;
12 | public Class clazz;
13 |
14 | public Class getClazz() {
15 | return clazz;
16 | }
17 |
18 | public void setClazz(Class clazz) {
19 | this.clazz = clazz;
20 | }
21 |
22 | public HttpParameter() {
23 | parameters = new HashMap<>();
24 | }
25 |
26 | public Map getParameters() {
27 | return parameters;
28 | }
29 | public void addParameter(String key,String parameter){
30 | parameters.put(key,parameter);
31 | }
32 | // public abstract void setParameterToField();
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/comtesting/atomtry/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.comtesting.atomtry", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/base/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.base;
2 |
3 | import com.example.comtesting.atomtry.data.repository.UserRepository;
4 | import com.example.comtesting.atomtry.request.mHttpRequest;
5 |
6 | import javax.inject.Inject;
7 |
8 | /**
9 | * Created by atom on 2017/2/24.
10 | * presenter层
11 | */
12 |
13 | public class BasePresenter{
14 | public final V mView;
15 | public final UserRepository mUserRepository;
16 | public final mHttpRequest mHttpRequest;
17 |
18 | public BasePresenter(V mView, UserRepository mUserRepository, com.example.comtesting.atomtry.request.mHttpRequest mHttpRequest) {
19 | this.mView = mView;
20 | this.mUserRepository = mUserRepository;
21 | this.mHttpRequest = mHttpRequest;
22 | }
23 |
24 | @Inject
25 | void setupListeners() {
26 | mView.setPresenter(this);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/login/LoginContract.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.login;
2 |
3 | import com.example.comtesting.atomtry.base.BasePresenter;
4 | import com.example.comtesting.atomtry.base.BaseView;
5 | import com.example.comtesting.atomtry.data.bean.UserLoginBean;
6 | import com.example.comtesting.atomtry.data.greendao.userLogin;
7 |
8 | /**
9 | * Created by atom on 2017/2/24.
10 | * login的view、presenter接口
11 | */
12 |
13 | public interface LoginContract {
14 | interface View extends BaseView {
15 | void showLoginDialog();
16 |
17 | void showLoginSuccess(UserLoginBean bean);
18 |
19 | void showLoginFail(String message);
20 |
21 | boolean isActive();
22 |
23 | boolean isRemember();
24 |
25 | void initUser(userLogin user);
26 | }
27 |
28 | interface presenter{
29 | void login(String userName, String password);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/mAppModule.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry;
2 |
3 | import android.content.Context;
4 |
5 | import com.example.comtesting.atomtry.request.HttpRequestFactory;
6 | import com.example.comtesting.atomtry.request.mHttpRequest;
7 |
8 | import java.util.concurrent.TimeUnit;
9 |
10 | import javax.inject.Singleton;
11 |
12 | import dagger.Module;
13 | import dagger.Provides;
14 | import okhttp3.OkHttpClient;
15 | import retrofit2.Retrofit;
16 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
17 | import retrofit2.converter.gson.GsonConverterFactory;
18 |
19 | /**
20 | * Created by atom on 2017/2/24.
21 | * 全局module
22 | */
23 | @Module
24 | public class mAppModule {
25 | private Context mContext;
26 |
27 | public mAppModule(Context mContext) {
28 | this.mContext = mContext;
29 | }
30 |
31 | @Singleton
32 | @Provides
33 | public mHttpRequest provideHttpRequest() {
34 | return HttpRequestFactory.getRetrofitHttpRequest();
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/login/LoginModule.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.login;
2 |
3 |
4 | import com.example.comtesting.atomtry.data.repository.UserRepository;
5 | import com.example.comtesting.atomtry.request.HttpRequestFactory;
6 | import com.example.comtesting.atomtry.request.mHttpRequest;
7 |
8 | import javax.inject.Singleton;
9 |
10 | import dagger.Module;
11 | import dagger.Provides;
12 |
13 | /**
14 | * Created by atom on 2017/2/24.
15 | * dagger的登录module
16 | */
17 | @Module
18 | public class LoginModule {
19 | private LoginContract.View mView;
20 |
21 | public LoginModule(LoginContract.View mView) {
22 | this.mView = mView;
23 | }
24 |
25 | @Provides
26 | LoginContract.View provideView(){
27 | return mView;
28 | }
29 | @Provides
30 | UserRepository provideUserRepository(){
31 | return new UserRepository();
32 | }
33 | // @Provides
34 | // mHttpRequest provideRequest(){
35 | // return HttpRequestFactory.getRetrofitHttpRequest();
36 | // }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/request/HttpResult.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.request;
2 |
3 | /**
4 | * Created by atom on 2017/3/15.
5 | * 网络请求返回
6 | */
7 |
8 | public class HttpResult {
9 | public String statusCode;
10 | public boolean status;
11 | public String message;
12 | public T data;
13 |
14 | public String getMessage() {
15 | return message;
16 | }
17 |
18 | public void setMessage(String message) {
19 | this.message = message;
20 | }
21 |
22 | public String getStatusCode() {
23 | return statusCode;
24 | }
25 |
26 | public void setStatusCode(String statusCode) {
27 | this.statusCode = statusCode;
28 | }
29 |
30 | public boolean isStatus() {
31 | return status;
32 | }
33 |
34 | public void setStatus(boolean status) {
35 | this.status = status;
36 | }
37 |
38 | public T getData() {
39 | return data;
40 | }
41 |
42 | public void setData(T data) {
43 | this.data = data;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
24 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
18 |
19 |
20 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.base;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.widget.Toast;
8 |
9 | import com.example.comtesting.atomtry.login.LoginPresenter;
10 | import com.trello.rxlifecycle2.components.support.RxFragment;
11 |
12 | /**
13 | *
14 | * @author atom
15 | * @date 2017/3/16
16 | */
17 |
18 | public class BaseFragment extends RxFragment{
19 | public ProgressDialog progressDialog;
20 | Context mContext;
21 |
22 | @Override
23 | public void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | mContext = getActivity();
26 | }
27 |
28 | public void showProgressDialog(String content){
29 | if (progressDialog==null){
30 | progressDialog=new ProgressDialog(mContext);
31 | }
32 | progressDialog.setMessage(content);
33 | progressDialog.show();
34 | }
35 | public void disMissProgressDialog(){
36 | if (progressDialog==null){
37 | return;
38 | }
39 | progressDialog.dismiss();
40 | }
41 |
42 | public void showToast(String content){
43 | Toast.makeText(mContext,content,Toast.LENGTH_SHORT).show();
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/utils/ciPherUtils.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.utils;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import java.io.UnsupportedEncodingException;
6 | import java.security.MessageDigest;
7 | import java.security.NoSuchAlgorithmException;
8 |
9 | /**
10 | * Created by atom on 2017/3/16.
11 | *
12 | */
13 |
14 | public class ciPherUtils {
15 | /**
16 | * 进行MD5加密(小写)
17 | */
18 | public static String Str2MD5LowCase(@NonNull String str) {
19 | return Str2MD5UpCase(str).toLowerCase();
20 | }
21 |
22 | /**
23 | * 进行MD5加密MD5加密
24 | */
25 | public static String Str2MD5UpCase(@NonNull String str) {
26 | byte[] hash;
27 | try {
28 | hash = MessageDigest.getInstance("MD5").digest(
29 | str.getBytes("UTF-8"));
30 | } catch (NoSuchAlgorithmException e) {
31 | throw new RuntimeException("Huh, MD5 should be supported?", e);
32 | } catch (UnsupportedEncodingException e) {
33 | throw new RuntimeException("Huh, UTF-8 should be supported?", e);
34 | }
35 | StringBuilder hex = new StringBuilder(hash.length * 2);
36 | for (byte b : hash) {
37 | if ((b & 0xFF) < 0x10)
38 | hex.append("0");
39 | hex.append(Integer.toHexString(b & 0xFF));
40 | }
41 | return hex.toString();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/login/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.login;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.Toolbar;
6 |
7 | import com.example.comtesting.atomtry.R;
8 | import com.example.comtesting.atomtry.base.BaseActivity;
9 | import com.example.comtesting.atomtry.mApplication;
10 | import com.example.comtesting.atomtry.utils.ActivityUtils;
11 |
12 | import javax.inject.Inject;
13 |
14 | /**
15 | * @author atom
16 | * 登录activity
17 | */
18 | public class LoginActivity extends BaseActivity {
19 | @Inject
20 | LoginPresenter presenter;
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_login);
25 | initView();
26 | }
27 | private void initView(){
28 | Toolbar toolbar = (Toolbar) findViewById(R.id.login_title);
29 | setSupportActionBar(toolbar);
30 | toolbar.setTitle(R.string.login);
31 |
32 | LoginFragment fragment=
33 | (LoginFragment) getSupportFragmentManager().findFragmentById(R.id.login_content);
34 | if (fragment==null){
35 | fragment=LoginFragment.newInstance();
36 | ActivityUtils.addFragment(getSupportFragmentManager(),fragment,R.id.login_content);
37 | }
38 | DaggerLoginComponent.builder()
39 | .mAppComponent(mApplication.getAppComponent())
40 | .loginModule(new LoginModule(fragment)).build().inject(this);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/mApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.app.Application;
5 | import android.content.Context;
6 |
7 | import com.example.comtesting.atomtry.greendao.gen.DaoMaster;
8 | import com.example.comtesting.atomtry.greendao.gen.DaoSession;
9 | import com.example.comtesting.atomtry.request.retrofitHttpRequest;
10 |
11 | import org.greenrobot.greendao.database.Database;
12 |
13 |
14 | /**
15 | * Created by atom on 2017/2/24.
16 | */
17 |
18 | public class mApplication extends Application {
19 | private static mAppComponent mAppComponent;
20 |
21 | private DaoSession daoSession;
22 | @SuppressLint("StaticFieldLeak")
23 | private static Context mContext;
24 | @Override
25 | public void onCreate() {
26 | super.onCreate();
27 | mContext=this;
28 | initGreenDao();
29 | retrofitHttpRequest.init();
30 | mAppComponent = DaggermAppComponent.builder()
31 | .mAppModule(new mAppModule(mContext)).build();
32 | }
33 |
34 | public static Context getmContext() {
35 | return mContext;
36 | }
37 |
38 | public static mAppComponent getAppComponent() {
39 | return mAppComponent;
40 | }
41 |
42 | private void initGreenDao(){
43 | DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "atom_db" );
44 | Database db = helper.getReadableDb();
45 | daoSession = new DaoMaster(db).newSession();
46 | }
47 |
48 | public DaoSession getDaoSession() {
49 | return daoSession;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/data/greendao/userLogin.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.data.greendao;
2 |
3 | import org.greenrobot.greendao.annotation.Entity;
4 | import org.greenrobot.greendao.annotation.Id;
5 | import org.greenrobot.greendao.annotation.Generated;
6 |
7 | /**
8 | * Created by atom on 2017/4/6.
9 | */
10 | @Entity
11 | public class userLogin {
12 | @Id(autoincrement = true)
13 | private Long id;
14 | private String userName;
15 | private String password;
16 | private boolean isRemember;
17 |
18 | public String getPassword() {
19 | return this.password;
20 | }
21 |
22 | public void setPassword(String password) {
23 | this.password = password;
24 | }
25 |
26 | public String getUserName() {
27 | return this.userName;
28 | }
29 |
30 | public void setUserName(String userName) {
31 | this.userName = userName;
32 | }
33 |
34 | public Long getId() {
35 | return this.id;
36 | }
37 |
38 | public void setId(Long id) {
39 | this.id = id;
40 | }
41 |
42 | public boolean getIsRemember() {
43 | return this.isRemember;
44 | }
45 |
46 | public void setIsRemember(boolean isRemember) {
47 | this.isRemember = isRemember;
48 | }
49 |
50 | @Generated(hash = 1270635441)
51 | public userLogin(Long id, String userName, String password, boolean isRemember) {
52 | this.id = id;
53 | this.userName = userName;
54 | this.password = password;
55 | this.isRemember = isRemember;
56 | }
57 |
58 | @Generated(hash = 1680734102)
59 | public userLogin() {
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/comtesting/atomtry/rxbus/RxBus.java:
--------------------------------------------------------------------------------
1 | package com.example.comtesting.atomtry.rxbus;
2 |
3 | import io.reactivex.Observable;
4 | import io.reactivex.android.schedulers.AndroidSchedulers;
5 | import io.reactivex.disposables.Disposable;
6 | import io.reactivex.functions.Consumer;
7 | import io.reactivex.subjects.PublishSubject;
8 | import io.reactivex.subjects.Subject;
9 |
10 | /**
11 | * Created by atom on 2017/3/23.
12 | * 自定义事件总线eventbus
13 | */
14 |
15 | public class RxBus {
16 |
17 | private static volatile RxBus instance;
18 | private final Subject