Skip to content

Commit b894672

Browse files
author
Yaoda Wang
committed
finished first demo.
1 parent 7e5b0f0 commit b894672

File tree

14 files changed

+561
-417
lines changed

14 files changed

+561
-417
lines changed

.idea/codeStyleSettings.xml

Lines changed: 229 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
android:roundIcon="@mipmap/ic_launcher_round"
1515
android:supportsRtl="true"
1616
android:theme="@style/AppTheme">
17-
<activity
18-
android:name=".LoginActivity"
19-
android:label="@string/app_name">
17+
<activity android:name=".RxLoginActivity">
18+
2019
<intent-filter>
2120
<action android:name="android.intent.action.MAIN"/>
2221

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.phoenix.demo.rxauthdemo;
2+
3+
import android.text.TextUtils;
4+
5+
import io.phoenix.demo.rxauthdemo.action.AuthAction.SignUpAction;
6+
import io.phoenix.demo.rxauthdemo.result.AuthResult;
7+
import io.reactivex.Observable;
8+
9+
import static io.phoenix.demo.rxauthdemo.result.AuthResult.SignUpResult;
10+
11+
12+
/**
13+
* Created by yaoda on 24/04/17.
14+
*/
15+
16+
public class AuthManager {
17+
public Observable<AuthResult.SignUpResult> signUp(SignUpAction action) {
18+
19+
if (TextUtils.isEmpty(action.getUsername()) || !action.getUsername().contains("@")) {
20+
return Observable.fromCallable(() -> {
21+
Thread.sleep(1000);
22+
return SignUpResult.FAIL_USERNAME;
23+
});
24+
}
25+
if (TextUtils.isEmpty(action.getPassword()) || action.getPassword().length() < 9) {
26+
return Observable.fromCallable(() -> {
27+
Thread.sleep(1000);
28+
return SignUpResult.FAIL_PASSWORD;
29+
});
30+
}
31+
// TODO: createUser
32+
return Observable.fromCallable(() -> {
33+
Thread.sleep(1000);
34+
return SignUpResult.SUCCESS;
35+
});
36+
}
37+
38+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package io.phoenix.demo.rxauthdemo;
2+
3+
/**
4+
* Created by yaoda on 24/04/17.
5+
*/
6+
7+
public class AuthUiModel {
8+
private final boolean inProcess;
9+
private final boolean usrValidate;
10+
private final boolean pwdValidate;
11+
private final boolean success;
12+
13+
private final String errorMessage;
14+
15+
private AuthUiModel(boolean inProcess, boolean usrValidate, boolean pwdValidate, boolean success, String errorMessage) {
16+
this.inProcess = inProcess;
17+
this.usrValidate = usrValidate;
18+
this.pwdValidate = pwdValidate;
19+
this.success = success;
20+
this.errorMessage = errorMessage;
21+
22+
23+
}
24+
25+
public static AuthUiModel idle() {
26+
return new AuthUiModel(false, true, true, false, "");
27+
}
28+
29+
public static AuthUiModel inProcess() {
30+
return new AuthUiModel(true, true, true, false, "");
31+
}
32+
33+
public static AuthUiModel success() {
34+
return new AuthUiModel(false, true, true, true, "");
35+
}
36+
37+
public static AuthUiModel fail(boolean username, boolean password, String msg) {
38+
return new AuthUiModel(false, username, password, false, msg);
39+
}
40+
41+
public boolean isSuccess() {
42+
return success;
43+
}
44+
45+
public boolean isInProcess() {
46+
return inProcess;
47+
}
48+
49+
public boolean isUsrValidate() {
50+
return usrValidate;
51+
}
52+
53+
public boolean isPwdValidate() {
54+
return pwdValidate;
55+
}
56+
57+
public String getErrorMessage() {
58+
return errorMessage;
59+
}
60+
}

0 commit comments

Comments
 (0)