private void updateDisplay(View view, ViewHolder holder, CheckListItem mListItem) { int drawableId; double minVal = mListItem.getMin_val(); double nomVal = mListItem.getNom_val(); double sysValue = mListItem.getSys_value(); String unit = mListItem.getUnit(); boolean failMandatory = false; getDroneVariable(drone, mListItem); failMandatory = sysValue <= minVal; if (sysValue <= minVal) drawableId = R.drawable.pstate_poor; else if (sysValue > minVal && sysValue <= nomVal) drawableId = R.drawable.pstate_warning; else drawableId = R.drawable.pstate_good; holder.progressBar.setMax((int) mListItem.getMax_val()); holder.progressBar.setProgressDrawable(view.getResources().getDrawable(drawableId)); holder.progressBar.setProgress((int) sysValue); try { holder.unitView.setText(String.format(unit, sysValue)); } catch (Exception e) { holder.unitView.setText("Error"); e.printStackTrace(); } updateCheckBox(checkListItem.isMandatory() && !failMandatory); /* if(holder.checkBox.isChecked()) holder.layoutView.setBackgroundColor(getViewType()); else holder.layoutView.setBackgroundColor(Color.parseColor("#4f0f00")); */ }
@Override protected void setupViewItems(ViewGroup viewGroup, CheckListItem checkListItem) { this.layoutView = (LinearLayout) viewGroup.findViewById(R.id.lst_layout); this.checkBox = (CheckBox) viewGroup.findViewById(R.id.lst_check); this.progressBar = (ProgressBar) viewGroup.findViewById(R.id.lst_level); this.unitView = (TextView) viewGroup.findViewById(R.id.lst_unit); this.progressBar.setMax((int) checkListItem.getMax_val()); }
private void updateDisplay(View view, ViewHolder holder, CheckListItem mListItem) { boolean failMandatory = false; getData(mListItem); failMandatory = !checkListItem.isSys_activated(); holder.switchView.setOnCheckedChangeListener(this); holder.switchView.setClickable(checkListItem.isEditable()); holder.switchView.setChecked(mListItem.isSys_activated()); updateCheckBox(checkListItem.isMandatory() && !failMandatory); }