Notification Center - List Item

A notification list item represents a single notification (action item) that requires user attention.

Usage

A notification list item represents a single notification (action item) in a list of notifications that require user attention.

A notification list item has several standard data elements:

  • title
  • description
  • a timestamp representing its creation date
  • associated relevance rank.
  • an associated action which is triggered when the user taps on the item.

The notification list item is capable of displaying a maximum of two lines of text in the description field. Descriptions that exceed two lines will be truncated with a trailing ellipsis.

Developers who use notification list item should provide functionality that allows app users to delete items and mark them as read, both individually and en masse.

Items fall off the list on a schedule that is dependent on the type of notification. The logic for each type of notification is provided to the Notification Center/Notification List Item via the product implementing a data source for that type of notification.

The order of an item in the list is determined by its timestamp. In the future, ordering may take relevance rank into account.

Android Specific Behavior

The Notification Center List Item component behaves the same on all platforms currently.

Availability

Available as part of the notificationcenter-android module maintained by Customer Technology Front-end Platform Engineering

Technical Details

Class and Module

NotificationListItemAdapter.kt — located in core module ui/american (note: this is an example)

notification_list_item.xml - located in core module ui/american (note: this is an example)

Example Code

Kotlin:

class MyActivity : AmericanActivity() {
    private lateinit var recyclerView: RecyclerView
    private lateinit var viewAdapter: RecyclerView.Adapter<*>
    private lateinit var viewManager: RecyclerView.LayoutManager

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.my_activity)

        // List items will be displayed in a single column in the RecyclerView
        viewManager = LinearLayoutManager(this)

        // Initialize adapter with initial list of notifications
        viewAdapter = NotificationListItemAdapter(myNotificationList)

        // Fetch reference to RecyclerView from layout and apply settings
        recyclerView = findViewById<RecyclerView>(R.id.my_recycler_view).apply {
            // use this setting to improve performance if you know that changes
            // in content do not change the layout size of the RecyclerView
            setHasFixedSize(true)

            // Apply the LinearLayoutManager to the RecyclerView
            layoutManager = viewManager

            // Apply the NotificationListItemAdapter
            adapter = viewAdapter

        }
    }
    // ...
}
<p>Unread State</p>
<img src="../../app-component-images/android/notification-list-item-unread.png" alt="Android Notification List Item in Unread State" />
<p>Read State</p>
<img src="../../app-component-images/android/notification-list-item-read.png" alt="Android Notification List Item in Read State" />
  • Handle: @notificationlistitem-android
  • Preview:
  • Filesystem Path: components/app/android/notificationcenter-android/notificationlistitem-android/notificationlistitem-android.hbs