thellmund / android-week-view Goto Github PK
View Code? Open in Web Editor NEWThis project forked from alamkanak/android-week-view
Display highly customizable calendar views in your Android app
License: Apache License 2.0
This project forked from alamkanak/android-week-view
Display highly customizable calendar views in your Android app
License: Apache License 2.0
1 - Is possible to show lines in the half hours? 0:30, 1:30, 2:30...
2 - Is possible to define the start and end hours? 8am - 8pm
Thanks
Setting horizontalFlingEnabled
to false has no effect. Regardless of what you set, you can still fling the view. My understanding is that this setting would prevent you from scrolling multiple screens at once, but still allow you to scroll on screen at a time.
EDIT: Look at comments because there is a real bug.
When you rotate your device WeekView goes to today. Is there an option to prevent WeekView from this? Should I do it manually? In my opinion it is a bug and it shouldn't goes to today automatically.
Steps to reproduce:
Currently the builders use Calendar instances, which are not great to work with. I can see that internally they immediately convert to jsr310 objects. If you could expose those objects on the builder it would be helpful for cleaning up my APIs. Ditto providing a month change listener that takes those types.
When MonthChangeListener.onMonthChange is called, it appears to be receiving the wrong startDate and endDate (they are for the next month).
The error is in MonthLoader.onLoad.
final int year = periodIndex / 12;
final int month = periodIndex % 12 + 1;
final Calendar startDate = DateUtils.withTimeAtStartOfDay(today());
startDate.set(Calendar.YEAR, year);
startDate.set(Calendar.MONTH, month);
startDate.set(Calendar.DAY_OF_MONTH, 1);
final int maxDays = startDate.getActualMaximum(Calendar.DAY_OF_MONTH);
final Calendar endDate = DateUtils.withTimeAtEndOfDay(today());
endDate.set(Calendar.YEAR, year);
endDate.set(Calendar.MONTH, month);
endDate.set(Calendar.DAY_OF_MONTH, maxDays);
final List<WeekViewDisplayable<T>> displayableItems =
onMonthChangeListener.onMonthChange(startDate, endDate);
It is my understanding that startDate.set(Calendar.Month, month)
is 0 indexed, so final int month = periodIndex % 12 + 1;
should actually be final int month = periodIndex % 12;
.
Hello!
Firstly, thank you @thellmund for maintaining this library.
I found a bug connected with daylight saving time change.
31.03.2019 Poland changed time to DST (from 02:00 to 03:00) and I observed that time column contains two 03:00 hours. If system clock is set to 31.03.2019 all days have this bug:
I would be very grateful if you could fix it.
Hi,
There is an error in the XML layout sample in the README :
app:noOfVisibleDays="3"
instead of
app:numberOfVisibleDays="3"
It is implemented referring to the sample AsyncActivity.
If you scroll to more than one month before and after the initial display month, onMonthChange is called multiple times, and the movement seems strange.
https://github.com/thellmund/Android-Week-View/blob/develop/sample/src/main/java/com/alamkanak/weekview/sample/AsyncActivity.kt#L101
Is there a bug in setMonthChangeListener?
Hi,
It looks like there is some problem with the goToDate()
function from the WeekView class. The point is that the function after receiving the date as Calendar type does not go to it.
For example:
It is the date 9/05/2019. I would like to go to the date 29/08/2021. After calling the goToDate()
method, only the day changes. The year does not change at all, and the month only when it precedes or is next after the current month. In the case of May, the month can be changed only for April and June, and for no other. My guess is that this bug is on the library side. If you can find and fix it, that's great. If you need a more detailed description, I can prepare a simple application that illustrates this problem :)
Hello,
is there some way I can get the WeekView to snap to the first day of the week when scrolling horizontally?
It should look like a paged view with one week per page.
weekView.setDateTimeInterpreter(new DateTimeInterpreter() {
@OverRide
public String interpretDate(Calendar date) {
SimpleDateFormat weekdayNameFormat = new SimpleDateFormat("EEE", Locale.getDefault());
String weekday = weekdayNameFormat.format(date.getTime());
SimpleDateFormat format = new SimpleDateFormat(" d/MMM", Locale.getDefault());
return weekday.toUpperCase() + format.format(date.getTime());
}
@Override
public String interpretTime(int hour) {
if (hour == 24) hour = 0;
if (hour == 0) hour = 0;
return hour + ":00";
}
});
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(dateSelected);
weekView.goToDate(calendar);
What is wrong? It is not scrolling do dateSelected, can you help me?
If the event title is longer than the event chip, it is currently truncated. As space is precious in a calendar view, not truncating the title seems like a better option.
config.drawingConfig.currentOrigin.x % config.totalDayWidth != 0f
isn't correct anymore
One of both values gets wrong calculated
also the horizontal fling seems to missplace the entitys
When the library clones and modifies WeekViewEvent objects for events that span multiple days, the cloned event will not have it's data property set. When the user then taps the event, the library will throw an exception.
The following function is responsible for this:
List<WeekViewEvent> splitWeekViewEvents() {
if (!isSameDay(clonedEndTime)) {
clonedEndTime = (Calendar) startTime.clone();
clonedEndTime.set(Calendar.HOUR_OF_DAY, 23);
clonedEndTime.set(Calendar.MINUTE, 59);
WeekViewEvent<T> event1 = new WeekViewEvent<>(id, title, startTime, clonedEndTime, location, isAllDay);
event1.setColor(color);
events.add(event1);
// Add other days.
Calendar otherDay = (Calendar) startTime.clone();
otherDay.add(Calendar.DATE, 1);
while (!DateUtils.isSameDay(otherDay, this.endTime)) {
Calendar overDay = (Calendar) otherDay.clone();
overDay.set(Calendar.HOUR_OF_DAY, 0);
overDay.set(Calendar.MINUTE, 0);
Calendar endOfOverDay = (Calendar) overDay.clone();
endOfOverDay.set(Calendar.HOUR_OF_DAY, 23);
endOfOverDay.set(Calendar.MINUTE, 59);
WeekViewEvent<T> eventMore = new WeekViewEvent<>(id, title, overDay, endOfOverDay, location, isAllDay);
eventMore.setColor(color);
events.add(eventMore);
// Add next day.
otherDay.add(Calendar.DATE, 1);
}
// Add last day.
Calendar startTime = (Calendar) this.endTime.clone();
startTime.set(Calendar.HOUR_OF_DAY, 0);
startTime.set(Calendar.MINUTE, 0);
WeekViewEvent<T> event2 = new WeekViewEvent<>(id, title, startTime, this.endTime, location, isAllDay);
event2.setColor(color);
events.add(event2);
} else {
events.add(this);
}
return events;
}
Specifically, this way of cloning WeekViewEvents causes null values for the data property: WeekViewEvent<T> eventMore = new WeekViewEvent<>(id, title, overDay, endOfOverDay, location, isAllDay);
Can easily be reproduced by modifying one of the events in the sample project to span multiple days and then tapping on the event.
Do you know how to set the color of a single event (rectangle in the timeline) on the XML side? It is possible to implement this on the Kotlin side, but I would rather do it on the XML layout side. I think that may be 'defaultEventColor', but it doesn't work.
When adding an event that starts at 2018-11-21T:00 and ends at 2018-11-21T00:00, the library does not draw a proper event rect and thus, the event will not be visible. I fixed this issue in the Quivr fork but it was never merged as it is no longer maintained.
Can I change the font of all the textviews?
Can I create custom event chip ? Like in listview, I create the view which will be in list !
Is this not the correct gradle implementation?
I want to set a bordered background as the background of the event.
Is it possible to achieve it?
Background is white and border color is specified.
There was a similar issue.
alamkanak#397
Thank you.
Switching between views (e.g. from week to day view) resets WeekView to the current date. Instead, it should remain at the first visible day.
I was thinking that notifyDataSetChanged()
notify WeekView
that it should invoke onMonthChange
method but... no. I'm updating my events List and calling notifyDataSetChanged()
but it does nothing, onMonthChange()
which should load events isn't called. Should I invoke onMonthChange()
manually when I want to update events?
This method is working fine on last release version but not in latest commit(s).
I am trying to add an event programatically, but I dont get to refresh the calendar. This is my code:
override fun onMonthChange(startDate: Calendar, endDate: Calendar): List<WeekViewDisplayable> {
events = mDatabase!!.getEventsInRange(startDate, endDate)
return events!!
}
override fun onEmptyViewClicked(time: Calendar) {
val hour = String.format(Locale.getDefault(), "%02d:%02d",
time.get(Calendar.HOUR_OF_DAY),
time.get(Calendar.MINUTE))
val event = Event(System.currentTimeMillis(),
"Event: $hour",
time,
endTime,
"",
ContextCompat.getColor(context, R.color.colorPrimary),
false)
events?.add(event)
weekView?.notifyDataSetChanged()
}
When I have a layout file with app:numberOfVisibleDays="1"
for portrait and a second file with app:numberOfVisibleDays="7"
for landscape, when I switch orientations on my device, the actual number of visible days remains whatever it was to begin with. Expected behavior is that for a given configuration, the xml is always used if it exists.
Stepping through the debugger it appears that the saved instance state is overwriting the value passed from xml.
I have an activity (containing the week view) that quickly checks for authentication, and, if unauthenticated, pops another activity over the current one.
When the new activity pops and then closes, the calendar is put through a very quick save/restore state cycle before the viewState
is completely initialized (i.e. before firstVisibleDay
is set to anything).
onRestoreInstanceState
needs to handle the case of a null firstVisibleDay
. Other methods safely handle the null case for this property, which makes me think this was just a small oversight.
Presently, in this case, toCalendar
throws a kotlin NPE. Using v3.4.2.
Hi, I am trying to implement a function that adds a new event to the calendar. I redirect to a new layout page where I can input some information about the event. After finishing input data, I create a new apiEvent
object and redirect back to the calendar page using putExtra()
. Then I add this new event to the events
in getEventsInRange
of FakeEventsDatabase
. But I always get 3 repeated events showing in the calendar view. Could you give me some suggestions about how to solve this?
I've noticed that this fork has an issue with showing the next page while scrolling to the next day. Having set the amount of visible days to 1, when I scroll to the next day, the next day page remains blank until scrolling has finished. I'm guessing this is happening because the next page isn't loaded in advance?
i use Android-Week-View in fragment. when Android-Week-View is initialized, setMonthChangeListener() is called three times。here is my code.
`@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view=inflater.inflate(R.layout.fragment_data, container, false);
weekView=view.findViewById(R.id.weekView);
if (weekView!=null){
weekView.setMonthChangeListener(new MonthChangeListener<CalendarItem>() {
@NotNull
@Override
public List<WeekViewDisplayable<CalendarItem>> onMonthChange(Calendar calendar, Calendar calendar1) {
return DataUtil.getDataList();
}
});
}
System.out.println("+++++++++++++");
weekView.setMinDate(DateUtil.getNowDate());
System.out.println(DateUtil.getNowDate().getTime());
weekView.setMaxDate(DateUtil.getAfterDate(5));
System.out.println(DateUtil.getAfterDate(5).getTime());
weekView.setEventTextColor(Color.BLACK);
return view;
}`
If columnGap has value and I have 4 o more allDay events, no event is shown below the day.
Also, if columngap has value, a space to the right of allDay events and below the date is shown.
It's possible detect when Weekview is scrolling and when the scroll has finished?
I want load the events when the day changes. And I want prevent multiple calls with fast scroll
Hi.
After days of surfing, I found your code.
What I want is really simple. I want to show a weekly plan in a week view. The plan only changes every year so there is no need to show other dates. Also, events will be added from database and the user should not be able to add a new event.
Can you help me with this?
When I give dp to columnGap, I can not click on the right blank space to create a new event. This is a bug or not?
This functionality is very useful to create events at the same time, but it can not be used
It would be nice to have a label beside the now line (in the time column) that shows the current time.
When sliding the "hight" seekbar far to the left the App will crash
The ConstraintActicity was Introduced in #24
Probably com.alamkanak.weekview.BackgroundGridDrawer.createHourLines(BackgroundGridDrawer.kt:25)
2019-02-13 23:42:51.647 14250-14250/com.alamkanak.weekview E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.alamkanak.weekview, PID: 14250
java.lang.ArrayIndexOutOfBoundsException: length=32; index=32
at com.alamkanak.weekview.BackgroundGridDrawer.drawHourLines(BackgroundGridDrawer.kt:78)
at com.alamkanak.weekview.BackgroundGridDrawer.drawGrid(BackgroundGridDrawer.kt:40)
at com.alamkanak.weekview.BackgroundGridDrawer.draw(BackgroundGridDrawer.kt:21)
at com.alamkanak.weekview.WeekView.onDraw(WeekView.java:151)
at android.view.View.draw(View.java:20366)
at android.view.View.updateDisplayListIfDirty(View.java:19241)
at android.view.View.draw(View.java:20094)
at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
at android.support.constraint.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
at android.view.View.updateDisplayListIfDirty(View.java:19232)
at android.view.View.draw(View.java:20094)
at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
at android.view.View.updateDisplayListIfDirty(View.java:19232)
at android.view.View.draw(View.java:20094)
at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
at android.view.View.updateDisplayListIfDirty(View.java:19232)
at android.view.View.draw(View.java:20094)
at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
at android.view.View.updateDisplayListIfDirty(View.java:19232)
at android.view.View.draw(View.java:20094)
at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
at android.view.View.updateDisplayListIfDirty(View.java:19232)
at android.view.View.draw(View.java:20094)
at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
at android.view.View.draw(View.java:20369)
at com.android.internal.policy.DecorView.draw(DecorView.java:781)
at android.view.View.updateDisplayListIfDirty(View.java:19241)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:690)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:696)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:805)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3515)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3312)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2681)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1633)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7786)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1004)
at android.view.Choreographer.doCallbacks(Choreographer.java:816)
at android.view.Choreographer.doFrame(Choreographer.java:751)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:990)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
OnePlus 5T
Android Pie 9
I have a question about this lib.
I'm working on an app that has a calendar feature, but instead of working on a "weekly fashion", it's supposed to display day by day, but here's the catch: It's supposed to do that for multiple people.
So instead of having the days of the week on the columns, I would have to display user names and pictures, and each row would correspond to their daily schedules.
Is is possible to use this lib on this scenario? Or is it too tied to displaying only the days of the week?
Thanks for being responsive on my other issues.
I'm trying to use this in a big corporate app that'll require RTL support. I'm not an expert on RTL for calendars, but I'm thinking that it should obey the system's locale in that regard in two specific ways that are immediately visible.
First, in an RTL locale I'd expect the time label column to show up at the start
of the layout (so the right). Second, I'd expect the individual events' labels to appear start-aligned.
I'm not sure if RTL should mess with the directionality of the dates on scrolling... but something else to think about.
Currently, when including the WeekView in a layout, it can not be rendered by AndroidStudio (in the layout preview) and throws a ClassNotFoundException
. This is because it uses classes from com.jakewharton.threetenabp
. To make these classes available for the layout preview, it would help to change the type of this dependency from implementation
to api
, but I don't know if it's the best way.
The full day event has a rectangle which can have only a single line of data inside, however if it has data which cannot be fit into one line, it draws the text in the next line which is out of the
bounds of the drawn rectangle
In this screenshot, the full title of the event is "Women's day ramp walk planning"
the title overflows the drawn bounds of the rectangle.
Same case when there is a location which cannot be fit into the line
Say that I want to block the user for looking at past events, but I don't want to use the static view. Is it possible to block scrolling to a past time, but keep scrolling to a future one?
Could you update the notifyDataSetChanged on your jitpack so I can continue to use your library. Thank You, really love what you have done with the library.
The event location is currently displayed right after the event title. Instead (or maybe as another option?), it should be possible to display it below the event title, provided that there is enough space.
Hello,
can each event have a different color? I have seen that it can in the develop branch. Can it be done in the master branch? If can not master, you can make a merge of the 2 branches and include this functionality?
How can I include the develop branch in Gradle?
Thank you
This library has changed API (in 3.0) but the documentation of new API isn't anywhere.
From what I found, this seems to be most actively maintained. As such, documentation of any level (thorough or simple list of API methods) would be very helpful.
Update the documentation with all the attributes and methods added since the last release.
Allow to limit the time range that is displayed in WeekView. For instance, one might wish to display only the hours between 10am and 8pm.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.