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) {
|
private void setShowVersions(boolean showVersions) {
|
||||||
this.showVersions = 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) {
|
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) {
|
private void addItem(int item) {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TextView
|
<TextView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
style="@style/AppDetailsLink"
|
style="@style/AppDetailsLink"
|
||||||
android:drawableLeft="@drawable/ic_website"
|
android:drawableLeft="@drawable/ic_website"
|
||||||
android:drawableStart="@drawable/ic_website"
|
android:drawableStart="@drawable/ic_website"
|
||||||
android:layout_marginLeft="@dimen/layout_horizontal_margin"
|
android:layout_marginLeft="@dimen/layout_horizontal_margin"
|
||||||
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
android:layout_marginStart="@dimen/layout_horizontal_margin"
|
||||||
android:text="@string/menu_website"
|
tools:text="@string/menu_website" />
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@ -14,18 +14,24 @@
|
|||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:ignore="UnusedAttribute">
|
tools:ignore="UnusedAttribute">
|
||||||
<TextView
|
|
||||||
android:id="@+id/information"
|
<!-- This frame layout is only for showing the material-design-like background ripple when
|
||||||
style="@style/AppDetailsSubheaderText"
|
selecting the TextView. -->
|
||||||
android:text="@string/links"
|
<FrameLayout style="@style/AppDetailsLink">
|
||||||
android:paddingLeft="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
|
||||||
android:paddingStart="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
<TextView
|
||||||
android:paddingRight="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
android:id="@+id/information"
|
||||||
android:paddingEnd="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
style="@style/AppDetailsSubheaderText"
|
||||||
android:drawableRight="@drawable/ic_expand_more_grey600"
|
android:text="@string/links"
|
||||||
android:drawableEnd="@drawable/ic_expand_more_grey600"
|
android:paddingLeft="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||||
android:drawableLeft="@drawable/ic_website"
|
android:paddingStart="@dimen/details_activity__collapsable_lists__padding__horizontal"
|
||||||
android:drawableStart="@drawable/ic_website" />
|
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
|
<LinearLayout
|
||||||
android:id="@+id/ll_content"
|
android:id="@+id/ll_content"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user