Skip to content

Commit

Permalink
Merge pull request #35 from MFlisar/master
Browse files Browse the repository at this point in the history
Removed unnnecessary inner handler
  • Loading branch information
myinnos authored Jun 4, 2018
2 parents 3f3a180 + 818eda3 commit ed6da8f
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,14 @@ private int getSectionByPoint(float y) {
return (int) ((y - mIndexbarRect.top - mIndexbarMargin) / ((mIndexbarRect.height() - 2 * mIndexbarMargin) / mSections.length));
}

private static final int WHAT_FADE_PREVIEW = 1;
private Runnable mLastFadeRunnable = null;

private void fade(long delay) {
if (mRecyclerView != null) {
if (mLastFadeRunnable != null) {
mRecyclerView.removeCallbacks(mLastFadeRunnable);
}
}
mHandler.removeMessages(0);
mHandler.sendEmptyMessageAtTime(WHAT_FADE_PREVIEW, SystemClock.uptimeMillis() + delay);
}
Expand All @@ -274,10 +279,15 @@ public void handleMessage(Message msg) {
if (msg.what == WHAT_FADE_PREVIEW) {
mRecyclerView.invalidate();
}

mLastFadeRunnable = new Runnable() {
@Override
public void run() {
mRecyclerView.invalidate();
}
};
mRecyclerView.postDelayed(mLastFadeRunnable, delay);
}

};
}

private int convertTransparentValueToBackgroundAlpha(float value) {
return (int) (255 * value);
Expand Down

0 comments on commit ed6da8f

Please sign in to comment.