Demo entry 6350282

登录代码片

   

Submitted by anonymous on Mar 09, 2017 at 09:32
Language: Java. Code size: 2.1 kB.

  @Click(R.id.tv_login)
    void btnLogin() {
        begin();
    }

 @Background(id = "login")
    void login(final String phone, final String psd) {
        NetUtils.Callback<LoginResult> getTransListResultCallback = 
														new NetUtils.Callback<LoginResult>() {
            @Override
            public LoginResult doRequest() {
                // 加入网络状态参数;
                return iUserService.login(new LoginParam(phone, psd, "android", JPushInterface.
						getRegistrationID(LoginActivity.this),SystemInfoUtils.
						getDeviceUuid(LoginActivity.this).toString(),
                        GetNetWorkStatus.getNetWorkStatus(LoginActivity.this),
                        GetNetWorkStatus.getIMEI(LoginActivity.this)
                        ));
            }

            @Override
            public void successRequest(LoginResult result) {
                if (result != null) {
                    //登录成功
                    if (result.getStatus() == 1 && result.getData() != null) {
                        Login login = result.getData();
                        MainApp.getInstance().loginMsg = login;
                        userPrefs.sessionId().put(login.getSessionId());
                        userPrefs.phone().put(phone);
                        userPrefs.password().put(psd);
						......
						......
                        Meta.sessionId = login.getSessionId();
                        if (null != login.getStudents() && login.getStudents().size() > 0) {...}
                        et_login_phone.setText("");
                        et_login_password.setText("");
                        MainActivity_.intent(com.education.activity.LoginActivity.this).start();
                        com.education.activity.LoginActivity.this.finish();
                    } else {
                        showShortToast(result.getMsg());
                    }
                }
            }

            @Override
            public void afterRequest() {
                hideLoading();
            }
        };
        netUtils.execRequest(getTransListResultCallback);
    }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).