| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- package eVVM.apk.ui.login;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Environment;
- import android.support.annotation.Nullable;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.text.TextUtils;
- import android.util.Log;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.ImageView;
- import java.io.File;
- import java.util.ArrayList;
- import java.util.List;
- import butterknife.BindView;
- import butterknife.OnClick;
- import cn.bingoogolapple.photopicker.activity.BGAPhotoPickerActivity;
- import cn.bingoogolapple.photopicker.imageloader.BGAImage;
- import eVVM.apk.R;
- import eVVM.apk.common.MyActivity;
- import eVVM.apk.helper.InputTextHelper;
- import eVVM.apk.helper.SPUtils;
- import eVVM.apk.helper.SystemUtil;
- import eVVM.apk.mvp.MvpActivity;
- import eVVM.apk.ui.bean.VerificationCodeBean;
- import eVVM.apk.ui.login.authentication.AttctContract;
- import eVVM.apk.ui.login.authentication.AttctPresenter;
- import me.jessyan.autosize.utils.AutoSizeUtils;
- /**
- * 实名认证页
- */
- public class AuthenticationActivity extends MvpActivity<AttctPresenter> implements AttctContract.View {
- @BindView(R.id.attc_et_phone)
- EditText attcEtPhone;
- @BindView(R.id.attc_et_name)
- EditText attcEtName;
- @BindView(R.id.attc_et_code)
- EditText attcEtCode;
- @BindView(R.id.attc_et_email)
- EditText attcEtEmail;
- @BindView(R.id.attc_et_post)
- EditText attcEtPost;
- @BindView(R.id.attc_et_license)
- ImageView attcEtLicense;
- @BindView(R.id.attc_et_prove)
- ImageView attcEtProve;
- @BindView(R.id.attc_btn_register)
- Button attcBtnRegister;
- private File takePhotoDir = new File(Environment.getExternalStorageDirectory(), "eVVM");
- private static final int REQUEST_LICENSE_CHOOSE_FROM_GALLERY = 1325;
- private static final int REQUEST_PROVE_CHOOSE_FROM_GALLERY = 1326;
- @Override
- protected int getLayoutId() {
- return R.layout.activity_authentication;
- }
- @Override
- protected int getTitleId() {
- return R.id.attc_title;
- }
- @Override
- protected void initView() {
- new InputTextHelper.Builder(this)
- .setMain(attcBtnRegister)
- .addView(attcEtPhone)
- .addView(attcEtName)
- .addView(attcEtCode)
- .addView(attcEtEmail)
- .addView(attcEtPost)
- .build();
- }
- @Override
- protected void initData() {
- }
- @OnClick({R.id.attc_et_license, R.id.attc_et_prove, R.id.attc_btn_register})
- public void onViewClicked(View view) {
- switch (view.getId()) {
- case R.id.attc_et_license:
- //上传营业执照
- /*
- 从相册选取二维码图片,这里为了方便演示,使用的是
- https://github.com/bingoogolapple/BGAPhotoPicker-Android
- 这个库来从图库中选择二维码图片,这个库不是必须的,你也可以通过自己的方式从图库中选择图片
- */
- Intent licensePhotoPickerIntent = new BGAPhotoPickerActivity.IntentBuilder(this)
- .cameraFileDir(takePhotoDir)
- .maxChooseCount(1)
- .selectedPhotos(null)
- .pauseOnScroll(false)
- .build();
- startActivityForResult(licensePhotoPickerIntent, REQUEST_LICENSE_CHOOSE_FROM_GALLERY);
- break;
- case R.id.attc_et_prove:
- //上传授权证明
- if (uploadimgpaths.size() == 0){
- toast("请先上传营业执照");
- }else {
- Intent provePhotoPickerIntent = new BGAPhotoPickerActivity.IntentBuilder(this)
- .cameraFileDir(takePhotoDir)
- .maxChooseCount(1)
- .selectedPhotos(null)
- .pauseOnScroll(false)
- .build();
- startActivityForResult(provePhotoPickerIntent, REQUEST_PROVE_CHOOSE_FROM_GALLERY);
- }
- break;
- case R.id.attc_btn_register:
- //进行实名认证
- if (uploadimgpaths.size() < 2){
- toast("请上传营业执照及授权证明");
- }else {
- String user_id = (String) SPUtils.get("USER_ID", "");
- if (TextUtils.isEmpty(user_id)){
- }else {
- getPresenter().attct(Integer.parseInt(user_id),attcEtPhone.getText().toString()
- ,attcEtName.getText().toString(),attcEtCode.getText().toString(),
- attcEtEmail.getText().toString(),2,0, SystemUtil.getSystemModel(),uploadimgpaths);
- }
- }
- break;
- }
- }
- @Override
- protected AttctPresenter createPresenter() {
- return new AttctPresenter();
- }
- @Override
- public void attctError(String msg) {
- toast(msg);
- }
- @Override
- public void attctSuccess(VerificationCodeBean data) {
- toast("注册成功");
- }
- private List<String> uploadimgpaths = new ArrayList<>();
- @Override
- protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_LICENSE_CHOOSE_FROM_GALLERY) {
- //营业执照回调
- String picturePath = BGAPhotoPickerActivity.getSelectedPhotos(data).get(0);
- if (uploadimgpaths.size() == 0){ //这里主要是为了让第一张图片必须是营业执照 第二张是授权证明
- uploadimgpaths.add(picturePath);
- }else if (uploadimgpaths.size() > 0){
- uploadimgpaths.remove(0);
- uploadimgpaths.add(0,picturePath);
- }
- BGAImage.display(attcEtLicense,R.mipmap.iv_upload_icon,picturePath, AutoSizeUtils.dp2px(this,77),AutoSizeUtils.dp2px(this,43));
- Log.e("uploadimgpaths1",""+uploadimgpaths.toString());
- }else if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_PROVE_CHOOSE_FROM_GALLERY){
- //授权证明回调
- String picturePath = BGAPhotoPickerActivity.getSelectedPhotos(data).get(0);
- if (uploadimgpaths.size() == 2) {
- uploadimgpaths.remove(1);
- uploadimgpaths.add(picturePath);
- }else {
- uploadimgpaths.add(picturePath);
- }
- BGAImage.display(attcEtProve,R.mipmap.iv_upload_icon,picturePath,AutoSizeUtils.dp2px(this,77),AutoSizeUtils.dp2px(this,43));
- Log.e("uploadimgpaths2",""+uploadimgpaths.toString());
- }
- }
- }
|