use of org.netxms.ui.android.main.views.CheckableLinearLayout in project netxms by netxms.
the class AlarmListAdapter method getView.
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
@SuppressLint("RtlHardcoded")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView message, source, date;
LinearLayout view, texts, info, icons;
ImageView severity, state;
if (// new alarm, create fields
convertView == null) {
severity = new ImageView(context);
severity.setPadding(5, 5, 5, 2);
state = new ImageView(context);
state.setPadding(5, 5, 5, 2);
icons = new LinearLayout(context);
icons.setOrientation(LinearLayout.VERTICAL);
icons.addView(severity);
icons.addView(state);
source = new TextView(context);
source.setPadding(5, 2, 5, 2);
source.setTextColor(r.getColor(R.color.text_color));
date = new TextView(context);
date.setPadding(5, 2, 5, 2);
date.setTextColor(r.getColor(R.color.text_color));
date.setGravity(Gravity.RIGHT);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.RIGHT;
date.setLayoutParams(lp);
message = new TextView(context);
message.setPadding(5, 2, 5, 2);
message.setTextColor(r.getColor(R.color.text_color));
info = new LinearLayout(context);
info.setOrientation(LinearLayout.HORIZONTAL);
info.addView(source);
info.addView(date);
texts = new LinearLayout(context);
texts.setOrientation(LinearLayout.VERTICAL);
lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
texts.setLayoutParams(lp);
texts.addView(info);
texts.addView(message);
view = new CheckableLinearLayout(context);
view.addView(icons);
view.addView(texts);
} else {
// get reference to existing alarm
view = (CheckableLinearLayout) convertView;
icons = (LinearLayout) view.getChildAt(1);
severity = (ImageView) icons.getChildAt(0);
state = (ImageView) icons.getChildAt(1);
texts = (LinearLayout) view.getChildAt(2);
info = (LinearLayout) texts.getChildAt(0);
source = (TextView) info.getChildAt(0);
date = (TextView) info.getChildAt(1);
message = (TextView) texts.getChildAt(1);
}
// get node name
Alarm alarm = alarms.get(position);
source.setText(getObjectName(alarm.getSourceObjectId()));
date.setText(DateFormat.getDateTimeInstance().format(alarm.getLastChangeTime()));
message.setText(alarm.getMessage());
severity.setImageResource(getAlarmIconSeverity(alarm));
state.setImageResource(getAlarmIconState(alarm));
return view;
}
use of org.netxms.ui.android.main.views.CheckableLinearLayout in project netxms by netxms.
the class LastValuesAdapter method getView.
/*
* (non-Javadoc)
*
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
@SuppressLint("RtlHardcoded")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView threshold, date, name, value;
CheckableLinearLayout view;
LinearLayout texts, info, info2, icons;
ImageView severity, state;
Resources r = context.getResources();
if (// new view, create fields
convertView == null) {
severity = new ImageView(context);
severity.setPadding(5, 5, 5, 2);
state = new ImageView(context);
state.setPadding(5, 5, 5, 2);
icons = new LinearLayout(context);
icons.setOrientation(LinearLayout.VERTICAL);
icons.addView(severity);
icons.addView(state);
threshold = new TextView(context);
threshold.setPadding(5, 2, 5, 2);
threshold.setTextColor(r.getColor(R.color.text_color));
date = new TextView(context);
date.setPadding(5, 2, 5, 2);
date.setTextColor(r.getColor(R.color.text_color));
date.setGravity(Gravity.RIGHT);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.RIGHT;
date.setLayoutParams(lp);
info = new LinearLayout(context);
info.setOrientation(LinearLayout.HORIZONTAL);
info.addView(threshold);
info.addView(date);
name = new TextView(context);
name.setPadding(5, 2, 5, 2);
name.setTextColor(r.getColor(R.color.text_color));
name.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1));
value = new TextView(context);
value.setPadding(5, 2, 5, 2);
value.setTextColor(r.getColor(R.color.text_color));
value.setGravity(Gravity.RIGHT);
lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 2);
lp.gravity = Gravity.RIGHT;
value.setLayoutParams(lp);
info2 = new LinearLayout(context);
info2.setOrientation(LinearLayout.HORIZONTAL);
info2.addView(name);
info2.addView(value);
texts = new LinearLayout(context);
texts.setOrientation(LinearLayout.VERTICAL);
texts.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
texts.addView(info);
texts.addView(info2);
view = new CheckableLinearLayout(context);
view.addView(icons);
view.addView(texts);
} else {
// get reference to existing alarm
view = (CheckableLinearLayout) convertView;
icons = (LinearLayout) view.getChildAt(1);
severity = (ImageView) icons.getChildAt(0);
state = (ImageView) icons.getChildAt(1);
texts = (LinearLayout) view.getChildAt(2);
info = (LinearLayout) texts.getChildAt(0);
threshold = (TextView) info.getChildAt(0);
date = (TextView) info.getChildAt(1);
info2 = (LinearLayout) texts.getChildAt(1);
name = (TextView) info2.getChildAt(0);
value = (TextView) info2.getChildAt(1);
}
// get node current name/value pair
DciValue item = currentValues.get(position);
if (item == null) {
name.setText(r.getString(R.string.node_unknown));
value.setText(r.getString(R.string.last_values_na));
} else {
Threshold t = item.getActiveThreshold();
severity.setImageResource(getThresholdIcon(t));
threshold.setText(getThresholdText(t));
state.setImageResource(LastValuesAdapter.stateImageId[item.getStatus()]);
date.setText(DateFormat.getDateTimeInstance().format(item.getTimestamp()));
name.setText(item.getDescription());
value.setText((item.getDcObjectType() == DataCollectionObject.DCO_TYPE_TABLE) ? r.getString(R.string.table_value_placeholder) : getFormattedValue(item));
}
return view;
}
Aggregations