新!!!登录

public class MainActivity extends AppCompatActivity implements IManintenter {
private String path=“http://172.17.8.100/small/user/v1/login”;
private EditText name;
private EditText pwd;
private Button denglu;
private Button zhuce;
private HoemPresenter hoemPresenter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    name = findViewById(R.id.name);
    pwd = findViewById(R.id.pwd);
    denglu = findViewById(R.id.denglu);
    zhuce = findViewById(R.id.zhuce);
    hoemPresenter = new HoemPresenter(this);
   denglu.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
           String sname = name.getText().toString();
           String spwd = pwd.getText().toString();
           hoemPresenter.getpresenter(path,sname,spwd);
       }
   });
   zhuce.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View v) {
           Intent intent = new Intent(MainActivity.this,ZhuChe.class);
           startActivity(intent);
       }
   });
}

@Override
public void getview(String s) {
    Log.i("AA","ss"+s);
    Gson gson = new Gson();
    DengLu dengLu = gson.fromJson(s, DengLu.class);
    if (dengLu.getStatus().equals("0000")) {
        Intent intent = new Intent(MainActivity.this, ZhanShiActivity.class);
        startActivity(intent);
    } else if (dengLu.getStatus().equals("1001")) {
        Intent intent = new Intent(MainActivity.this, ZhuChe.class);
        startActivity(intent);
    }
}

}

public class HoemPresenter {
private final Okhttp getdanli;
MainActivity mainActivity;

public HoemPresenter(MainActivity mainActivity1) {
    this.mainActivity = mainActivity1;
    getdanli = Okhttp.getdanli();
}

public void getpresenter(String s, String name, String pwd) {
    getdanli.post(s, name, pwd, new Okhttp.getokhttp() {
        @Override
        public void getcheng(String s) {
            mainActivity.getview(s);
        }
    });
}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值