Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix color reset on last slide with screen reorientation #145

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,13 @@ public void onDismissed(Snackbar snackbar, int event) {
}

private Integer getBackgroundColor(int position, float positionOffset) {
return (Integer) argbEvaluator.evaluate(positionOffset, color(adapter.getItem(position).backgroundColor()), color(adapter.getItem(position + 1).backgroundColor()));
int nextPosition = (position == adapter.getCount() - 1) ? position : position + 1;
return (Integer) argbEvaluator.evaluate(positionOffset, color(adapter.getItem(position).backgroundColor()), color(adapter.getItem(nextPosition).backgroundColor()));
}

private Integer getButtonsColor(int position, float positionOffset) {
return (Integer) argbEvaluator.evaluate(positionOffset, color(adapter.getItem(position).buttonsColor()), color(adapter.getItem(position + 1).buttonsColor()));
int nextPosition = (position == adapter.getCount() - 1) ? position : position + 1;
return (Integer) argbEvaluator.evaluate(positionOffset, color(adapter.getItem(position).buttonsColor()), color(adapter.getItem(nextPosition).buttonsColor()));
}

private int color(@ColorRes int color) {
Expand All @@ -430,7 +432,7 @@ private int color(@ColorRes int color) {
private class ColorTransitionScrollListener implements IPageScrolledListener {
@Override
public void pageScrolled(int position, float offset) {
if (position < adapter.getCount() - 1) {
if (position <= adapter.getCount() - 1) {
setViewsColor(position, offset);
} else if (adapter.getCount() == 1) {
viewPager.setBackgroundColor(adapter.getItem(position).backgroundColor());
Expand Down