@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = inflater.inflate(R.layout.equipment_list_item, null); holder = new ViewHolder(); holder.name = (TextView) convertView.findViewById(R.id.equipment_name_text_view); holder.code = (TextView) convertView.findViewById(R.id.equipment_code_text_view); holder.type = (TextView) convertView.findViewById(R.id.equipment_type_text_view); holder.data = (TextView) convertView.findViewById(R.id.equipment_data_text_view); holder.state = (TextView) convertView.findViewById(R.id.equipment_state_text_view); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } final EquipmentData equipmentData = equipmentList.get(position); holder.name.setText(equipmentData.getName()); holder.code.setText(equipmentData.getCode()); holder.type.setText(equipmentData.getType()); holder.data.setText( equipmentData.getData() != null ? equipmentData.getData().toString() : "--"); final EquipmentState state = getEquipmentState(equipmentData); holder.state.setText(equipmentStateAsString(state)); return convertView; }
public View getView(int position, View view, ViewGroup parent) { ViewHolder holder; // LayoutInflater inflater = (LayoutInflater) context.getSystemService // (Activity.LAYOUT_INFLATER_SERVICE); if (view == null) { view = LayoutInflater.from(context).inflate(R.layout.pic_and_text_list, parent, false); holder = new ViewHolder(); holder.data = (TextView) view.findViewById(R.id.data); holder.date = (TextView) view.findViewById(R.id.date); holder.id = (TextView) view.findViewById(R.id.id); view.setTag(holder); } else holder = (ViewHolder) view.getTag(); // set textviews and imageview for (int i = 0; i < items.size(); i++) { JSONObject fullContentItem = getItem(position); try { String id = fullContentItem.getString("id"); holder.id.setText("ID: " + id); String data = fullContentItem.getString("data"); holder.data.setText("Data: " + data); String date = fullContentItem.getString("date"); holder.date.setText("Date: " + date); String type = fullContentItem.getString("type"); // if (type.equals("image")) { // Picasso.with(context) // .load(data) // .into(holder.icon); // } // else if (type.equals("text")){ //// homeActivity.addShowHideListener(holder, webViewFragment); // // // // } } catch (JSONException e) { e.printStackTrace(); } } return view; }
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = this.mInflater.inflate(R.layout.stats_item, null, true); holder = new ViewHolder(); holder.imageIcon = (ImageView) convertView.findViewById(R.id.imageIcon); holder.textName = (TextView) convertView.findViewById(R.id.textName); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.data = (StatsData) getItem(position); holder.imageIcon.setImageResource(R.drawable.ic_log); holder.imageIcon.setColorFilter( mContext.getResources().getColor(getDataColor(position)), Mode.SRC_IN); holder.textName.setText(holder.data.title + ": " + holder.data.value); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; int layoutResourceId; WeatherInfo mWeatherInfo = filteredData.get(position); // if (convertView == null) { holder = new ViewHolder(); layoutResourceId = R.layout.weather_row_default; LayoutInflater inflater = ((Activity) context).getLayoutInflater(); convertView = inflater.inflate(layoutResourceId, parent, false); holder.isProtected = mWeatherInfo.isProtected(); holder.name = (TextView) convertView.findViewById(R.id.weather_name); holder.iconRow = (ImageView) convertView.findViewById(R.id.rowIcon); holder.data = (TextView) convertView.findViewById(R.id.weather_data); holder.hardware = (TextView) convertView.findViewById(R.id.weather_hardware); holder.dayButton = (Button) convertView.findViewById(R.id.day_button); holder.monthButton = (Button) convertView.findViewById(R.id.month_button); holder.yearButton = (Button) convertView.findViewById(R.id.year_button); holder.name.setText(mWeatherInfo.getName()); holder.hardware.append(mWeatherInfo.getHardwareName()); holder.data.setEllipsize(TextUtils.TruncateAt.END); holder.data.setMaxLines(3); holder.data.append(mWeatherInfo.getData()); if (!UsefulBits.isEmpty(mWeatherInfo.getRain())) holder.data.setText(context.getString(R.string.rain) + ": " + mWeatherInfo.getRain()); if (!UsefulBits.isEmpty(mWeatherInfo.getRainRate())) holder.data.append( ", " + context.getString(R.string.rainrate) + ": " + mWeatherInfo.getRainRate()); if (!UsefulBits.isEmpty(mWeatherInfo.getForecastStr())) holder.data.append(", " + mWeatherInfo.getForecastStr()); if (!UsefulBits.isEmpty(mWeatherInfo.getSpeed())) holder.data.append(", " + context.getString(R.string.speed) + ": " + mWeatherInfo.getSpeed()); if (mWeatherInfo.getDewPoint() > 0) holder.data.append( ", " + context.getString(R.string.dewPoint) + ": " + mWeatherInfo.getDewPoint()); if (mWeatherInfo.getTemp() > 0) holder.data.append(", " + context.getString(R.string.temp) + ": " + mWeatherInfo.getTemp()); if (mWeatherInfo.getBarometer() > 0) holder.data.append( ", " + context.getString(R.string.pressure) + ": " + mWeatherInfo.getBarometer()); if (!UsefulBits.isEmpty(mWeatherInfo.getChill())) holder.data.append(", " + context.getString(R.string.chill) + ": " + mWeatherInfo.getChill()); if (!UsefulBits.isEmpty(mWeatherInfo.getDirectionStr())) holder.data.append( ", " + context.getString(R.string.direction) + ": " + mWeatherInfo.getDirectionStr()); if (!UsefulBits.isEmpty(mWeatherInfo.getHumidityStatus())) holder.data.append( ", " + context.getString(R.string.humidity) + ": " + mWeatherInfo.getHumidityStatus()); holder.dayButton.setId(mWeatherInfo.getIdx()); holder.dayButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { for (WeatherInfo t : filteredData) { if (t.getIdx() == v.getId()) listener.onLogClick(t, Domoticz.Graph.Range.DAY); } } }); holder.monthButton.setId(mWeatherInfo.getIdx()); holder.monthButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { for (WeatherInfo t : filteredData) { if (t.getIdx() == v.getId()) listener.onLogClick(t, Domoticz.Graph.Range.MONTH); } } }); holder.yearButton.setId(mWeatherInfo.getIdx()); holder.yearButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { for (WeatherInfo t : filteredData) { if (t.getIdx() == v.getId()) listener.onLogClick(t, Domoticz.Graph.Range.YEAR); } } }); convertView.setTag(holder); Picasso.with(context) .load( domoticz.getDrawableIcon( mWeatherInfo.getTypeImg(), mWeatherInfo.getType(), null, false, false, null)) .into(holder.iconRow); return convertView; }
@Override public View getView(int position, View convertView, ViewGroup parent) { if (null == convertView || null == convertView.getTag()) { holder = new ViewHolder(); convertView = LayoutInflater.from(context).inflate(R.layout.list_item_message, parent, false); holder.name = (TextView) convertView.findViewById(R.id.message_contacts_lv_item_name); holder.otherPeopleName = (TextView) convertView.findViewById(R.id.message_contacts_lv_item_other_name); holder.content = (TextView) convertView.findViewById(R.id.message_contacts_lv_item_content); holder.data = (TextView) convertView.findViewById(R.id.message_contacts_lv_item_data); holder.tag = (ImageView) convertView.findViewById(R.id.message_contacts_lv_item_tag); holder.city = (CountryImageView) convertView.findViewById(R.id.message_contacts_lv_item_city); holder.rlItemCity = (RelativeLayout) convertView.findViewById(R.id.message_contacts_rl_item_city); holder.attachment = (ImageView) convertView.findViewById(R.id.message_contacts_lv_item_attachment); holder.isRead = (ImageView) convertView.findViewById(R.id.message_contacts_lv_item_read); holder.rlTag = (RelativeLayout) convertView.findViewById(R.id.message_contacts_lv_item_rl_tag); holder.rlTagPadding = (View) convertView.findViewById(R.id.message_contacts_lv_item_left_padding); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } messageContent = (MessageContent) getItem(position); if ("0".equals(action)) { holder.isRead.setVisibility(View.GONE); fullName = messageContent.sender.fullName; otherNameTag = "收件人:"; if ("00".equals(messageContent.receiver.operatorId) || !SupplierApplication.getInstance().getUser().content.userInfo.isManager()) { otherName = "我"; otherNameColor = context.getResources().getColor(R.color.color_b3b3b3); } else { otherName = messageContent.receiver.fullName; otherNameColor = context.getResources().getColor(R.color.color_ccb895); } if (!Utils.isEmpty(messageContent.sender.countryImageUrl)) { holder.rlItemCity.setVisibility(View.VISIBLE); ImageUtil.getImageLoader() .displayImage( messageContent.sender.countryImageUrl, holder.city, ImageUtil.getCommonImageOptions()); } else { holder.rlItemCity.setVisibility(View.INVISIBLE); } if ("0".equals(messageContent.isRead)) // true:未读 { holder.name.setTextColor(context.getResources().getColor(R.color.color_333333)); holder.tag.setImageResource(R.drawable.bg_message_blue_dot); holder.tag.setVisibility(View.VISIBLE); } else { // 判断是否已经回复 if ("1".equals(messageContent.isReplied)) { holder.tag.setImageResource(R.drawable.ic_message_reply); holder.tag.setVisibility(View.VISIBLE); } else { holder.tag.setVisibility(View.INVISIBLE); } holder.name.setTextColor(context.getResources().getColor(R.color.color_666666)); } } else { holder.rlTag.setVisibility(View.GONE); holder.rlTagPadding.setVisibility(View.VISIBLE); if ("1".equals(messageContent.receiverReadFlag)) // true:未读 { holder.name.setTextColor(context.getResources().getColor(R.color.color_666666)); holder.isRead.setVisibility(View.VISIBLE); } else { holder.name.setTextColor(context.getResources().getColor(R.color.color_333333)); holder.isRead.setVisibility(View.GONE); } fullName = messageContent.receiver.fullName; otherNameTag = "发件人:"; if ("00".equals(messageContent.sender.operatorId) || !SupplierApplication.getInstance().getUser().content.userInfo.isManager()) { otherName = "我"; otherNameColor = context.getResources().getColor(R.color.color_b3b3b3); } else { otherName = messageContent.sender.fullName; otherNameColor = context.getResources().getColor(R.color.color_ccb895); } holder.rlItemCity.setVisibility(View.GONE); holder.tag.setVisibility(View.GONE); } if ("1".equals(messageContent.isAttached)) { holder.attachment.setVisibility(View.VISIBLE); } else { holder.attachment.setVisibility(View.GONE); } holder.otherPeopleName.setText(otherNameTag + otherName); holder.otherPeopleName.setTextColor(otherNameColor); holder.name.setText(fullName); if (!Utils.isEmpty(messageContent.date)) { holder.data.setText(Util.formatDateForMessageList(messageContent.date)); holder.data.setVisibility(View.VISIBLE); } else { holder.data.setVisibility(View.INVISIBLE); } holder.content.setText(messageContent.subject); return convertView; }