login page logic

chengzhenyu 8 years ago
parent
commit
b880dbc570

+ 36 - 3
app/src/main/java/ai/pai/lensman/login/LoginActivity.java

@@ -2,26 +2,59 @@ package ai.pai.lensman.login;
2 2
 
3 3
 import android.content.Intent;
4 4
 import android.os.Bundle;
5
+import android.view.View;
6
+import android.widget.EditText;
7
+
8
+import com.android.views.progressbar.ProgressWheel;
5 9
 
6 10
 import ai.pai.lensman.R;
7 11
 import ai.pai.lensman.base.BaseActivity;
8
-import ai.pai.lensman.db.Preferences;
9 12
 import ai.pai.lensman.upload.UploadActivity;
13
+import butterknife.BindView;
10 14
 import butterknife.ButterKnife;
11 15
 import butterknife.OnClick;
12 16
 
13
-public class LoginActivity extends BaseActivity {
17
+public class LoginActivity extends BaseActivity implements LoginContract.View{
18
+
19
+    @BindView(R.id.et_login_pwd)       EditText pwdET;
20
+    @BindView(R.id.et_login_user_name) EditText usernameET;
21
+    @BindView(R.id.wheel_wait_http)    ProgressWheel progressWheel;
22
+
23
+    private LoginContract.Presenter presenter;
14 24
 
15 25
     @Override
16 26
     protected void onCreate(Bundle savedInstanceState) {
17 27
         super.onCreate(savedInstanceState);
18 28
         setContentView(R.layout.activity_login);
19 29
         ButterKnife.bind(this);
30
+        presenter = new LoginPresenter(this);
20 31
     }
21 32
 
33
+
22 34
     @OnClick(R.id.btn_login)
23 35
     public void login(){
24
-        Preferences.getInstance(this).setLensManId("hafihafhHDFA");
36
+        presenter.login(usernameET.getText().toString(),pwdET.getText().toString());
37
+    }
38
+
39
+    @Override
40
+    public void showLoginHint(String hint) {
41
+
42
+    }
43
+
44
+    @Override
45
+    public void showProgressView() {
46
+        progressWheel.setVisibility(View.VISIBLE);
47
+        progressWheel.startSpinning();
48
+    }
49
+
50
+    @Override
51
+    public void hideProgressView() {
52
+        progressWheel.stopSpinning();
53
+        progressWheel.setVisibility(View.GONE);
54
+    }
55
+
56
+    @Override
57
+    public void jumpMain() {
25 58
         startActivity(new Intent(this, UploadActivity.class));
26 59
         finish();
27 60
     }

+ 5 - 4
app/src/main/java/ai/pai/lensman/login/LoginContract.java

@@ -5,15 +5,16 @@ package ai.pai.lensman.login;
5 5
  */
6 6
 public class LoginContract {
7 7
 
8
-    interface LoginView{
9
-
8
+    interface View{
9
+        void showLoginHint(String hint);
10 10
         void showProgressView();
11 11
         void hideProgressView();
12
+        void jumpMain();
12 13
 
13 14
     }
14 15
 
15
-    interface LoginPresenter{
16
-
16
+    interface Presenter{
17
+        void login(String userName,String pwd);
17 18
     }
18 19
 
19 20
 }

+ 20 - 0
app/src/main/java/ai/pai/lensman/login/LoginPresenter.java

@@ -0,0 +1,20 @@
1
+package ai.pai.lensman.login;
2
+
3
+/**
4
+ * Created by chengzhenyu on 2016/8/11.
5
+ */
6
+public class LoginPresenter implements LoginContract.Presenter {
7
+
8
+    private LoginContract.View view;
9
+
10
+    public LoginPresenter(LoginContract.View view){
11
+        this.view = view;
12
+    }
13
+
14
+    @Override
15
+    public void login(String userName, String pwd) {
16
+        view.showProgressView();
17
+
18
+    }
19
+
20
+}

+ 9 - 0
app/src/main/res/layout/activity_login.xml

@@ -2,6 +2,7 @@
2 2
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3
     android:layout_width="match_parent"
4 4
     android:layout_height="match_parent"
5
+    xmlns:progress="http://schemas.android.com/apk/res-auto"
5 6
     android:background="@color/login_bg_blue">
6 7
 
7 8
     <ImageView
@@ -98,4 +99,12 @@
98 99
         android:textColor="@color/white"
99 100
         android:textSize="18sp" />
100 101
 
102
+    <com.android.views.progressbar.ProgressWheel
103
+        android:id="@+id/wheel_wait_http"
104
+        android:layout_width="80dp"
105
+        android:layout_height="80dp"
106
+        android:layout_centerInParent="true"
107
+        progress:text="@string/please_wait"
108
+        android:visibility="gone"/>
109
+
101 110
 </RelativeLayout>

+ 4 - 0
app/src/main/res/values/strings.xml

@@ -11,6 +11,10 @@
11 11
     <string name="account_name">账号</string>
12 12
     <string name="password">密码</string>
13 13
 
14
+    <string name="login_success">登录成功</string>
15
+    <string name="login_fail">登录失败</string>
16
+    <string name="please_wait">请稍候</string>
17
+
14 18
     <string name="network_disconnect">当前无网络连接</string>
15 19
 
16 20
     <string name="qr_scan_hint">将取景框对准二维码,\n即可自动扫码</string>