导航菜单

页面标题

页面副标题

爱心e站 v1.0.0 - AreaSelectActivity.java 源代码

正在查看: 爱心e站 v1.0.0 应用的 AreaSelectActivity.java JAVA 源代码文件

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


package com.newheyd.JZKFcanjiren.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.newheyd.JZKFcanjiren.Adapter.AddressAdapter;
import com.newheyd.JZKFcanjiren.BaseActivity;
import com.newheyd.JZKFcanjiren.Bean.AreaNode;
import com.newheyd.JZKFcanjiren.R;
import com.newheyd.JZKFcanjiren.Utils.StastisticUtil;
import com.newheyd.JZKFcanjiren.Utils.ToastUtils;
import com.newheyd.JZKFcanjiren.Utils.locationUtil.LocationAddrUtil;
import com.newheyd.JZKFcanjiren.View.TitleView;
import com.newheyd.JZKFcanjiren.config.NewHYConfig;
import com.newheyd.JZKFcanjiren.model.BaseResult;
import com.newheyd.JZKFcanjiren.model.DataParser;
import com.newheyd.JZKFcanjiren.net.CommonDataListTask;
import com.newheyd.JZKFcanjiren.net.NewHYTask;
import com.newheyd.JZKFcanjiren.net.RequestServiceList;
import com.tencent.connect.common.Constants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

public class AreaSelectActivity extends BaseActivity implements AddressAdapter.OnAddreddCallBack {
    private TitleView mTitleView;
    private AddressAdapter addressCityAdapter = null;
    private ArrayList<AreaNode> mCityData = new ArrayList<>();
    private ListView mCityList = null;
    private AddressAdapter addressAreaAdapter = null;
    private ArrayList<AreaNode> mAreaData = new ArrayList<>();
    private ListView mAreaList = null;
    private AddressAdapter addressStreetAdapter = null;
    private ArrayList<AreaNode> mStreetData = new ArrayList<>();
    private ListView mStreetList = null;
    private String areaCode = "370000000000";
    private String areaName = "山东省";
    private String keytype = "1";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_area_select);
        super.onCreate(savedInstanceState);
        getAreaList();
        goStatistics();
    }

    public void goStatistics() {
        HashMap<String, String> map = LocationAddrUtil.getInstance().getLocationParam(this.mContext);
        StastisticUtil.getInstance().onEvent(this.mContext, "AreaSelectActivity", map);
    }

    public void getAreaList() {
        HashMap<String, String> params = new HashMap<>();
        params.put("type", "1");
        params.put("id", this.areaCode);
        params.put(Constants.PARAM_KEY_TYPE, this.keytype);
        NewHYTask task = new CommonDataListTask(RequestServiceList.TREECODEASYNCDATA, params, AreaNode.class);
        executeRequest(task);
    }

    public void freshData() {
        if ("1".equals(this.keytype)) {
            this.addressCityAdapter = new AddressAdapter(this.mContext, this.mCityData, R.layout.item_address);
            this.addressCityAdapter.setKeytype("2");
            this.addressCityAdapter.setCallBack(this);
            this.mCityList.setAdapter((ListAdapter) this.addressCityAdapter);
            return;
        }
        if ("2".equals(this.keytype)) {
            this.addressAreaAdapter = new AddressAdapter(this.mContext, this.mAreaData, R.layout.item_address);
            this.addressAreaAdapter.setKeytype("3");
            this.addressAreaAdapter.setCallBack(this);
            this.mAreaList.setAdapter((ListAdapter) this.addressAreaAdapter);
            return;
        }
        this.addressStreetAdapter = new AddressAdapter(this.mContext, this.mStreetData, R.layout.item_address);
        this.addressStreetAdapter.setKeytype("4");
        this.addressStreetAdapter.setCallBack(this);
        this.mStreetList.setAdapter((ListAdapter) this.addressStreetAdapter);
    }

    @Override
    public void onResponseBefore(NewHYTask task) {
        switch (task.getService()) {
            case TREECODEASYNCDATA:
                showProgress(NewHYConfig.LOADING_HINT, false);
                break;
        }
    }

    @Override
    public void onResponseAfter(NewHYTask task) {
        switch (task.getService()) {
            case TREECODEASYNCDATA:
                cancleProgress();
                break;
        }
    }

    @Override
    public void onResponseSuccessful(NewHYTask task, BaseResult object) {
        switch (task.getService()) {
            case TREECODEASYNCDATA:
                DataParser<AreaNode> mResult = (DataParser) object;
                if ("1".equals(task.getParamsMap().get(Constants.PARAM_KEY_TYPE))) {
                    this.mCityData.clear();
                    this.mCityData.addAll(mResult.getObjects());
                } else if ("2".equals(task.getParamsMap().get(Constants.PARAM_KEY_TYPE))) {
                    this.mAreaData.clear();
                    this.mAreaData.addAll(mResult.getObjects());
                } else {
                    this.mStreetData.clear();
                    this.mStreetData.addAll(mResult.getObjects());
                }
                freshData();
                break;
        }
    }

    @Override
    public void onResponseError(NewHYTask task, BaseResult object) {
        switch (task.getService()) {
            case TREECODEASYNCDATA:
                ToastUtils.showShortToast(this.mContext, object.getMsg());
                break;
        }
    }

    @Override
    public void onServerError(NewHYTask task, int failedType) {
        switch (task.getService()) {
            case TREECODEASYNCDATA:
                onResultShow(failedType);
                break;
        }
    }

    @Override
    public void initViews() {
        this.mTitleView = (TitleView) findViewById(R.id.titleview);
        this.mCityList = (ListView) findViewById(R.id.city);
        this.mAreaList = (ListView) findViewById(R.id.area);
        this.mStreetList = (ListView) findViewById(R.id.street);
    }

    @Override
    public void setListener() {
        this.mTitleView.setOnTitleClik(new TitleView.BackListenner() {
            @Override
            public void BackSet() {
                AreaSelectActivity.this.finish();
            }
        }, new TitleView.RightListenner() {
            @Override
            public void RightSet() {
                Intent intent = new Intent();
                intent.putExtra("areaCode", AreaSelectActivity.this.areaCode);
                intent.putExtra("areaName", AreaSelectActivity.this.areaName);
                AreaSelectActivity.this.setResult(-1, intent);
                AreaSelectActivity.this.finish();
            }
        });
    }

    public void updateCheckState() {
        ArrayList<AreaNode> mTempList;
        BaseAdapter baseAdapter;
        String type = String.valueOf(Integer.parseInt(this.keytype) - 1);
        if ("1".equals(type)) {
            mTempList = this.mCityData;
            baseAdapter = this.addressCityAdapter;
        } else if ("2".equals(type)) {
            mTempList = this.mAreaData;
            baseAdapter = this.addressAreaAdapter;
        } else {
            mTempList = this.mStreetData;
            baseAdapter = this.addressStreetAdapter;
        }
        if (mTempList != null) {
            Iterator<AreaNode> it = mTempList.iterator();
            while (it.hasNext()) {
                AreaNode node = it.next();
                if (this.areaCode.equals(node.getId())) {
                    node.setCheck(true);
                } else {
                    node.setCheck(false);
                }
            }
        }
        if (baseAdapter != null) {
            baseAdapter.notifyDataSetChanged();
        }
    }

    @Override
    public void onAddress(AreaNode node, String keytype) {
        this.keytype = keytype;
        this.areaCode = node.getId();
        this.areaName = node.getName();
        node.setCheck(true);
        updateCheckState();
        if (!"4".equals(keytype)) {
            getAreaList();
        }
    }
}