QuickLoginActivity.java
6.91 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.cnlive.libs;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.cnlive.libs.user.IUserService;
import com.cnlive.libs.user.UserUtil;
import com.cnlive.libs.user.model.UserData;
import com.cnlive.libs.util.data.network.Callback;
/**
* 用户快捷登录(手机验证码登录)
*/
public class QuickLoginActivity extends BaseActivity implements View.OnClickListener {
private static final String SEND_MESSAGE_TAG = "SendMsgbefQuickLogin";
private static final String QUICK_LOGIN = "QuickLogin";
private EditText mobile, code;
private Button getCode, quickLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quick_login);
initView();
}
private void initView() {
mobile = (EditText) this.findViewById(R.id.mobile);
code = (EditText) this.findViewById(R.id.number);
getCode = (Button) findViewById(R.id.getNumber);
getCode.setOnClickListener(this);
quickLogin = (Button) findViewById(R.id.quick_login);
quickLogin.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.getNumber:
/**
* 快捷登录前发送手机验证码
* @param type
* @param mobile 手机号
* @param callback 回调
*
* 发送手机验证码需要传入一个type值用来区分发送的验证码是用来做什么的
* QUICK_LOGIN--->快捷登陆前发送手机验证码
* REGISTER_OR_MODIFY_MOBILE---> 注册或修改手机号前发手机验证码
* RETRIEVE_OR_MODIFY_PASSWORD---> 找回或修改密码前发手机验证码
*/
UserUtil.sendMessage(IUserService.QUICK_LOGIN, mobile.getText().toString(), new Callback() {
@Override
public void onState(int what, String extra, Object obj) {
showToast(extra + " : " + obj.toString());
switch (what) {
case IUserService.SUCCESS:
//成功
break;
case IUserService.ERROR_PARAM:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_param);
break;
case IUserService.ERROR_MOBILE:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_mobile);
break;
case IUserService.ERROR_CLIENT_PLAT:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_client_plat);
break;
case IUserService.ERROR_MESSAGE_SERVER:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_server);
break;
case IUserService.ERROR_MESSAGE_SERVER_ANALYSIS:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_message_server_analysis);
break;
case IUserService.ERROR_OTHER:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_other);
break;
case IUserService.ERROR_SEND_MESSAGE_TO_MUCH:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_send_message_to_much);
break;
case IUserService.ERROR_SEND_MESSAGE_FAILED:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_send_message_failed);
break;
case IUserService.ERROR_MESSAGE_OTHER:
Log.e(SEND_MESSAGE_TAG, IUserService.message_error_message_other);
break;
}
}
});
break;
case R.id.quick_login:
/**
* 快捷登录
* @param userName 手机号
* @param verificationCode 验证码
* @param frmId 渠道ID(非必传参数,可传"")
* @param callback 回调
*/
UserUtil.quickLogin(mobile.getText().toString(), code.getText().toString(), "", new Callback() {
@Override
public void onState(int what, String extra, Object obj) {
showToast(extra + " : " + obj.toString());
switch (what) {
case IUserService.SUCCESS:
//成功 obj返回用户信息
userData = ((UserData) obj);
break;
case IUserService.ERROR_PARAM:
Log.e(QUICK_LOGIN, IUserService.message_error_param);
break;
case IUserService.ERROR_CLIENT_PLAT:
Log.e(QUICK_LOGIN, IUserService.message_error_client_plat);
break;
case IUserService.ERROR_MOBILE:
Log.e(QUICK_LOGIN, IUserService.message_error_mobile);
break;
case IUserService.ERROR_VERIFICATION_CODE_LENGTH:
Log.e(QUICK_LOGIN, IUserService.message_error_verfication_code_length);
break;
case IUserService.ERROR_VERIFICATION_CODE:
Log.e(QUICK_LOGIN, IUserService.message_error_verfication_code);
break;
case IUserService.ERROR_MOBILE_EXIST:
Log.e(QUICK_LOGIN, IUserService.message_error_mobile_exist);
break;
case IUserService.ERROR_NICK_NAME_EXIST:
Log.e(QUICK_LOGIN, IUserService.message_error_nick_name_exist);
break;
case IUserService.ERROR_OTHER:
Log.e(QUICK_LOGIN, IUserService.message_error_other);
break;
}
}
});
break;
}
}
@Override
protected void showToast(String msg) {
super.showToast(msg);
}
}