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

Bug with goToHour method when time range is set #104

Open
anisias opened this issue May 22, 2018 · 3 comments
Open

Bug with goToHour method when time range is set #104

anisias opened this issue May 22, 2018 · 3 comments

Comments

@anisias
Copy link

anisias commented May 22, 2018

If a time range is set and goToHour(currentTime) method is called the view will not scroll to currentTime hour because of a bug in goToHour method

verticalOffset = (int) (mHourHeight * hour);

it should be
verticalOffset = (int) (mHourHeight * (hour - mMinTime));
otherwise it works only with the default range of 0-24

@NaturallyAsh
Copy link

I am having this problem as well after setting max and min time attr. I tried your change but unfortunately it doesn't help with the problem.

@anisias
Copy link
Author

anisias commented Oct 8, 2018

I modified also other parts of this method, do you have problems when current hour > maxTime, when current hour > minTime or in both cases?
This is my current method:

public void goToHour(double hour) {
    if (mAreDimensionsInvalid) {
        mScrollToHour = hour;
        return;
    }

   int verticalOffset = 0;
   if (hour > mMinTime && hour < mMaxTime) {
        verticalOffset = (int) (mHourHeight * (hour - mMinTime));
    }
    if (verticalOffset > mHourHeight * (mMaxTime - mMinTime) - getHeight() + mHeaderHeight + mHeaderMarginBottom) {
        verticalOffset = (int) (mHourHeight * (mMaxTime - mMinTime) - getHeight() + mHeaderHeight + mHeaderMarginBottom);
    }
    mCurrentOrigin.y = -verticalOffset;
    invalidate();
    mScroller.forceFinished(true);
}

Hope it helps

@NaturallyAsh
Copy link

Yes it works now! Thanx soo much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants