use of com.reindeercrafts.notificationpeek.NotificationHub in project NotificationPeekPort by lzanita09.
the class NotificationPeekActivity method updateNotificationIcons.
/**
* Update small notification icons when there is new notification coming, and the
* Activity is in foreground.
*/
private void updateNotificationIcons() {
if (mNotificationsContainer.getVisibility() != View.VISIBLE) {
mNotificationsContainer.setVisibility(View.VISIBLE);
}
NotificationHub notificationHub = NotificationHub.getInstance();
int iconSize = getResources().getDimensionPixelSize(R.dimen.small_notification_icon_size);
int padding = getResources().getDimensionPixelSize(R.dimen.small_notification_icon_padding);
final StatusBarNotification n = notificationHub.getCurrentNotification();
ImageView icon = new ImageView(this);
icon.setAlpha(NotificationPeek.ICON_LOW_OPACITY);
icon.setPadding(padding, 0, padding, 0);
icon.setImageDrawable(NotificationPeekViewUtils.getIconFromResource(this, n));
icon.setTag(n);
restoreFirstIconVisibility();
int oldIndex = getOldIconViewIndex(notificationHub);
if (oldIndex >= 0) {
mNotificationsContainer.removeViewAt(oldIndex);
}
mNotificationsContainer.addView(icon);
LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(iconSize, iconSize);
// Wrap LayoutParams to GridLayout.LayoutParams.
GridLayout.LayoutParams gridLayoutParams = new GridLayout.LayoutParams(linearLayoutParams);
icon.setLayoutParams(gridLayoutParams);
}
Aggregations