-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
126 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 35 additions & 13 deletions
48
library/src/main/java/com/mikepenz/aboutlibraries/util/RippleForegroundListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,66 @@ | ||
package com.mikepenz.aboutlibraries.util; | ||
|
||
import android.support.v7.widget.CardView; | ||
import android.annotation.SuppressLint; | ||
import android.os.Build; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
|
||
/** | ||
* Created by mikepenz on 16.04.15. | ||
*/ | ||
public class RippleForegroundListener implements View.OnTouchListener { | ||
CardView cardView; | ||
private int rippleViewId = -1; | ||
|
||
public RippleForegroundListener setCardView(CardView cardView) { | ||
this.cardView = cardView; | ||
return this; | ||
/** | ||
* @param rippleViewId the id of the view which contains the rippleDrawable | ||
*/ | ||
public RippleForegroundListener(int rippleViewId) { | ||
this.rippleViewId = rippleViewId; | ||
} | ||
|
||
@SuppressLint("ClickableViewAccessibility") | ||
@Override | ||
public boolean onTouch(View v, MotionEvent event) { | ||
// Convert to card view coordinates. Assumes the host view is | ||
// a direct child and the card view is not scrollable. | ||
// Convert to view coordinates. Assumes the host view is | ||
// a direct child and the view is not scrollable. | ||
float x = event.getX() + v.getLeft(); | ||
float y = event.getY() + v.getTop(); | ||
|
||
if (android.os.Build.VERSION.SDK_INT >= 21) { | ||
// Simulate motion on the card view. | ||
cardView.drawableHotspotChanged(x, y); | ||
final View rippleView = findRippleView(v); | ||
//if we were not able to find the view to display the ripple on, continue. | ||
if (rippleView == null) { | ||
return false; | ||
} | ||
|
||
// Simulate pressed state on the card view. | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
// Simulate motion on the view. | ||
rippleView.drawableHotspotChanged(x, y); | ||
} | ||
|
||
// Simulate pressed state on the view. | ||
switch (event.getActionMasked()) { | ||
case MotionEvent.ACTION_DOWN: | ||
cardView.setPressed(true); | ||
rippleView.setPressed(true); | ||
break; | ||
case MotionEvent.ACTION_UP: | ||
case MotionEvent.ACTION_CANCEL: | ||
cardView.setPressed(false); | ||
rippleView.setPressed(false); | ||
break; | ||
} | ||
|
||
// Pass all events through to the host view. | ||
return false; | ||
} | ||
|
||
public View findRippleView(View view) { | ||
if (view.getId() == rippleViewId) { | ||
return view; | ||
} else { | ||
if (view.getParent() instanceof View) { | ||
return findRippleView((View) view.getParent()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/cardListView" | ||
android:layout_width="match_parent" | ||
android:clipToPadding="false" | ||
android:layout_height="match_parent" | ||
android:clipToPadding="false" | ||
android:divider="@null" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_horizontal_margin" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
/> | ||
android:scrollbarStyle="outsideInset" | ||
android:scrollbars="vertical" /> | ||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,105 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v7.widget.CardView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@id/rippleForegroundListenerView" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginBottom="8dp" | ||
android:layout_marginTop="8dp" | ||
android:clickable="true" | ||
android:foreground="?selectableItemBackground"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="6dp" | ||
android:orientation="vertical"> | ||
android:orientation="vertical" | ||
android:padding="6dp"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center_vertical" | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp" | ||
android:orientation="horizontal" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp"> | ||
|
||
<TextView | ||
android:id="@+id/libraryName" | ||
android:textSize="@dimen/textSizeLarge_openSource" | ||
android:textStyle="normal" | ||
android:layout_width="0dp" | ||
android:layout_weight="5" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="5" | ||
android:ellipsize="end" | ||
android:maxLines="1" | ||
tools:text="Library name"/> | ||
android:textSize="@dimen/textSizeLarge_openSource" | ||
android:textStyle="normal" | ||
tools:text="Library name" /> | ||
|
||
<TextView | ||
android:id="@+id/libraryCreator" | ||
android:textStyle="normal" | ||
android:layout_width="0dp" | ||
android:layout_weight="2" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="2dp" | ||
android:layout_weight="2" | ||
android:gravity="right" | ||
android:maxLines="2" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
tools:text="Creator"/> | ||
android:textStyle="normal" | ||
tools:text="Creator" /> | ||
</LinearLayout> | ||
|
||
<View | ||
android:id="@+id/libraryDescriptionDivider" | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginTop="4dp"/> | ||
android:layout_marginTop="4dp" /> | ||
|
||
<TextView | ||
android:id="@+id/libraryDescription" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
android:textStyle="normal" | ||
android:padding="8dp" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:maxLines="20" | ||
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in aliquet justo. Donec tincidunt, leo imperdiet pretium posuere, sapien leo auctor mi, ac scelerisque diam leo vel sapien. Morbi lobortis, sem sed molestie fermentum."> | ||
</TextView> | ||
android:padding="8dp" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
android:textStyle="normal" | ||
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in aliquet justo. Donec tincidunt, leo imperdiet pretium posuere, sapien leo auctor mi, ac scelerisque diam leo vel sapien. Morbi lobortis, sem sed molestie fermentum."></TextView> | ||
|
||
<View | ||
android:id="@+id/libraryBottomDivider" | ||
android:layout_width="match_parent" | ||
android:layout_height="1px" | ||
android:layout_marginTop="4dp" | ||
/> | ||
android:layout_marginTop="4dp" /> | ||
|
||
<LinearLayout | ||
android:id="@+id/libraryBottomContainer" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center_vertical" | ||
android:orientation="horizontal" | ||
android:paddingLeft="8dp" | ||
android:paddingTop="4dp" | ||
android:paddingRight="8dp" | ||
android:orientation="horizontal" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
android:paddingTop="4dp"> | ||
|
||
<TextView | ||
android:id="@+id/libraryVersion" | ||
android:textStyle="normal" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:gravity="left" | ||
android:maxLines="1" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
tools:text="Version"/> | ||
android:textStyle="normal" | ||
tools:text="Version" /> | ||
|
||
<TextView | ||
android:id="@+id/libraryLicense" | ||
android:textStyle="normal" | ||
android:layout_width="0dp" | ||
android:layout_weight="1" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:gravity="right" | ||
android:maxLines="1" | ||
android:textSize="@dimen/textSizeSmall_openSource" | ||
tools:text="License"/> | ||
android:textStyle="normal" | ||
tools:text="License" /> | ||
</LinearLayout> | ||
</LinearLayout> | ||
</android.support.v7.widget.CardView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<item name="rippleForegroundListenerView" type="id" /> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.