Show material-design-ripple in background when touching list item.
Also ensure it shows this animation correctly when expanding "Versions". This is done by changing from `notifyDataSetChanged()` to the more specific `notifyItemRange(Inserted|Removed)`, which ensures the "Versions" item doesn't get rebuilt midway through an animation.
This commit is contained in:
parent
6a6cede4de
commit
75eb72c50b
@ -135,11 +135,19 @@ public class AppDetailsRecyclerViewAdapter
|
||||
|
||||
private void setShowVersions(boolean showVersions) {
|
||||
this.showVersions = showVersions;
|
||||
items.removeAll(versions);
|
||||
boolean itemsWereRemoved = items.removeAll(versions);
|
||||
int startIndex = items.indexOf(VIEWTYPE_VERSIONS) + 1;
|
||||
|
||||
// When adding/removing items, be sure to only notifyItemInserted and notifyItemRemoved
|
||||
// rather than notifyDatasetChanged(). If we only notify about the entire thing, then
|
||||
// everything gets rebuilt, including the expandable "Versions" item. By rebuilding that
|
||||
// item it will interrupt the nice material-design-style-ripple from the background.
|
||||
if (showVersions) {
|
||||
items.addAll(items.indexOf(VIEWTYPE_VERSIONS) + 1, versions);
|
||||
items.addAll(startIndex, versions);
|
||||
notifyItemRangeInserted(startIndex, versions.size());
|
||||
} else if (itemsWereRemoved) {
|
||||
notifyItemRangeRemoved(startIndex, versions.size());
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void addItem(int item) {
|
||||
|
@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
style="@style/AppDetailsLink"
|
||||
android:drawableLeft="@drawable/ic_website"
|
||||
android:drawableStart="@drawable/ic_website"
|
||||
android:layout_marginLeft="@dimen/layout_horizontal_margin"
|
||||
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||
android:text="@string/menu_website"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android" />
|
||||
tools:text="@string/menu_website" />
|
@ -14,18 +14,24 @@
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UnusedAttribute">
|
||||
<TextView
|
||||
android:id="@+id/information"
|
||||
style="@style/AppDetailsSubheaderText"
|
||||
android:text="@string/links"
|
||||
android:paddingLeft="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:paddingStart="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:paddingRight="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:paddingEnd="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:drawableRight="@drawable/ic_expand_more_grey600"
|
||||
android:drawableEnd="@drawable/ic_expand_more_grey600"
|
||||
android:drawableLeft="@drawable/ic_website"
|
||||
android:drawableStart="@drawable/ic_website" />
|
||||
|
||||
<!-- This frame layout is only for showing the material-design-like background ripple when
|
||||
selecting the TextView. -->
|
||||
<FrameLayout style="@style/AppDetailsLink">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/information"
|
||||
style="@style/AppDetailsSubheaderText"
|
||||
android:text="@string/links"
|
||||
android:paddingLeft="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:paddingStart="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:paddingRight="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:paddingEnd="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||
android:drawableRight="@drawable/ic_expand_more_grey600"
|
||||
android:drawableEnd="@drawable/ic_expand_more_grey600"
|
||||
android:drawableLeft="@drawable/ic_website"
|
||||
android:drawableStart="@drawable/ic_website" />
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_content"
|
||||
|
Loading…
x
Reference in New Issue
Block a user