@Override
protected void convert(BaseViewHolder helper, final Problem item) {
helper.setText(R.id.title_tv, item.getFaultName());
Switch titleSwitch = helper.getView(R.id.title_switch);
final AppCompatEditText hiddenEt = helper.getView(R.id.hidden_danger_et);
if (hiddenEt.getTag()instanceof TextWatcher) {
hiddenEt.removeTextChangedListener((TextWatcher) hiddenEt.getTag());
}
if (item.getChecked()) {
hiddenEt.setVisibility(View.VISIBLE);
hiddenEt.setText(item.getRemarks());
}else {
hiddenEt.setVisibility(View.GONE);
}
TextWatcher watcher =new 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) {
}
@Override
public void afterTextChanged(Editable s) {
item.setRemarks(s.toString());
}
};
hiddenEt.addTextChangedListener(watcher);
hiddenEt.setTag(watcher);