@Override protected void onResume() { // TODO Auto-generated method stub super.onResume(); String host = PersistenceManager.getInstance(LoginActivity.this).getHostIp(); String port = PersistenceManager.getInstance(LoginActivity.this).getHostPort(); if (host != null && port != null && !host.equals("") && !port.equals("")) { HTTPConstant.HOST_URL_NO_SPRIT = "http://" + host + ":" + port; HTTPConstant.HOST_URL = HTTPConstant.HOST_URL_NO_SPRIT + "/"; System.out.println("Ip被设置为:" + HTTPConstant.HOST_URL + "--" + HTTPConstant.HOST_URL_NO_SPRIT); HTTPConstant.resetValues(); } // else { // HTTPConstant.HOST_URL = null; // HTTPConstant.HOST_URL_NO_SPRIT = null; // } }
@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); } }
/** 这个方法用于初始化界面 */ private void initView() { /** 这几行代码用来设置页面头部的布局,就是页面的提示信息,以及页面返回按钮 */ setActionBar(R.layout.include_head_textbtn); setActionBarWidgetResource( ViewIdConstant.ACTIONBAR_TITLE, ResourceConstant.ACTIONBAR_TITLE, "登录"); BackImageView backImageView = (BackImageView) getActionBarViewByMarkId( ViewIdConstant.ACTIONBAR_BACK_IAMGEVIEW, ResourceConstant.ACTIONBAR_BACK_IMAGEVIEW); backImageView.setVisibility(View.GONE); /** 根据布局页面找到控件 */ userNameEditText = (EditText) findViewById(R.id.login_user_name); passwordEditText = (EditText) findViewById(R.id.login_password); userNameEditText.setText(PersistenceManager.getInstance(LoginActivity.this).getUserName()); passwordEditText.setText(PersistenceManager.getInstance(LoginActivity.this).getPassword()); loginBtn = (Button) findViewById(R.id.login_login); settingButton = (Button) findViewById(R.id.login_setting); /** 设置监听事件 */ settingButton.setOnClickListener(listener); loginBtn.setOnClickListener(listener); UserConstant.admin = null; UserConstant.diseaseCategories = null; UserConstant.diseaseTypes = null; }