Search in sources :

Example 1 with ProxyAdapter

use of com.dante.adapter.ProxyAdapter in project 91Pop by DanteAndroid.

the class ProxySettingActivity method init.

private void init() {
    testAlertDialog = DialogUtils.initLodingDialog(this, "测试中,请稍候...");
    String proxyHost = dataManager.getProxyIpAddress();
    int port = dataManager.getProxyPort();
    etDialogProxySettingIpAddress.setIpAddressStr(proxyHost);
    etDialogProxySettingPort.setText(port == 0 ? "" : String.valueOf(port));
    List<ProxyModel> data = new ArrayList<>();
    proxyAdapter = new ProxyAdapter(R.layout.item_proxy, data);
    recyclerViewProxySetting.setLayoutManager(new LinearLayoutManager(this));
    recyclerViewProxySetting.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    View view = getLayoutInflater().inflate(R.layout.item_proxy, recyclerViewProxySetting, false);
    proxyAdapter.setHeaderView(view);
    proxyAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {

        @Override
        public void onLoadMoreRequested() {
            presenter.parseXiCiDaiLi(false);
        }
    }, recyclerViewProxySetting);
    proxyAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
            ProxyModel proxyModel = (ProxyModel) adapter.getItem(position);
            if (proxyModel == null) {
                showMessage("数据出错了", TastyToast.WARNING);
                return;
            }
            proxyAdapter.setClickPosition(position);
            if (proxyModel.getType() != ProxyModel.TYPE_SOCKS) {
                etDialogProxySettingIpAddress.setIpAddressStr(proxyModel.getProxyIp());
                etDialogProxySettingPort.setText(proxyModel.getProxyPort());
            } else {
                showMessage("暂不支持socket代理", TastyToast.INFO);
            }
        }
    });
    recyclerViewProxySetting.setAdapter(proxyAdapter);
    helper = new LoadViewHelper(recyclerViewProxySetting);
    helper.setListener(new OnLoadViewListener() {

        @Override
        public void onRetryClick() {
            presenter.parseXiCiDaiLi(false);
        }
    });
    presenter.parseXiCiDaiLi(false);
}
Also used : ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) BaseQuickAdapter(com.chad.library.adapter.base.BaseQuickAdapter) OnLoadViewListener(com.helper.loadviewhelper.help.OnLoadViewListener) ProxyAdapter(com.dante.adapter.ProxyAdapter) LoadViewHelper(com.helper.loadviewhelper.load.LoadViewHelper) ProxyModel(com.dante.data.model.ProxyModel)

Aggregations

DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 BindView (butterknife.BindView)1 BaseQuickAdapter (com.chad.library.adapter.base.BaseQuickAdapter)1 ProxyAdapter (com.dante.adapter.ProxyAdapter)1 ProxyModel (com.dante.data.model.ProxyModel)1 OnLoadViewListener (com.helper.loadviewhelper.help.OnLoadViewListener)1 LoadViewHelper (com.helper.loadviewhelper.load.LoadViewHelper)1 ArrayList (java.util.ArrayList)1