示例#1
0
 @Override
 public void onSuccess(UserMessage t, com.jun.android_frame.entity.BaseEntity baseEntity) {
   if (baseEntity.getStatus() == 1) { // 成功
     PersistenceManager.getInstance(LoginActivity.this).putAdmin(t.getAdmin());
     PersistenceManager.getInstance(LoginActivity.this)
         .putDiseaseCatogory(t.getDiseaseCategoryList());
     PersistenceManager.getInstance(LoginActivity.this)
         .putDiseaseType(t.getDiseaseTypeList());
     PersistenceManager.getInstance(LoginActivity.this).putUserName(userNameString);
     PersistenceManager.getInstance(LoginActivity.this).putPassorw(passwordString);
     Intent intent = new Intent();
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
     intent.setClass(LoginActivity.this, MainActivity.class);
     startActivity(intent);
     finish();
   } else if (baseEntity.getStatus() == 2) { // 没权限
     SystemUtils.MToast("没有权限", LoginActivity.this);
   } else if (baseEntity.getStatus() == 0) { // 失败
     SystemUtils.MToast("登录失败", LoginActivity.this);
   }
 }
示例#2
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
       /** 这里是登录请求的事件 */
     case R.id.login_login: // 登录按钮事件执行
       if (HTTPConstant.HOST_URL == null) {
         SystemUtils.MToast("请设置Ip地址和端口号", LoginActivity.this);
         return;
       }
       userNameString = userNameEditText.getEditableText().toString();
       passwordString = passwordEditText.getEditableText().toString();
       if (userNameString.equals("") || passwordString.equals("")) {
         SystemUtils.MToast("请输入完整的账号密码", LoginActivity.this);
         return;
       }
       /** 这里是正式的HTTP请求了 */
       RequestParams requestParams = new RequestParams(); // 设置请求参数
       requestParams.add("admin.username", userNameString);
       requestParams.add("admin.password", passwordString);
       /** 通过这个BaseConnectTemplet,这是一个加载数据的公共类,他在加载的时候,会弹出一个对话框 */
       BaseConnectTemplet<UserMessage> baseConnectTemplet =
           new BaseConnectTemplet<>(
               LoginActivity.this,
               "提示",
               "正在登陆",
               httpConnectReciver,
               requestParams,
               HTTPConstant.LOGIN_URL,
               new TypeToken<UserMessage>() {}.getType());
       baseConnectTemplet.setProgressViewCanCancel();
       baseConnectTemplet.getData();
       break;
     case R.id.login_setting: // 跳转到设置界面
       SystemUtils.intentToAnotherActivity(LoginActivity.this, SettingActivity.class);
       break;
     default:
       break;
   }
 }
示例#3
0
 @Override
 public void onFail(String string) {
   SystemUtils.MToast("连接服务器失败!", LoginActivity.this);
 }