Search in sources :

Example 1 with OpenHABNotification

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);
    }
}
Also used : OpenHABNotification(org.openhab.habdroid.model.OpenHABNotification) Connection(org.openhab.habdroid.core.connection.Connection)

Aggregations

Connection (org.openhab.habdroid.core.connection.Connection)1 OpenHABNotification (org.openhab.habdroid.model.OpenHABNotification)1