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
@RequiresApi(Build.VERSION_CODES.S) | |
val metaBallRenderEffect = | |
RenderEffect.createChainEffect( | |
RenderEffect.createColorFilterEffect( | |
ColorMatrixColorFilter( | |
ColorMatrix( | |
floatArrayOf( | |
1f, 0f, 0f, 0f, 0f, | |
0f, 1f, 0f, 0f, 0f, | |
0f, 0f, 1f, 0f, 0f, |
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
//const val ASPECT_RATIO = 4/3f you can play with it | |
const val ASPECT_RATIO = 1.55f | |
@Composable | |
fun ScrollPositionListItem( | |
itemUi: ListItemUi, | |
listState: LazyListState, | |
index: Int, | |
modifier: Modifier = Modifier, | |
viewportHeight: Float |
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
@Composable | |
fun ParallaxRoute( | |
viewModel: ParallaxVewModel = hiltViewModel(), | |
) { | |
val uiState by viewModel.uiState.collectAsStateWithLifecycle() | |
ParallaxScreen(uiState) | |
} | |
@Composable | |
fun ParallaxScreen( |
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 applyParallax(float translateValue) { | |
mBackgroundImg.setTranslationY(translateValue - this.getHeight() / 8f); | |
mTitleTV.setTranslationY(+translateValue * 2); | |
mProfileCircleIV.setTranslationY(translateValue * 2); | |
mWeatherIcon.setTranslationY(translateValue * 2); | |
} |
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 int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, | |
RecyclerView.State state) { | |
... | |
if (parentLayout != null) { | |
animatedLayout = parentLayout.findViewById(R.id.transformItem); | |
float translateValue = computeCurrentParallaxOffset(parentLayout); | |
animatedLayout.applyParallax(translateValue); | |
} | |
... |
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 void applySummerTitleTV() { | |
mTitleTV.setBackgroundResource(R.drawable.summer_text_background); | |
mTitleTV.setTextColor(Color.BLACK); | |
mTitleTV.setText("WINTER IS COMING..."); | |
// fix bug: text view with wrap_content layout param | |
// does not resize its width and | |
// last word of new text will not displayed if new string is longer |
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 int mIdleState = SUMMER_STATE; // set initial state as SUMMER_STATE | |
... | |
public void animateBy(int dy) { | |
float newOffset; | |
if (dy > 0) { | |
newOffset = (mOffsetValue - dy) < 0 ? 0 : mOffsetValue - dy; | |
} else { | |
//scroll to the left |
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 CustomLinearLayoutManager extends LinearLayoutManager { | |
public CustomLinearLayoutManager(Context context) { | |
super(context); | |
} | |
public CustomLinearLayoutManager(Context context, int orientation, boolean reverseLayout) { | |
super(context, orientation, reverseLayout); | |
} | |
public CustomLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
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 init() { | |
... | |
mFling.addEndListener(new DynamicAnimation.OnAnimationEndListener() { | |
@Override | |
public void onAnimationEnd(DynamicAnimation animation, boolean canceled, float value, float velocity) { | |
if (!canceled) { | |
if (mOffsetValue == 0 || mOffsetValue == getWidth()) { | |
//correct ending | |
mCurrentAnimation = IDLE_ANIMATION_STATE; | |
if (mOffsetValue == 0) { |
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 event) { | |
isTouching = true; | |
mFling.cancel(); | |
switch (event.getActionMasked()) { | |
case MotionEvent.ACTION_DOWN: | |
mPreviousTouchX = event.getX(); | |
if (mVelocityTracker == null) { | |
// Retrieve a new VelocityTracker object to watch the velocity | |
// of a motion. |
NewerOlder