Comments (13)
Are you on the latest version? I have tried to reproduce this, but I'm finding it difficult to do so. Are you using the sample or have you modified any thing?
from compactcalendarview.
@SundeepK I'm using version 1.7.9. I know its hard to reproduce it and it doesn't happen all the time. It is really really weird you need to scroll like 12 months away to start seeing it.
from compactcalendarview.
I have scrolled years and haven't spotted it, you are using the sample project correct?
from compactcalendarview.
@SundeepK this is my code:
calendarView.setListener(new CompactCalendarView.CompactCalendarViewListener() {
@Override
public void onDayClick(Date dateClicked) {
currentSelectedDate = dateClicked;
dateSelected.setText(DateUtil.getCalendarShowableDate(dateClicked));
}
@Override
public void onMonthScroll(Date firstDayOfNewMonth) {
setMonthName(dateFormatForMonth.format(firstDayOfNewMonth)); //here I'm showing month and year in the Toolbar
Calendar scrolledCalendar = Calendar.getInstance();
scrolledCalendar.setTime(firstDayOfNewMonth);
todayCal = Calendar.getInstance(Locale.getDefault());
//If I scrolled to the current month, set the day to the current day
if (todayCal.get(Calendar.MONTH) == scrolledCalendar.get(Calendar.MONTH) &&
todayCal.get(Calendar.YEAR) == scrolledCalendar.get(Calendar.YEAR)) {
scrolledCalendar.set(Calendar.DAY_OF_MONTH, CalendarContainer.this.todayCal.get(Calendar.DAY_OF_MONTH));
calendarView.setCurrentDate(scrolledCalendar.getTime());
}
dateSelected.setText(DateUtil.getCalendarShowableDate(scrolledCalendar.getTime()));
presenter.getEventsByStartDate(scrolledCalendar.getTime());
}
});
from compactcalendarview.
I suspect a bug on setting the current date using setCurrentDate()
whilst in the callback.
from compactcalendarview.
@SundeepK Do you mean I can't call setcurrentDate inside the onMonthScroll? Sorry, I didn't understand that last comment.
from compactcalendarview.
Well it might be a bug in the library when setting the current day whilst in the callback. Under the hood, it uses java Calendar object, which is not the nicest class you work with and is mutable. Might be some inconsistency while setting the date which could be causing the problem, but I will investigate.
I have copied your code directly and I can see the bug as you describe.
from compactcalendarview.
Ok I think I found the problem, under the hood, the library uses OverScroller to keep track of how far the user has scrolled in x direction. When setting the date, the current date was being initialized correctly with the one passed in but the OverScroller current x direction was not being reset to 0.
This causes a problem since internally it uses OverScroller is used to keep track how many months user has scrolled in +/- and sets the date accordingly.
I think solution is simple as calling scroller.startScroll(0,0,0,0);
when setting the date. Also would be a good place to reset any internal values to 0 just to be sure.
from compactcalendarview.
This also leads to anther method to be exposed by the library which is scrollBackToCurrentDate()
. This will allow user to easily scroll back to the currently set date in the calendar through scroller.startScroll((int) accumulatedScrollOffset.x,0, (int) - accumulatedScrollOffset.x,0);
and will play an animation. But this is totally out of scope of this issue.
from compactcalendarview.
After a bit of playing around, I've taken the pragmatic approach by simply calling scroller.startScroll(0,0,0,0);
to fix the bug. However, this doesn't have the nicest effect since it makes the calender reset its X position to 0 with a really quick scrolling animation . Unfortunately, the ``OverScroller` class provided in the Android SDK doesn't allow you to simply set an X value without scroll, which is annoying.
I will have another look at refining this, but I much rather fix the problem than have it perfect.
from compactcalendarview.
Changes are in master, will be released in the next day.
from compactcalendarview.
Re-opening until I actually release a new version so other people can see the issue.
from compactcalendarview.
Available in version:
dependencies {
compile 'com.github.sundeepk:compact-calendar-view:1.8.0'
}
from compactcalendarview.
Related Issues (20)
- Creating CustomAdapter
- Swipe left and swipe right listener HOT 1
- Background color of abbreviations (weeks)
- Events from REST API
- Work on emulator but not on device
- One event on day : Big circle; multiple event on a day : Big circle + little dot
- Can I use another fonts?
- How to select more days and disable others days tap? How to enable tap only on selected days
- error with add event function
- Color description bar
- error: failed linking references.
- error: resource android:attr/lStar not found.
- using talkback
- Adding Events to CompactCalendar from api call
- Clear Selection
- How to remove the selected current date background when month is scrolled?
- How to present only 1 week ?
- How to pass Calendar as argument?
- Issue
- Events not showing in some android devices api level 33
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compactcalendarview.