LoginActivity.java
This commit is contained in:
parent
76e0c6fb5f
commit
39fb66d3ec
|
@ -42,7 +42,7 @@ import com.tencent.tauth.Tencent;
|
|||
import com.tencent.tauth.UiError;
|
||||
|
||||
/**
|
||||
* 登陆界面
|
||||
* 鐧婚檰鐣岄潰
|
||||
*
|
||||
* @date 2014-4-24
|
||||
* @author Stone
|
||||
|
@ -66,7 +66,7 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|||
private ImageView mNewLoginButton;
|
||||
private TextView backInfo;
|
||||
|
||||
// QQ登陆
|
||||
// QQ鐧婚檰
|
||||
private static Tencent mTencent;
|
||||
// private QQAuth mQQAuth;
|
||||
|
||||
|
@ -97,12 +97,12 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 初始化 Bmob SDK
|
||||
// 使用时请将第二个参数Application ID替换成你在Bmob服务器端创建的Application ID
|
||||
// 鍒濆鍖<EFBFBD> Bmob SDK
|
||||
// 浣跨敤鏃惰灏嗙浜屼釜鍙傛暟Application ID鏇挎崲鎴愪綘鍦˙mob鏈嶅姟鍣ㄧ鍒涘缓鐨凙pplication ID
|
||||
Bmob.initialize(this, "252a2c58d0dc9a78a5411501c62ce0de");
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
// QQ登陆, 获取实例
|
||||
// QQ鐧婚檰, 鑾峰彇瀹炰緥
|
||||
// mQQAuth = QQAuth.createInstance(APP_ID,
|
||||
// this.getApplicationContext());
|
||||
mTencent = Tencent.createInstance(APP_ID, this.getApplicationContext());
|
||||
|
@ -134,7 +134,7 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|||
etPassword.setText(sp.getString("password", null));
|
||||
}
|
||||
|
||||
// 保存用户的登陆记录
|
||||
// 淇濆瓨鐢ㄦ埛鐨勭櫥闄嗚褰<EFBFBD>
|
||||
private void saveUserInfo(String username, String password) {
|
||||
SharedPreferences sp = getSharedPreferences("UserInfo", 0);
|
||||
Editor editor = sp.edit();
|
||||
|
@ -157,15 +157,15 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
// 登陆
|
||||
// 鐧婚檰
|
||||
case R.id.btn_login:
|
||||
username = etUsername.getText().toString();
|
||||
password = etPassword.getText().toString();
|
||||
|
||||
if (!Util.isNetworkConnected(this)) {
|
||||
toast("木有网络 ( ⊙ o ⊙ ) ");
|
||||
toast("鏈ㄦ湁缃戠粶 ( 鈯<> o 鈯<> ) ");
|
||||
} else if (username.equals("") || password.equals("")) {
|
||||
toast("请输入账号和密码");
|
||||
toast("璇疯緭鍏ヨ处鍙峰拰瀵嗙爜");
|
||||
break;
|
||||
} else {
|
||||
final User bu2 = new User();
|
||||
|
@ -174,10 +174,10 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|||
bu2.login(this, new InsertListener() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
toast("欢迎进入 在这里 服务系统");
|
||||
// 保存用户信息
|
||||
toast("娆㈣繋杩涘叆 鍦ㄨ繖閲<E7B996> 鏈嶅姟绯荤粺");
|
||||
// 淇濆瓨鐢ㄦ埛淇℃伅
|
||||
saveUserInfo(username, password);
|
||||
// 跳转到主页
|
||||
// 璺宠浆鍒颁富椤<EFBFBD>
|
||||
User.userId = bu2.getObjectId();
|
||||
Intent toHome = new Intent(LoginActivity.this, BaseActivity.class);
|
||||
startActivity(toHome);
|
||||
|
@ -187,7 +187,7 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|||
|
||||
@Override
|
||||
public void onFailure(String msg) {
|
||||
toast("用户名或密码错误");
|
||||
toast("鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -227,15 +227,15 @@ public class LoginActivity extends Activity implements OnClickListener {
|
|||
@Override
|
||||
public void onComplete(Object response) {
|
||||
if (null == response) {
|
||||
Util.showResultDialog(LoginActivity.this, "返回为空", "登录失败");
|
||||
Util.showResultDialog(LoginActivity.this, "杩斿洖涓虹┖", "鐧诲綍澶辫触");
|
||||
return;
|
||||
}
|
||||
JSONObject jsonResponse = (JSONObject) response;
|
||||
if (null != jsonResponse && jsonResponse.length() == 0) {
|
||||
Util.showResultDialog(LoginActivity.this, "返回为空", "登录失败");
|
||||
Util.showResultDialog(LoginActivity.this, "杩斿洖涓虹┖", "鐧诲綍澶辫触");
|
||||
return;
|
||||
}
|
||||
// Util.showResultDialog(LoginActivity.this, response.toString(), "登录成功");
|
||||
// Util.showResultDialog(LoginActivity.this, response.toString(), "鐧诲綍鎴愬姛");
|
||||
doComplete((JSONObject) response);
|
||||
try {
|
||||
User.userId = jsonResponse.getString("openid");
|
||||
|
|
Loading…
Reference in New Issue