Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tyczj/GoogleCalendarView
This project is meant for people who want to display a calendar view and show that there are events on certain days.
https://github.com/tyczj/GoogleCalendarView
Last synced: 3 months ago
JSON representation
This project is meant for people who want to display a calendar view and show that there are events on certain days.
- Host: GitHub
- URL: https://github.com/tyczj/GoogleCalendarView
- Owner: tyczj
- License: other
- Created: 2013-03-31T05:25:55.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-08T18:51:12.000Z (over 11 years ago)
- Last Synced: 2024-07-01T10:59:08.929Z (4 months ago)
- Language: Java
- Homepage:
- Size: 825 KB
- Stars: 166
- Watchers: 24
- Forks: 60
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: License.txt
Awesome Lists containing this project
README
ExtendedCalendarView
====================![image](https://github.com/tyczj/ExtendedCalendarView/raw/master/ExtendedCalendarView.png)
This project is meant for people who want to display a calendar view and show that there are events on certain days.
What I did was pull out the calendar view from Google's Calendar application found here. It is still a work in progress but the project should run. The example project pulls events from the google calendar provider and inserts them into the examples databasehttps://github.com/android/platform_packages_apps_calendar.
Implementation is not the easiest though as there is a lot to it but I hope to filter out stuff that is not needed to try to make it simpler
A quick run though of how to use it:
in your activity before you set the content view you need to create a Calendar Controller
public class MainActivity extends Activity implements EventHandler{
private CalendarController mController;@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);mController = CalendarController.getInstance(this);
setContentView(R.layout.cal_layout);
mController.registerEventHandler(R.id.cal_frame, (EventHandler) monthFrag);
mController.registerFirstEventHandler(0, this);
}
The put in the MonthByWeekFragment to your viewFragmentTransaction ft = getFragmentManager().beginTransaction();
monthFrag = new MonthByWeekFragment(System.currentTimeMillis(), false);
ft.replace(R.id.cal_frame, monthFrag).commit();
You also need to override handleEvent, this gets called when you click on a day on the calendar and gets called when you click on an event in the day view@Override
public void handleEvent(EventInfo event) {
if (event.eventType == EventType.GO_TO) {
// day selected on calendsr, start DayFragment to display the day that was clicked
this.event = event;
dayView = true;
FragmentTransaction ft = getFragmentManager().beginTransaction();
dayFrag = new DayFragment(event.startTime.toMillis(true),1);
ft.replace(R.id.cal_frame, dayFrag).addToBackStack(null).commit();
}if(event.eventType == EventType.VIEW_EVENT){
//TODO do something when an event is clicked
}
}
Calendar Content Provider
=========================To display events on the calendar I have build a content provider that the calendar uses which replicates how it is done in googles calendar app.
things that it needs is the start and end date in a milliseconds timestamp.those should go in the START and END columns of the database
values.put(CalendarProvider.END, endTimestamp));
values.put(CalendarProvider.START, startTimestamp);
You also need to get the julian start/end day from the timestamp like soint startDay = Time.getJulianDay(startTimestamp, TimeUnit.MILLISECONDS.toSeconds(tz.getOffset(startTimestamp)));
int endDay = Time.getJulianDay(endTimestamp, TimeUnit.MILLISECONDS.toSeconds(tz.getOffset(endTimestamp)));
the put them in the start day and end day columns of the databasevalues.put(CalendarProvider.START_DAY, startDay);
values.put(CalendarProvider.END_DAY, endDay);
The last thing you need in the database is the start/end time in minutes and put them in the start time and end time columnsvalues.put(CalendarProvider.START_TIME, startMin);
values.put(CalendarProvider.END_TIME, endMin);
Follow me on Google+
https://plus.google.com/107013202469298721562/posts