p-v / flexiblecalendar Goto Github PK
View Code? Open in Web Editor NEWA flexible android calendar
License: MIT License
A flexible android calendar
License: MIT License
Would it possible to add a function like that? Which selects a date given by year, month, day or by SelectedDateItem (SetSelectedDateTime(SelectedDateItem selectedDate)).
Or maybe it's the FlexibleCalendar#refresh() not working?
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.1.1'
compile 'com.p_v:flexiblecalendar:1.2.1'
}
private Map<Date,List<CustomEvent>> eventMap = new HashMap<>();
viewHolder.calendar.setEventDataProvider(new FlexibleCalendarView.EventDataProvider() {
@Override
public List<? extends Event> getEventsForTheDay(int year, int month, int day) {
return getEvents(year, month, day);
}
});
public List<CustomEvent> getEvents(int year, int month, int day){
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);
return eventMap.get(cal.getTime());
}
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
Log.e(LOG_TAG, "onLoadFinished");
switch (loader.getId()) {
case CALENDAR_EVENT_LOADER:
if (data != null && data.moveToFirst()) {
do {
String mainActivity = data.getString(COL_MAIN_ACTIVITY_TITLE);
String activity = data.getString(COL_ACTIVITY_TITLE);
String categoryName = data.getString(COL_CATEGORY_NAME);
String fieldContent = data.getString(COL_FIELD_CONTENT);
try {
Date date = DateFormat.getDateInstance().parse(fieldContent);
CustomEvent event = new CustomEvent(mainActivity, activity, categoryName, date, android.R.color.holo_blue_bright);
// Update eventMap with new event
List<CustomEvent> events = eventMap.get(date);
if (events == null) {
events = new ArrayList<>();
eventMap.put(date, events);
}
events.add(event);
} catch (ParseException e) {
e.printStackTrace();
}
} while (data.moveToNext());
Log.e(LOG_TAG, "refresh");
viewHolder.calendar.refresh();
viewHolder.calendar.refreshDrawableState();
}
break;
default:
break;
}
}
Code is in a Fragment and i'm using a LoaderManager.
Can you help me?
Is it possible to have events shown as a different color cell? I mean, if you have standard blue cells for example, when you have an event, just paint the whole cell red.
Is it possible?
EDIT: I don't really need events, any way that makes possible to inflate each cell with a different layout based on the date will help.
Called mutiple times please answer me ?
Looking at your values.xml, I saw state_dates such as REGULAR, TODAY, SELECTED, OUTSIDE_MONTH, etc, I was hoping to add a few new ones (such as PUBLIC HOLIDAY, etc).
Would it be sufficient to:
EventDataProvider
to the cell generation.int cellType
for CellState.PUBLIC_HOLIDAY during FlexibleCalendarView.CalendarView.getCellView()
(or getWeekdayCellView()? I'm a little confused about the difference between the two)Sorry if this has been asked before, but I was wondering what the most "correct" way of adding this would be.
Better, If you could add date range selection to this.
is not worked.. called lot of times
calendarView.setEventDataProvider(new FlexibleCalendarView.EventDataProvider() {
@OverRide
public List<?extends CustomEvent> getEventsForTheDay(int ye, int mo, int da)
{
There's a few issues I'm having with the new support library. First is when i perform calendarView.goToCurrentDay();
I get this error
Process: PID: 27352 java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 10000, found: 402 Pager id: ffffffff Pager class: class com.p_v.flexiblecalendar.MonthViewPager Problematic adapter: class com.antonyt.infiniteviewpager.InfinitePagerAdapter
The other issue I'm having is with calendarView.refresh()
which doesn't seem to be working anymore. It was working flawlessly until the new support lib broke the world ;) JK, any help or updates would be most gratefully appreciated!
To note as well when I page a few months to the right my events start to actually show in the calenderView. I'm not sure what to be looking for on this particular issue but I'm positive it's related to the new support library.
Contains environment information that clutters commits
I want to change background color of multiple dates based on a few conditions, is this possible using your library?
Hi. I can't set the calendar to specific month and year to display and disable scrolling. E.g. I want to display just one month without change it. How can I do that?
I'm attempting to add margin around a cell view to let the background show through between each week row (tried both Square and EventCount CellView's), and it appears that the android:layout_margin values are not respected. Ideally I'd like to make it look something like https://github.com/p-v/FlexibleCalendar/blob/master/demo/screenshot-4.jpg, but with no horizontal margin between the days.
After upgrading to support library 23.2, it has stopped refreshing the correct display after:
FlexibleCalendar.refresh()
or invalidate()
EventDataProvider.getEventsForTheDay()
no longer calledIt refreshes correctly once you select a date by clicking on it.
Hi.
Nice library.
My problem is, the 1 day of month is shown selected by default and this occurs when the month is changed. I am not able to disable this. I dont want the 1st day of month to be shown selected. Am I missing something?
Also, I wish to have multiple date selections, for that purpose i added a clicklistener to getCellView but the clicklistener is not working.
http://imgur.com/a/d6uKs
When clicking on the bottom "5" before clicking on a date within the current month, the following NPE occurs.
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.p_v.flexiblecalendar.entity.SelectedDateItem.equals(java.lang.Object)' on a null object reference at com.p_v.flexiblecalendar.MonthViewPagerAdapter.refreshUserSelectedItem(MonthViewPagerAdapter.java:210) at com.p_v.flexiblecalendar.FlexibleCalendarView$MonthChangeListener.onPageSelected(FlexibleCalendarView.java:326) at android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1939) at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:687) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:671) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:632) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:624) at com.antonyt.infiniteviewpager.InfiniteViewPager.setCurrentItem(InfiniteViewPager.java:48)
Hi there, just wondering if there is a way to have the calendar_data_cell_view.xml (the circle representing the selected day) to be circle (not oval) regardless of the size of the box representing the date.??
I suggest replacing this line:
eventPaint.setColor(getContext().getResources().getColor(e.getColor()));
with
eventPaint.setColor(ContextCompat.getColor(getContext(), e.getColor()));
Can you fix it?
E/AndroidRuntime: FATAL EXCEPTION: main
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1233)
at android.content.res.Resources.getColor(Resources.java:887)
at com.p_v.flexiblecalendar.view.CircularEventCellView.setEvents(CircularEventCellView.java:109)
at com.p_v.flexiblecalendar.FlexibleCalendarGridAdapter.drawDateCell(FlexibleCalendarGridAdapter.java:144)
at com.p_v.flexiblecalendar.FlexibleCalendarGridAdapter.getView(FlexibleCalendarGridAdapter.java:133)
at android.widget.AbsListView.obtainView(AbsListView.java:2344)
at android.widget.GridView.makeAndAddView(GridView.java:1433)
at android.widget.GridView.makeRow(GridView.java:361)
at android.widget.GridView.fillDown(GridView.java:302)
at android.widget.GridView.fillFromTop(GridView.java:437)
at android.widget.GridView.layoutChildren(GridView.java:1276)
at android.widget.AbsListView.onLayout(AbsListView.java:2148)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1695)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:122)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1192)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:814)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1187)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLa
Thanks for the nice Library.
@Pratyush Verma
Can you tell me when we select a day dot not shown there ?
please help me out
case BaseCellView.TODAY:
cellView.addState(BaseCellView.STATE_TODAY);
break;
case BaseCellView.SELECTED_TODAY:
case BaseCellView.SELECTED:
cellView.addState(BaseCellView.STATE_SELECTED);
break;
I'm trying to remember last selected date position of calendar which is working fine, but when user select date in previous month then next time when i try to set the same date calendar starts to malfunction.
Is there a way to disable touch selection for days? I want to enable selected state only for specific days
Can we have two kinds of day in two different types of calendar format into one cell ??
it may look like this:
I am showing green dot for the event. But for the today date event dot is not showing.
Also when I select some date. then white background will display on date and dot disappear.
I want to know how to show event dot for the selected date and today date.
I inflate each of my WeekdayCellView
with a layout like is shown in the code.
@Override
public BaseCellView getWeekdayCellView(int position, View convertView, ViewGroup parent) {
BaseCellView cellView = (BaseCellView) convertView;
if (cellView == null) {
LayoutInflater inflater = LayoutInflater.from(MaterialFullCalendar.this);
cellView = (BaseCellView) inflater.inflate(R.layout.fullcalendar_weekday_cell, null);
}
return cellView;
}
But when I run my app, the layout isn't filled correctly and some pixels are skipped. Notice that in the image below, the above blue is part of the Toolbar
and just below I have my FlexibleCalendar
widget.
Displaying events on days works fine if you know the dates beforehand, but when querying a new set of events, there is no way to refresh everything.
Hello,
Firstly thank you for awesome calendar view.
I want to populate list of events when a calendar is load, for that I need start and end date of calendar visible. How can I get that. ?
Ex:
calendarView.setWeekViewBackgroundResource(R.drawable.cell_orange_background);
the week day header part does not change.
Add an option to set the calendar week to start on Monday instead of Sunday. I have managed how to do that but you can do it better.
Calendar is showing only week labels view but not the date views. Im not getting where i have done wrong.
How to convert the month to weekview in the library...
i want to show instead of month to week only 7day in viewpager
If the layout is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.p_v.flexiblecalendar.FlexibleCalendarView
android:id="@+id/flexibleCalendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"/>
...
</LinearLayout>
It looks like:
But if I wrap it into ScrollView:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.p_v.flexiblecalendar.FlexibleCalendarView
android:id="@+id/flexibleCalendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"/>
...
</LinearLayout>
</ScrollView>
It looks like:
How can I prevent this issue without setting absolute size in dp to FlexibleCalendarView?
Maybe add a function that instead to go to current month, another that goes to the current day.
calendarView.setEventDataProvider(new FlexibleCalendarView.EventDataProvider() {
@OverRide
public List<?extends CustomEvent> getEventsForTheDay(int ye, int mo, int da)
{
Log.e("Month", "" + mo);
Log.e("Year", "" + ye);
return null;
}
});
This run more than 500 times..
even if i call flexibleCalendarView.selectDate() function, the events are show only after user interaction. I have a predefined list of events which should populate as soon as the calendar is created. I see you have done that in calendar 3 but I can't seem to make it work.
calendarView.setEventDataProvider(new FlexibleCalendarView.EventDataProvider() {
@Override
public List<? extends Event> getEventsForTheDay(int year, int month, int day) {
for (int i = 0; i < size; i++)
{
if(i<presentList.size()) {
if (year == 2016 && month == 9 && day == presentList.get(i)) {
List<CustomEvent> colorLst1 = new ArrayList<>();
colorLst1.add(new CustomEvent(R.color.present));
return colorLst1;
}
}
if(i<absentList.size())
{
if (year == 2016 && month == 9 && day == absentList.get(i)) {
List<CustomEvent> colorLst1 = new ArrayList<>();
colorLst1.add(new CustomEvent(R.color.absent));
return colorLst1;
}}
if(i<sickList.size()) {
if (year == 2016 && month == 9 && day == sickList.get(i)) {
List<CustomEvent> colorLst1 = new ArrayList<>();
colorLst1.add(new CustomEvent(R.color.sick));
return colorLst1;
}
}
}
return null;
}
});
Grey out or disable all the previous dates. Is there a way to do this ?
One way to do this : Add all the dates to an event and change the background, but this is not the optimal way!
Any idea otherwise?
When I try to use the " for " to put in several days with events , does not work.
For example:
calendarView.setEventDataProvider(new FlexibleCalendarView.EventDataProvider() {
@OverRide
public List<? extends Event> getEventsForTheDay(int year, int month, int day) {
return getEventColorList(year, month, day);
}
private List<? extends Event> getEventColorList(int year, int month, int day) {
int sdf;
do {
int joka = 0;
for (int jbf = 0; jbf < m_parts.size(); jbf++) {
if (datameio.getTime().after(m_parts.get(jbf).getDataInicio()) && datameio.getTime().before(m_parts.get(jbf).getDataFim()) || datameio.getTime().equals(m_parts.get(jbf).getDataInicio()) && datameio.getTime().before(m_parts.get(jbf).getDataFim()) || datameio.getTime().after(m_parts.get(jbf).getDataInicio()) && datameio.getTime().equals(m_parts.get(jbf).getDataFim())) {
joka++;
}
}
List<CalendarEvent> eventColors = new ArrayList<>();
int ano = datameio.get(Calendar.YEAR);
int mes =datameio.get(Calendar.MONTH);
int dia =datameio.get(Calendar.DAY_OF_MONTH);
if (year ==ano && month == mes && day ==dia ) {
for (int i = 0; i < joka; i++) {
eventColors.add(new CalendarEvent(android.R.color.holo_purple));
}
return eventColors;
}
datameio.add(Calendar.DATE, 1);
} while (datameio.before(datamaistarde));
return null;
}
});
is it possible t jump over to particular date in calendar ??
How can I change First day of the week?
after i update my android studio and change
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
when i use calendarview.refresh() it doesnt update the view. the events not appear in the calendar neither in the examples of the git.
Hi. Nice calendar. But I can't use it in ScrollView or ListView. It shows just days of week
not sure a good way to handle this, but would be great to be able to use this tool
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.