dependencies {
compile 'com.android.support:design:22.2.+'
compile 'com.android.support:cardview-v7:22.2.+'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
}
listviewanimations
library usesnineoldandroids
for animationslistviewanimations
provides sweeeeet animation adapters you can put your existing adapters into.
-
Populate your data source using an ArrayList
ArrayList<NotificationEntry> notificationEntries = ...;
-
Use a DynamicListView in your layout.
<com.nhaarman.listviewanimations.itemmanipulation.DynamicListView android:id="@+id/notification_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:layout_marginTop="20dp" android:clipToPadding="false" android:divider="@android:color/transparent" android:fitsSystemWindows="true" />
NOTE that adding your
DynamicListView
in aRelativeLayout
will cause some animations to stop working. -
Set an animation adapter of your choice using your data source from (1) and
DynamicListView
from (2). There are 3 defined inMainActivity
setUndoSwipeAdapter
: allows you to undo the swipe to deletesetSwipeDismissAdapter
: allows you to swipe to deletesetSwingFromRightAdapter
: notifications slide in from the right
-
There's the option to set the number of visible notifications at any time. Just use
setNumberOfVisibleNotifications
specifying theDynamicListView
and the number you want visible.-
This method uses these values from the dimens.xml
notification_height notification_bottom_margin notification_top_margin
-
-
If you want to edit the layout of...
- the notification items, it is in
notification_layout
- the undo row (what appears when you swipe a undo-able notification), it is in
undo_row
- Both layouts share some values
- color/notification_card
- dimens/notification_height
- dimens/notification_bottom_margin
- dimens/notification_top_margin
- the notification items, it is in
-
The
NotificationEntry
class has been edited to include more defined values based on theNotificationType
getCardColorResFromType
getIconFromType
-
The
NotificationType
now has aSIGN_IN
value. -
Several resources were added to match the mockups, they are required for these notifications to work
- drawable/ic_info_outline
- drawable/ic_warning
- mipmap/ic_device_bulb