From 0f574afb981638a5586f5fcd34ab13d5a49724a6 Mon Sep 17 00:00:00 2001 From: BaselHorany <30597730+BaselHorany@users.noreply.github.com> Date: Mon, 17 Feb 2020 16:24:35 +0300 Subject: [PATCH] Update FadedRecyclerView.java --- .../basel/FadedRecyclerView/FadedRecyclerView.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/FadedRecyclerView/src/main/java/com/basel/FadedRecyclerView/FadedRecyclerView.java b/FadedRecyclerView/src/main/java/com/basel/FadedRecyclerView/FadedRecyclerView.java index f83f07b..7d5e66a 100644 --- a/FadedRecyclerView/src/main/java/com/basel/FadedRecyclerView/FadedRecyclerView.java +++ b/FadedRecyclerView/src/main/java/com/basel/FadedRecyclerView/FadedRecyclerView.java @@ -32,7 +32,7 @@ public FadedRecyclerView(Context context, @Nullable AttributeSet attrs, int defS } private LayoutManager layoutManger; - private boolean isVertical,isLinear,isAggressive; + private boolean isVertical,isLinear,isAggressive,isFadeModeAlpha; private Rect rvGlobalRect,rvLocalRect,itemBoundsRect; private int red,green,blue; private VisibilityListener vListener; @@ -148,13 +148,13 @@ private void calculateVisibility(int firstVisibleItem, int lastVisibleItem) { private void fadeView(int position, int visibilty) { tempViewHolder = findViewHolderForLayoutPosition(position); if(tempViewHolder!=null){//and it should not but.. - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !isFadeModeAlpha) { int transperancyColor = Color.argb(visibilty * 255 / 100, red, green, blue); mColorDrawable = new ColorDrawable(transperancyColor); tempViewHolder.itemView.setForeground(mColorDrawable); }else{ //ugly? & expensive! - tempViewHolder.itemView.setAlpha((float)(visibilty/100)); + tempViewHolder.itemView.setAlpha((float)(100-visibilty)/100f); } } } @@ -167,4 +167,8 @@ public void setVisibilityListener(VisibilityListener visibilityListener) { vListener = visibilityListener; } -} \ No newline at end of file + public void setFadeModeAlpha(boolean fadeModeAlpha) { + isFadeModeAlpha = fadeModeAlpha; + } + +}