|
@@ -7,9 +7,16 @@ import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.netease.nim.uikit.permission.MPermission;
|
|
|
import com.sheishuo.app.R;
|
|
|
+import com.sheishuo.app.cache.AccountCache;
|
|
|
+import com.sheishuo.app.common.util.data.SPHelper;
|
|
|
+import com.sheishuo.app.common.util.net.NetImpl;
|
|
|
+import com.sheishuo.app.common.util.net.ResponseCallback;
|
|
|
+import com.sheishuo.app.login.beans.LoginBean;
|
|
|
+import com.sheishuo.app.login.helper.LoginHelper;
|
|
|
import com.sheishuo.app.uikit_implements.SheishuoUI;
|
|
|
|
|
|
public class LoginAndRegActivity extends SheishuoUI implements View.OnClickListener{
|
|
@@ -49,8 +56,8 @@ public class LoginAndRegActivity extends SheishuoUI implements View.OnClickListe
|
|
|
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
|
|
// WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
|
|
setContentView(R.layout.login_and_reg_layout);
|
|
|
- init();
|
|
|
requestBasicPermission();
|
|
|
+ init();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -59,6 +66,45 @@ public class LoginAndRegActivity extends SheishuoUI implements View.OnClickListe
|
|
|
regBtn = findView(R.id.btn_register);
|
|
|
loginBtn.setOnClickListener(this);
|
|
|
regBtn.setOnClickListener(this);
|
|
|
+
|
|
|
+ final String mobile = (String) SPHelper.getParam(context,"mobile","");
|
|
|
+ final String pwd = (String) SPHelper.getParam(context,"pwd","");
|
|
|
+ if (!(mobile.isEmpty() || pwd.isEmpty())){
|
|
|
+ showToast(context,"自动登录中,请稍后");
|
|
|
+ new NetImpl().loginQuery(mobile, pwd, new ResponseCallback() {
|
|
|
+ @Override
|
|
|
+ public void onSuccess(Object object) {
|
|
|
+ LoginBean bean = (LoginBean)object;
|
|
|
+ //存入SP用于自动登录
|
|
|
+ SPHelper.setParam(context,"mobile",mobile);
|
|
|
+ SPHelper.setParam(context,"pwd",pwd);
|
|
|
+
|
|
|
+
|
|
|
+ //将用户信息放入缓存
|
|
|
+ AccountCache.setCache(bean.getD());
|
|
|
+ AccountCache.sync();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //登录NIM服务
|
|
|
+ new LoginHelper(context,bean).loginToNIM();
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailed() {
|
|
|
+ getHandler().post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ Toast.makeText(context,"登录失败",Toast.LENGTH_SHORT).show();
|
|
|
+ loginBtn.setEnabled(true);
|
|
|
+ loginBtn.setText("登录");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
protected <T extends View> T findView(int resId) {
|
|
|
return (T) (findViewById(resId));
|