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 float MIN_FLING_START_VELOCITY_DP = 500; | |
private float mCurrentMinFlingVelocityPx; | |
private VelocityTracker mVelocityTracker; | |
private boolean isTouching = false; | |
private FlingAnimation mFling = new FlingAnimation(this, | |
new FloatPropertyCompat<AnimatedLayout>("offset") { | |
@Override | |
public float getValue(AnimatedLayout object) { |
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 void updateOffset(float newOffsetValue) { | |
... | |
updateIconView(); | |
} | |
private void updateIconView() { | |
float oldTranslatePosition = mWeatherIcon.getTranslationX(); | |
float newTranslatePosition; | |
float newAlpha; |
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 AnimatedLayout extends ConstraintLayout { | |
... | |
@Override | |
protected boolean drawChild(Canvas canvas, View child, long drawingTime) { | |
if (canvas instanceof ScreenShotCanvas) { | |
if (isChildExcluded(child)) { | |
// do not draw this child to the screenshot canvas | |
return false; | |
} | |
return super.drawChild(canvas, child, drawingTime); |
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 AnimatedLayout extends ConstraintLayout { | |
... | |
private CircleImageView mWeatherIcon; | |
... | |
@Override | |
protected void onFinishInflate() { | |
super.onFinishInflate(); | |
... | |
mWeatherIcon = findViewById(R.id.weatherIconIV); |
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
<?xml version="1.0" encoding="utf-8"?> | |
<com.example.animated.article.custom.AnimatedLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/transformItem" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" |
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 boolean draw(Canvas canvas) { | |
canvas.clipRect(mBounds.left, | |
mBounds.top, | |
mBounds.right, | |
mBounds.bottom + mBounds.bottom * BlUR_RADIUS_FACTOR); | |
... | |
// mPaint.setAlpha((int) (0xff * mGlowAlpha)); alpha is not going to be changed during animation | |
... | |
} |
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 setSize(int width, int height) { | |
... | |
mPaint.setMaskFilter(new BlurMaskFilter(mBounds.bottom * BlUR_RADIUS_FACTOR, | |
BlurMaskFilter.Blur.NORMAL)); | |
} |
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 GlowingEdgeEffectFactory extends RecyclerView.EdgeEffectFactory { | |
@NonNull | |
@Override | |
protected EdgeEffect createEdgeEffect(@NonNull RecyclerView view, int direction) { | |
return new GlowingEdgeEffect(view.getContext()); | |
} | |
} |
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 DistortEdgeEffect { | |
... | |
private static final float RADIUS_FACTOR = 1f; //not nessesary but I have changed it from 0.6 to 1 | |
private final int HORIZONTAL_STEPS_COUNT = 40; // as more steps as more smoother it looks | |
private float[] mDistrotedVertices; | |
private float mStepWidth; | |
... | |
public void setSize(int width, int height) { | |
... |
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 DistortEdgeEffect { | |
... | |
private int mFulHeight; | |
private int mFullWidth; | |
private float maxDistortionHeight; | |
... | |
public void setSize(int width, int height) { | |
... |