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

Modify time update interval #61

Open
ryandt opened this issue Aug 2, 2018 · 1 comment
Open

Modify time update interval #61

ryandt opened this issue Aug 2, 2018 · 1 comment

Comments

@ryandt
Copy link

ryandt commented Aug 2, 2018

I'm wanting to show ETAs that will commonly be less than 60 minutes but may occasionally be up to 120 minutes. In the case that the ETA is 60 minutes or less, the ETA text of my RelativeTextView updates every minute. In the case where an ETA is greater than 60 minutes, the ETA text updates every hour. However, I need the ETA to update every minute regardless of the difference between now and the reference time.

Current interval logic:

if (difference > DateUtils.WEEK_IN_MILLIS) {
   interval = DateUtils.WEEK_IN_MILLIS;
} else if (difference > DateUtils.DAY_IN_MILLIS) {
   interval = DateUtils.DAY_IN_MILLIS;
} else if (difference > DateUtils.HOUR_IN_MILLIS) {
   interval = DateUtils.HOUR_IN_MILLIS;
}

I think it would be helpful to add the ability to modify the time update interval. This could be achieved in a couple ways.
A) Add a public setter to set and override the time interval.
B) Allow subclasses to override the method that determines the interval.

I prefer option B as it provides more flexibility to the client.

@curioustechizen What are your thoughts on adding the ability to modify the time update interval?

@curioustechizen
Copy link
Owner

@ryandt For now, you can override the getRelativeTimeDisplayString() method and there use your own logic to determine the update interval.

However, I'm not happy about the flexibility (or lack of it) in this library. The default algorithm to calculate the update interval does not fit all use cases.

I'm open to suggestions about an elegant way to expose the update interval as an API.

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