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

Support for setting min and max dates #173

Closed
wants to merge 5 commits into from

Conversation

glennschmidt
Copy link
Contributor

In case you are interested, I've implemented a feature for limiting the WeekView to a defined date range. This allows you to disable the infinite horizontal scrolling in one or both directions.

I think this makes the component more flexible, and useful in a range of situations. For example you could show a schedule of sessions that occur over a fixed period at a conference.

This feature has involved a few changes to the codebase, which can be broken down as follows:

  1. Add members mMinDate and mMaxDate which default to null (providing unrestricted scrolling by default)
  2. Add public methods getMinDate(), getMaxDate(), setMinDate(), setMaxDate()
  3. Eliminate mToday and replace it with mHomeDate, which is recalculated by a private method resetHomeDate() whenever certain properties change.
    • When the horizontal scroll offset is zero, the home date will be the leftmost day visible in the view.
    • The home date won't always be 'today', because today's date might not be within the the restricted date range.
  4. Centralise the logic that calculates min/max scroll offsets into private methods getXMinLimit(), getXMaxLimit(), getYMinLimit() and getYMaxLimit()
  5. Centralise the logic that calculates the x-offset for a date into private method getXOriginForDate()
  6. Enforce the scroll limits in onScroll(), onFling() and goToDate()

@entropitor
Copy link
Contributor

Super! 👍

I'll take a look later!

@alamkanak Are their guidelines yet about Pull Requests?

@entropitor
Copy link
Contributor

@glennschmidt Can you rebase on develop, I'll take a look then, because it's a highly requested feature!

Allows you to disable the infinite horizontal scrolling in one or both directions.

Centralized the logic for calculating scroll limits into methods getYMinLimit(),
getYMaxLimit(), getXMinLimit(), getXMaxLimit().
Calculate scroll limits and home date appropriately when min/max
dates are set and numberOfVisibleDays > 1.
@glennschmidt
Copy link
Contributor Author

Ok, done.
I also have a patch for setting min and max hours (ie. vertical scroll limits), but it's dependant on this one, so I'll submit it if this gets merged.

@Bersam
Copy link

Bersam commented Oct 24, 2015

I've switched to this fork and it's working flawlessly. +1

@tncalucard
Copy link

Hi,

I'm very interrested on using this library with this feature. When is it intended to be included on the master branch?

@Anio-pke
Copy link

What happens with this pull? I need this too. :)

@marunjar
Copy link
Contributor

👍

@entropitor
Copy link
Contributor

Oops, I totally forgot about this PR :(

I'm so sorry, but @glennschmidt can you rebase onto master again?

@entropitor
Copy link
Contributor

@glennschmidt Do you have to time to rebase this on the develop branch and fix the merge conflicts?

This is a highly requested feature, see #6 and all duplicates referencing #6.

@glennschmidt
Copy link
Contributor Author

I should get around to it this week.

@simoattila
Copy link

Hey everyone :) I also need this feature :) @glennschmidt can You tell us when will be this available please?

@rmnbhl
Copy link

rmnbhl commented Mar 8, 2016

Ola :)

i would also appreciate this feature. @glennschmidt is it going to be merged or not? Just to know if to wait on that or go on. Thanks.

@rmnbhl
Copy link

rmnbhl commented Mar 14, 2016

I rebased that old commits to the master on my own. I found one issue there - when the period has length 28 days it is going weird. But for my purpose it is not a problem. Sorry, but for now I have no skills to pull and solve the collisions here on github. Old collision code is more less commented and marked by "//TODO". Could help so I decide to put it on pastebin at least: http://pastebin.com/8arLPBJ2 - thought better than keep it will be post it somewhere even in this state and way.

jamesnwarner pushed a commit to jamesnwarner/Android-Week-View that referenced this pull request May 10, 2016
This code is adapted from code written by @glennschmidt. The original code can be found in this pull request (alamkanak#173).
This code was written to work with a newer version of Android-Week-View.
@jamesnwarner
Copy link

I've managed to get @glennschmidt code working with the latest version of develop with no conflicts. I will now open a pull request for this so that others can hopefully use this feature.

@entropitor
Copy link
Contributor

Closing this in favor of #319

@entropitor entropitor closed this Aug 29, 2016
kimkyuhwan pushed a commit to AE-TEM/Android-Week-View that referenced this pull request Nov 20, 2021
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

Successfully merging this pull request may close these issues.

None yet

9 participants