导航菜单

页面标题

页面副标题

大众借. v4.1.2 - MTH0ACT.java 源代码

正在查看: 大众借. v4.1.2 应用的 MTH0ACT.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.shiliuj.ui.activitys;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.core.view.PointerIconCompat;
import butterknife.BindView;
import butterknife.OnClick;
import com.base.commonlibrary.base.BaseResult;
import com.base.commonlibrary.base.baserx.RxSchedulers;
import com.base.commonlibrary.utils.KeyBordUtil;
import com.base.commonlibrary.utils.RegexUtil;
import com.base.commonlibrary.views.TitleLayout;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.google.gson.Gson;
import com.shiliuj.mjyp.app.api.Api;
import com.shiliuj.mjyp.app.base.BaseBindActivity;
import com.shiliuj.mjyp.app.base.RxSubscriber;
import com.shiliuj.ui.activitys.MTH0ACT;
import com.shiliuj.ui.bean.BaseInfoForm;
import com.shiliuj.ui.bean.JsonBean;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;

public class MTH0ACT extends BaseBindActivity {
    private static final int MSG_LOAD_DATA = 1;
    private static final int MSG_LOAD_FAILED = 3;
    private static final int MSG_LOAD_SUCCESS = 2;
    private static boolean isLoaded;
    private String address;
    private BaseInfoForm baseInfoForm;

    @BindView(2131296390)
    TextView btnOk;

    @BindView(2131296419)
    TextView chooseAddress;

    @BindView(2131296420)
    TextView chooseWorkAddress;
    private String cityId;
    private String companyAddress;
    private String companyCityId;
    private String companyDistrictId;
    private String companyName;
    private String companyProvinceId;
    private String companyTel;
    private String districtId;

    @BindView(2131296328)
    EditText etAddress;

    @BindView(2131296631)
    RelativeLayout llAddress;

    @BindView(2131296654)
    LinearLayout llPhone;

    @BindView(2131296663)
    LinearLayout llWord;

    @BindView(2131296664)
    RelativeLayout llWorkAddress;

    @BindView(2131296776)
    EditText phone;
    private String provinceId;
    private Thread thread;

    @BindView(2131296971)
    TextView tipAddress;

    @BindView(2131296990)
    TextView tipPhone;

    @BindView(2131296996)
    TextView tipWork;

    @BindView(2131296997)
    TextView tipWorkAddress;

    @BindView(2131296998)
    TitleLayout title;

    @BindView(2131297067)
    EditText work;

    @BindView(2131297068)
    EditText workAddress;
    private List<JsonBean> options1Items = new ArrayList();
    private ArrayList<ArrayList<String>> options2Items = new ArrayList<>();
    private ArrayList<ArrayList<ArrayList<String>>> options3Items = new ArrayList<>();
    private Handler mHandler = new AnonymousClass1();

    protected boolean canLoadMore() {
        return false;
    }

    public int getLayoutId() {
        return 2131492903;
    }

    public void initPresenter() {
    }

    protected void loadMore() {
    }

    protected void refresh() {
    }

    class AnonymousClass1 extends Handler {
        AnonymousClass1() {
        }

        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            if (i != 1) {
                if (i != 2) {
                    return;
                }
                boolean unused = MTH0ACT.isLoaded = true;
            } else if (MTH0ACT.this.thread == null) {
                MTH0ACT.this.thread = new Thread(new Runnable() {
                    @Override
                    public final void run() {
                        MTH0ACT.AnonymousClass1.this.lambda$handleMessage$0$MTH0ACT$1();
                    }
                });
                MTH0ACT.this.thread.start();
            }
        }

        public void lambda$handleMessage$0$MTH0ACT$1() {
            MTH0ACT.this.initJsonData();
        }
    }

    public void initView(Bundle bundle) {
        this.mHandler.sendEmptyMessage(1);
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            BaseInfoForm baseInfoForm = (BaseInfoForm) extras.getSerializable("baseInfo");
            this.baseInfoForm = baseInfoForm;
            setBaseInfo(baseInfoForm);
        }
    }

    private void setBaseInfo(BaseInfoForm baseInfoForm) {
        this.address = baseInfoForm.getAddress();
        this.companyAddress = baseInfoForm.getCompanyAddress();
        this.companyName = baseInfoForm.getCompanyName();
        this.companyTel = baseInfoForm.getCompanyTel();
        this.companyProvinceId = baseInfoForm.getCompanyProvinceId();
        this.companyCityId = baseInfoForm.getCompanyCityId();
        this.companyDistrictId = baseInfoForm.getCompanyDistrictId();
        this.provinceId = baseInfoForm.getProvinceId();
        this.cityId = baseInfoForm.getCityId();
        this.districtId = baseInfoForm.getDistrictId();
        this.etAddress.setText(this.address);
        this.workAddress.setText(this.companyAddress);
        this.chooseAddress.setText(this.provinceId + "-" + this.cityId + "-" + this.districtId);
        this.chooseWorkAddress.setText(this.companyProvinceId + "-" + this.companyCityId + "-" + this.companyDistrictId);
        this.work.setText(this.companyName);
        this.phone.setText(this.companyTel);
    }

    @OnClick({2131296390, 2131296419, 2131296420})
    protected void onClick(View view) {
        switch (view.getId()) {
            case 2131296390:
                this.address = this.etAddress.getText().toString();
                this.companyAddress = this.workAddress.getText().toString();
                this.companyName = this.work.getText().toString();
                this.companyTel = this.phone.getText().toString();
                if (RegexUtil.isEmpty(this.address)) {
                    showShortToast(2131689939);
                    break;
                } else if (RegexUtil.isEmpty(this.companyAddress)) {
                    showShortToast(2131689940);
                    break;
                } else if (RegexUtil.isEmpty(this.companyName)) {
                    showShortToast(2131689941);
                    break;
                } else if (RegexUtil.isEmpty(this.companyTel)) {
                    showShortToast(2131689942);
                    break;
                } else if (RegexUtil.isEmpty(this.companyProvinceId)) {
                    showShortToast(2131689936);
                    break;
                } else if (RegexUtil.isEmpty(this.provinceId)) {
                    showShortToast(2131689934);
                    break;
                } else if (!RegexUtil.isEmpty(this.address) && !RegexUtil.isEmpty(this.companyAddress) && !RegexUtil.isEmpty(this.companyName) && !RegexUtil.isEmpty(this.companyTel) && !RegexUtil.isEmpty(this.provinceId) && !RegexUtil.isEmpty(this.companyProvinceId)) {
                    this.baseInfoForm = new BaseInfoForm(this.provinceId, this.cityId, this.districtId, this.address, this.companyName, this.companyTel, this.companyProvinceId, this.companyCityId, this.companyDistrictId, this.companyAddress);
                    loadData(true);
                    break;
                } else {
                    showShortToast(2131689937);
                    break;
                }
                break;
            case 2131296419:
                KeyBordUtil.hideKeyboard(this.mContext);
                if (isLoaded) {
                    showPickerView(false);
                    break;
                } else {
                    showShortToast(2131689943);
                    break;
                }
            case 2131296420:
                KeyBordUtil.hideKeyboard(this.mContext);
                if (isLoaded) {
                    showPickerView(true);
                    break;
                } else {
                    showShortToast(2131689943);
                    break;
                }
        }
    }

    private void showPickerView(final boolean z) {
        OptionsPickerView build = new OptionsPickerBuilder(this, new OnOptionsSelectListener() {
            public void onOptionsSelect(int i, int i2, int i3, View view) {
                String str = "";
                String pickerViewText = MTH0ACT.this.options1Items.size() > 0 ? ((JsonBean) MTH0ACT.this.options1Items.get(i)).getPickerViewText() : "";
                String str2 = (MTH0ACT.this.options2Items.size() <= 0 || ((ArrayList) MTH0ACT.this.options2Items.get(i)).size() <= 0) ? "" : (String) ((ArrayList) MTH0ACT.this.options2Items.get(i)).get(i2);
                if (MTH0ACT.this.options2Items.size() > 0 && ((ArrayList) MTH0ACT.this.options3Items.get(i)).size() > 0 && ((ArrayList) ((ArrayList) MTH0ACT.this.options3Items.get(i)).get(i2)).size() > 0) {
                    str = (String) ((ArrayList) ((ArrayList) MTH0ACT.this.options3Items.get(i)).get(i2)).get(i3);
                }
                String str3 = pickerViewText + "-" + str2 + "-" + str;
                if (z) {
                    MTH0ACT.this.companyProvinceId = pickerViewText;
                    MTH0ACT.this.companyCityId = str2;
                    MTH0ACT.this.companyDistrictId = str;
                    MTH0ACT.this.chooseWorkAddress.setText(str3);
                    return;
                }
                MTH0ACT.this.provinceId = pickerViewText;
                MTH0ACT.this.cityId = str2;
                MTH0ACT.this.districtId = str;
                MTH0ACT.this.chooseAddress.setText(str3);
            }
        }).setTitleSize(15).setTitleBgColor(ContextCompat.getColor(this.mContext, 2131099932)).setSubmitColor(ContextCompat.getColor(this.mContext, 2131099701)).setCancelColor(ContextCompat.getColor(this.mContext, 2131099923)).setTitleText(getString(2131689590)).setDividerColor(ContextCompat.getColor(this.mContext, 2131099797)).setTextColorCenter(ContextCompat.getColor(this.mContext, 2131099701)).setContentTextSize(20).build();
        build.setPicker(this.options1Items, this.options2Items, this.options3Items);
        build.show();
    }

    public String getJson(Context context, String str) {
        StringBuilder sb = new StringBuilder();
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(context.getAssets().open(str)));
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine == null) {
                    break;
                }
                sb.append(readLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sb.toString();
    }

    public void initJsonData() {
        ArrayList<JsonBean> parseData = parseData(getJson(this, "jdxf001.json"));
        this.options1Items = parseData;
        for (int i = 0; i < parseData.size(); i++) {
            ArrayList<String> arrayList = new ArrayList<>();
            ArrayList<ArrayList<String>> arrayList2 = new ArrayList<>();
            for (int i2 = 0; i2 < parseData.get(i).getCityList().size(); i2++) {
                arrayList.add(((JsonBean.CityBean) parseData.get(i).getCityList().get(i2)).getName());
                ArrayList<String> arrayList3 = new ArrayList<>();
                if (((JsonBean.CityBean) parseData.get(i).getCityList().get(i2)).getArea() == null || ((JsonBean.CityBean) parseData.get(i).getCityList().get(i2)).getArea().size() == 0) {
                    arrayList3.add("");
                } else {
                    arrayList3.addAll(((JsonBean.CityBean) parseData.get(i).getCityList().get(i2)).getArea());
                }
                arrayList2.add(arrayList3);
            }
            this.options2Items.add(arrayList);
            this.options3Items.add(arrayList2);
        }
        this.mHandler.sendEmptyMessage(2);
    }

    public ArrayList<JsonBean> parseData(String str) {
        ArrayList<JsonBean> arrayList = new ArrayList<>();
        try {
            JSONArray jSONArray = new JSONArray(str);
            Gson gson = new Gson();
            for (int i = 0; i < jSONArray.length(); i++) {
                arrayList.add((JsonBean) gson.fromJson(jSONArray.optJSONObject(i).toString(), JsonBean.class));
            }
        } catch (Exception e) {
            e.printStackTrace();
            this.mHandler.sendEmptyMessage(3);
        }
        return arrayList;
    }

    protected void onDestroy() {
        super.onDestroy();
        Handler handler = this.mHandler;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
        }
    }

    private void loadData(boolean z) {
        this.mRxManager.add(Api.getDefault().updateBaseInfo(this.baseInfoForm).compose(RxSchedulers.io_main()).subscribe(new RxSubscriber<BaseResult>(this.mContext, z) {
            public void _onNext(BaseResult baseResult) {
                Intent intent = new Intent();
                intent.putExtra("baseInfo", (Serializable) MTH0ACT.this.baseInfoForm);
                MTH0ACT.this.setResult(PointerIconCompat.TYPE_CONTEXT_MENU, intent);
                MTH0ACT.this.finish();
            }

            protected void _onError(String str) {
                MTH0ACT.this.showShortToast(str);
            }
        }));
    }
}