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
... | |
private Bitmap mBitmap; | |
... | |
private void initScrollView() { | |
... | |
Resources res = getResources(); | |
mBitmap = BitmapFactory.decodeResource(res, R.drawable.hand_rope); | |
mBitmap = Bitmap.createScaledBitmap(mBitmap, mBitmap.getWidth() / 2, | |
mBitmap.getHeight() / 2, false); | |
} |
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
... | |
<com.example.replica.NestedScrollView | |
android:layout_height="match_parent" | |
android:layout_width="match_parent" | |
android:background="@color/overscroll_background"> | |
<androidx.cardview.widget.CardView | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:elevation="8dp" |
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
private boolean useEdgeEffect = false; | |
... | |
@Override | |
public boolean onTouchEvent(MotionEvent ev) { | |
... | |
// if (canOverscroll) { | |
if (useEdgeEffect) { | |
deltaY -= mScrollConsumed[1]; |
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
boolean overScrollByCompat(int deltaX, int deltaY, | |
int scrollX, int scrollY, | |
int scrollRangeX, int scrollRangeY, | |
int maxOverScrollX, int maxOverScrollY, | |
boolean isTouchEvent) { | |
... | |
// if (clampedY && !hasNestedScrollingParent(ViewCompat.TYPE_NON_TOUCH)) { | |
if (clampedY && !hasNestedScrollingParent(ViewCompat.TYPE_NON_TOUCH) | |
&& !mIsBeingDragged) { | |
mScroller.springBack(newScrollX, newScrollY, 0, 0, 0, getScrollRange()); |
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
public void fling(int velocityY) { | |
if (getChildCount() > 0) { | |
// standart implementation: | |
// mScroller.fling(getScrollX(), getScrollY(), // start | |
// 0, velocityY, // velocities | |
// 0, 0, // x | |
// Integer.MIN_VALUE, Integer.MAX_VALUE, // y | |
// 0, 0); // overscroll | |
// fixed implementation: | |
int height = getHeight() - getPaddingBottom() - getPaddingTop(); |
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
@Override | |
public void computeScroll() { | |
... | |
overScrollByCompat(0, unconsumed, getScrollX(), | |
oldScrollY, 0, range, 0, mOverflingDistance, false); | |
... | |
} |
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
@Override | |
public boolean onTouchEvent(MotionEvent ev) { | |
... | |
case MotionEvent.ACTION_MOVE: | |
... | |
// Calling overScrollByCompat will call onOverScrolled, which | |
// calls onScrollChanged if applicable. | |
if (overScrollByCompat(0, deltaY, 0, getScrollY(), 0, range, 0, | |
mOverscrollDistance, true) && !hasNestedScrollingParent(ViewCompat.TYPE_TOUCH)) { |
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
public class NestedScrollView extends FrameLayout implements NestedScrollingParent3, | |
NestedScrollingChild3, ScrollingView { | |
static final int ANIMATED_SCROLL_GAP = 250; | |
static final float MAX_SCROLL_FACTOR = 0.5f; | |
private static final String TAG = "NestedScrollView"; | |
/** | |
* Interface definition for a callback to be invoked when the scroll |
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
public class ExpandableTextView extends AppCompatTextView | |
implements View.OnClickListener { | |
private final int COLLAPSED_MAX_LINES = 3; | |
private final static String POSTFIX = "...see more "; | |
private ValueAnimator mAnimator; | |
private boolean isCollapsing; | |
private CharSequence mOriginalText; |
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
@Override | |
protected void onLayout(boolean changed, int left, int top, int right, int bottom) { | |
super.onLayout(changed, left, top, right, bottom); | |
if (getLineCount() <= COLLAPSED_MAX_LINES) { | |
deEllipsize(); // add to fix current bug | |
setClickable(false); | |
} else { | |
setClickable(true); | |
if (!animator.isRunning() && isCollapsed()) { | |
ellipsizeColored(); |