Skip to content

Commit

Permalink
Update FadedRecyclerView.java
Browse files Browse the repository at this point in the history
  • Loading branch information
BaselHorany authored Feb 17, 2020
1 parent a18a594 commit 0f574af
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand All @@ -167,4 +167,8 @@ public void setVisibilityListener(VisibilityListener visibilityListener) {
vListener = visibilityListener;
}

}
public void setFadeModeAlpha(boolean fadeModeAlpha) {
isFadeModeAlpha = fadeModeAlpha;
}

}

0 comments on commit 0f574af

Please sign in to comment.