1
BEGIN:VEVENT
DTSTART;TZID=America/Los_Angeles:20151116T123000
DTEND;TZID=America/Los_Angeles:20151116T140000
EXDATE;TZID=America/Los_Angeles:20160215T123000
EXDATE;TZID=America/Los_Angeles:20160530T123000
EXDATE;TZID=America/Los_Angeles:20160704T123000
EXDATE;TZID=America/Los_Angeles:20160905T123000
EXDATE;TZID=America/Los_Angeles:20170220T123000
EXDATE;TZID=America/Los_Angeles:20170529T123000
RRULE:FREQ=WEEKLY;BYDAY=MO
DTSTAMP:20161007T103007Z
UID:[email protected]
CREATED:20151116T002427Z
DESCRIPTION:
LAST-MODIFIED:20160829T190451Z
LOCATION:
SEQUENCE:2
STATUS:CONFIRMED
SUMMARY:iOS Today
TRANSP:OPAQUE
END:VEVENT
私はICSを解析するライブラリhttps://github.com/alamkanak/Android-Week-Viewとこのライブラリhttps://github.com/mangstadt/biweeklyを使用してAndroidアプリのためcalenderView
を構築しようとしています。しかし、例のように、再発のあるイベントを作成する際に問題が発生しています。再発隔週ライブラリ
protected TreeMap<Integer,TreeMap<Integer,List<WeekViewEvent>>> doInBackground(String... params) {
ICalendar ical = Biweekly.parse(params[0]).first();
List<VEvent> le = ical.getEvents();
for(VEvent ev: le){
Calendar startTime = Calendar.getInstance();
startTime.setTimeInMillis(ev.getDateStart().getValue().getTime());
if(ev.getRecurrenceRule()!=null){
//Don't know what do I do here
}
int year = startTime.get(Calendar.YEAR);
int month = startTime.get(Calendar.MONTH);
//Log.v("Calendar",year+" Ano " + month +" Mes");
Calendar endTime = Calendar.getInstance();
if(ev.getDateEnd()==null){
continue;
}
endTime.setTimeInMillis(ev.getDateEnd().getValue().getTime());
WeekViewEvent we = new WeekViewEvent(0,ev.getSummary().getValue(),startTime,endTime);
if(eventos.get(we.getStartTime().get(Calendar.YEAR))==null){
TreeMap<Integer,List<WeekViewEvent>> as = new TreeMap<>();
List<WeekViewEvent> listEv = new ArrayList<>();
listEv.add(we);
as.put(we.getStartTime().get(Calendar.MONTH),listEv);
eventos.put(we.getStartTime().get(Calendar.YEAR),as);
}
else {
TreeMap<Integer, List <WeekViewEvent>> as = eventos.get(we.getStartTime().get(Calendar.YEAR));
if(as.containsKey(we.getStartTime().get(Calendar.MONTH))){
as.get(we.getStartTime().get(Calendar.MONTH)).add(we);
}else {
List<WeekViewEvent> listEv= new ArrayList<>();
listEv.add(we);
as.put(we.getStartTime().get(Calendar.MONTH),listEv);
}
}
}
return eventos;
}
助けていただければ幸いです。