use of org.openhab.habdroid.model.OpenHABNotification in project openhab-android by openhab.
the class OpenHABNotificationAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(NotificationViewHolder holder, int position) {
OpenHABNotification notification = mItems.get(position);
holder.mCreatedView.setText(DateUtils.getRelativeDateTimeString(mContext, notification.createdTimestamp(), DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0));
holder.mMessageView.setText(notification.message());
if (notification.icon() != null) {
Connection conn = ConnectionFactory.getConnection(Connection.TYPE_CLOUD);
String iconUrl = String.format(Locale.US, "%simages/%s.png", conn.getOpenHABUrl(), Uri.encode(notification.icon()));
holder.mIconView.setImageUrl(iconUrl, conn.getUsername(), conn.getPassword(), R.drawable.ic_openhab_appicon_24dp);
} else {
holder.mIconView.setImageResource(R.drawable.ic_openhab_appicon_24dp);
}
}
Aggregations