You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
6.5 KiB
Java
191 lines
6.5 KiB
Java
|
3 years ago
|
package com.rehome.zhdcoa.adapter;
|
||
|
|
|
||
|
|
import android.content.Context;
|
||
|
|
import android.text.Editable;
|
||
|
|
import android.text.TextUtils;
|
||
|
|
import android.text.TextWatcher;
|
||
|
|
import android.view.View;
|
||
|
|
import android.widget.EditText;
|
||
|
|
|
||
|
|
import com.rehome.zhdcoa.R;
|
||
|
|
import com.rehome.zhdcoa.bean.OfficeAddBean;
|
||
|
|
import com.rehome.zhdcoa.weiget.AuditDialog;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Created by Rehome-rjb1 on 2017/7/10.
|
||
|
|
* 办公设施新增adapter
|
||
|
|
*/
|
||
|
|
|
||
|
|
public class OfficAddAdapter extends CommonAdapter<OfficeAddBean.DataRowsBean> {
|
||
|
|
|
||
|
|
private final List<OfficeAddBean.DataRowsBean> datas;
|
||
|
|
private final boolean isAudit;
|
||
|
|
|
||
|
|
private final Context context;
|
||
|
|
|
||
|
|
public OfficAddAdapter(Context context, List<OfficeAddBean.DataRowsBean> datas, boolean isAudit) {
|
||
|
|
super(context, R.layout.item_office_add, datas);
|
||
|
|
this.datas = datas;
|
||
|
|
this.isAudit = isAudit;
|
||
|
|
this.context = context;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
protected void convert(ViewHolder viewHolder, final OfficeAddBean.DataRowsBean item, final int position) {
|
||
|
|
|
||
|
|
if (!TextUtils.isEmpty(item.getRelatedid())) {
|
||
|
|
item.setSavetype("2");
|
||
|
|
}
|
||
|
|
|
||
|
|
EditText etApplyFacilitiesMC = viewHolder.getView(R.id.et_ApplyFacilitiesMC);
|
||
|
|
EditText etApplyFacilitiesNUM = viewHolder.getView(R.id.et_ApplyFacilitiesNUM);
|
||
|
|
EditText etApplyFacilitiesDW = viewHolder.getView(R.id.et_ApplyFacilitiesDW);
|
||
|
|
EditText etApplyFacilitiesGJ = viewHolder.getView(R.id.et_ApplyFacilitiesGJ);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
viewHolder.setOnClickListener(R.id.ib_del, new View.OnClickListener() {
|
||
|
|
@Override
|
||
|
|
public void onClick(View v) {
|
||
|
|
AuditDialog dialog = new AuditDialog(context, "你确定删除吗?", new AuditDialog.AuditDialogListener() {
|
||
|
|
@Override
|
||
|
|
public void confirm() {
|
||
|
|
datas.remove(position);
|
||
|
|
notifyDataSetChanged();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void cancel() {
|
||
|
|
}
|
||
|
|
});
|
||
|
|
dialog.show();
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
if (isAudit) {
|
||
|
|
etApplyFacilitiesMC.setEnabled(false);
|
||
|
|
etApplyFacilitiesNUM.setEnabled(false);
|
||
|
|
etApplyFacilitiesDW.setEnabled(false);
|
||
|
|
etApplyFacilitiesGJ.setEnabled(false);
|
||
|
|
viewHolder.setVisible(R.id.ib_del, false);
|
||
|
|
}
|
||
|
|
|
||
|
|
etApplyFacilitiesMC.clearFocus();
|
||
|
|
etApplyFacilitiesDW.clearFocus();
|
||
|
|
etApplyFacilitiesNUM.clearFocus();
|
||
|
|
etApplyFacilitiesGJ.clearFocus();
|
||
|
|
|
||
|
|
|
||
|
|
if (etApplyFacilitiesMC.getTag() instanceof TextWatcher) {
|
||
|
|
etApplyFacilitiesMC.removeTextChangedListener((TextWatcher) etApplyFacilitiesMC.getTag());
|
||
|
|
}
|
||
|
|
if (etApplyFacilitiesDW.getTag() instanceof TextWatcher) {
|
||
|
|
etApplyFacilitiesDW.removeTextChangedListener((TextWatcher) etApplyFacilitiesDW.getTag());
|
||
|
|
}
|
||
|
|
|
||
|
|
if (etApplyFacilitiesNUM.getTag() instanceof TextWatcher) {
|
||
|
|
etApplyFacilitiesNUM.removeTextChangedListener((TextWatcher) etApplyFacilitiesNUM.getTag());
|
||
|
|
}
|
||
|
|
|
||
|
|
if (etApplyFacilitiesGJ.getTag() instanceof TextWatcher) {
|
||
|
|
etApplyFacilitiesGJ.removeTextChangedListener((TextWatcher) etApplyFacilitiesGJ.getTag());
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if (!TextUtils.isEmpty(datas.get(position).getApplyFacilitiesMC())) {
|
||
|
|
etApplyFacilitiesMC.setText(datas.get(position).getApplyFacilitiesMC());
|
||
|
|
etApplyFacilitiesNUM.setText(datas.get(position).getApplyFacilitiesNUM());
|
||
|
|
etApplyFacilitiesDW.setText(datas.get(position).getApplyFacilitiesDW());
|
||
|
|
etApplyFacilitiesGJ.setText(datas.get(position).getApplyFacilitiesPrice());
|
||
|
|
|
||
|
|
|
||
|
|
etApplyFacilitiesMC.setSelection(item.getApplyFacilitiesMC().length());
|
||
|
|
etApplyFacilitiesDW.setSelection(item.getApplyFacilitiesDW().length());
|
||
|
|
etApplyFacilitiesNUM.setSelection(item.getApplyFacilitiesNUM().length());
|
||
|
|
etApplyFacilitiesGJ.setSelection(item.getApplyFacilitiesPrice().length());
|
||
|
|
|
||
|
|
|
||
|
|
} else {
|
||
|
|
etApplyFacilitiesMC.setText("");
|
||
|
|
etApplyFacilitiesNUM.setText("");
|
||
|
|
etApplyFacilitiesDW.setText("");
|
||
|
|
etApplyFacilitiesGJ.setText("");
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
final TextWatcher MCwatcher = new MyTextWatcher() {
|
||
|
|
@Override
|
||
|
|
public void beforeTextChange(String s) {
|
||
|
|
if (TextUtils.isEmpty(s)) {
|
||
|
|
item.setApplyFacilitiesMC(null);
|
||
|
|
} else {
|
||
|
|
item.setApplyFacilitiesMC(s);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
final TextWatcher NUMwatcher = new MyTextWatcher() {
|
||
|
|
@Override
|
||
|
|
public void beforeTextChange(String s) {
|
||
|
|
if (TextUtils.isEmpty(s)) {
|
||
|
|
item.setApplyFacilitiesNUM(null);
|
||
|
|
} else {
|
||
|
|
item.setApplyFacilitiesNUM(s);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
final TextWatcher DWwatcher = new MyTextWatcher() {
|
||
|
|
@Override
|
||
|
|
public void beforeTextChange(String s) {
|
||
|
|
if (TextUtils.isEmpty(s)) {
|
||
|
|
item.setApplyFacilitiesDW(null);
|
||
|
|
} else {
|
||
|
|
item.setApplyFacilitiesDW(s);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
final TextWatcher GJwatcher = new MyTextWatcher() {
|
||
|
|
@Override
|
||
|
|
public void beforeTextChange(String s) {
|
||
|
|
if (TextUtils.isEmpty(s)) {
|
||
|
|
item.setApplyFacilitiesPrice(null);
|
||
|
|
} else {
|
||
|
|
item.setApplyFacilitiesPrice(s);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
etApplyFacilitiesMC.addTextChangedListener(MCwatcher);
|
||
|
|
etApplyFacilitiesNUM.addTextChangedListener(NUMwatcher);
|
||
|
|
etApplyFacilitiesDW.addTextChangedListener(DWwatcher);
|
||
|
|
etApplyFacilitiesGJ.addTextChangedListener(GJwatcher);
|
||
|
|
|
||
|
|
|
||
|
|
etApplyFacilitiesMC.setTag(MCwatcher);
|
||
|
|
etApplyFacilitiesNUM.setTag(NUMwatcher);
|
||
|
|
etApplyFacilitiesDW.setTag(DWwatcher);
|
||
|
|
etApplyFacilitiesGJ.setTag(GJwatcher);
|
||
|
|
}
|
||
|
|
|
||
|
|
public abstract class MyTextWatcher implements TextWatcher {
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||
|
|
beforeTextChange(s.toString());
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void afterTextChanged(Editable s) {
|
||
|
|
}
|
||
|
|
|
||
|
|
public abstract void beforeTextChange(String s);
|
||
|
|
}
|
||
|
|
}
|