我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Android登录代码MVP架构详解-创新互联

登录代码MVP架构的具体实现,分享给大家。

为企业提供网站制作、成都网站设计、网站优化、成都全网营销、竞价托管、品牌运营等营销获客服务。成都创新互联拥有网络营销运营团队,以丰富的互联网营销经验助力企业精准获客,真正落地解决中小企业营销获客难题,做到“让获客更简单”。自创立至今,成功用技术实力解决了企业“网站建设、网络品牌塑造、网络营销”三大难题,同时降低了营销成本,提高了有效客户转化率,获得了众多企业客户的高度认可!

MainActivity.java

public class MainActivity extends AppCompatActivity implements View.OnClickListener, Mvp.fff {

  private EditText mUsername;
  private EditText mPassword;
  private Button login;
  private ProgressDialog mProgressDialog;
  private Mvp mMvp;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();

     mMvp = new Mvp(this);

  }
  private void initView() {
    mUsername = (EditText) findViewById(R.id.username);
    mPassword = (EditText) findViewById(R.id.password);
    login = (Button) findViewById(R.id.login);

    login.setOnClickListener(this);

    //动态的创建一个进度条
    mProgressDialog = new ProgressDialog(this);
  }

  @Override
  public void onClick(View view) {

    switch (view.getId()){
      case R.id.login:
        String user = mUsername.getText().toString();
        String pass = mPassword.getText().toString();
        final User users = new User();
        users.username=user;
        users.password=pass;


        Boolean empty = mMvp.isEmpty(users);
        if (empty){

          mProgressDialog.show();
          mMvp.isLogin(users);
        }else {

          Toast.makeText(MainActivity.this, "输入不能为空", Toast.LENGTH_SHORT).show();
          return;
        }

        break;
    }

  }

  @Override
  public void success() {

    runOnUiThread(new Runnable() {
      @Override
      public void run() {
        mProgressDialog.dismiss();
        Toast.makeText(MainActivity.this, "欢迎回来,思密达", Toast.LENGTH_SHORT).show();
      }
    });
  }

  @Override
  public void doil() {

    runOnUiThread(new Runnable() {
      @Override
      public void run() {
        mProgressDialog.dismiss();
        Toast.makeText(MainActivity.this, "登录失败,账号密码有问题", Toast.LENGTH_SHORT).show();
      }
    });
  }

  @Override
  protected void onDestroy() {
    super.onDestroy();
    mMvp=null;
  }
}

文章标题:Android登录代码MVP架构详解-创新互联
链接URL:http://shouzuofang.com/article/iipgi.html

其他资讯