Search in sources :

Example 1 with NotificationHub

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);
}
Also used : GridLayout(android.widget.GridLayout) StatusBarNotification(android.service.notification.StatusBarNotification) ImageView(android.widget.ImageView) NotificationHub(com.reindeercrafts.notificationpeek.NotificationHub) LinearLayout(android.widget.LinearLayout)

Aggregations

StatusBarNotification (android.service.notification.StatusBarNotification)1 GridLayout (android.widget.GridLayout)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 NotificationHub (com.reindeercrafts.notificationpeek.NotificationHub)1