Events not showing

2 posts, 0 answers
  1. Paul
    Paul avatar
    3 posts
    Member since:
    Feb 2015

    Posted 02 Mar 2015 Link to this post

    I'm trying to create an event based on the code in the example. In my generateEvents call, I pass in a fromdate that I format and turn in to a calendar object. I then put this from and to date in the eventitem object and add it to the events array. I then notifydatachanged and nothing happens. The event doesn't show on my calendar. What am I doing wrong?


    :
    calendarView.getEventAdapter().setEvents(generateEvents());
    calendarView.notifyDataChanged();
            
    return root;
        }
        

        
    private ArrayList<Event> generateEvents() {
            ArrayList<Event> events = new ArrayList<Event>();

            Calendar c = getToday();
            String fromdate = "2015-02-17T18:00:00";
            String todate = fromdate;
           
            c = (stringToDateCalendar(fromdate));
            c.set(Calendar.HOUR_OF_DAY, 20);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MILLISECOND, 0);
            long start = c.getTimeInMillis();
           
            c = (stringToDateCalendar(todate));
            c.set(Calendar.HOUR_OF_DAY, 20);
            c.set(Calendar.MINUTE, 1);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MILLISECOND, 0);
            long end = c.getTimeInMillis();
           
            String desc = "booster stuff";
           
            Event eventitem = new Event(desc, start, end);
            eventitem.setEventColor(blueevent);
            events.add(eventitem);
            
            Collections.sort(events, new Comparator<Event>() {
                @Override
                public int compare(Event event, Event event2) {
                    return (event.getStartDate() < event2.getStartDate()) ? -1 : (event.getStartDate() > event2.getStartDate()) ? 1 : 0;
                }
            });
            
            return events;
    }

    private static Calendar stringToDateCalendar(String date1) {

       SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
       java.util.Date d1 = null;
       Calendar tdy1;
       
       try {
           d1 = form.parse(date1);
       } catch (java.text.ParseException e) {
           e.printStackTrace();
       }
       tdy1 = Calendar.getInstance();
       tdy1.setTime(d1);
       return tdy1;
    }

    private int getColor(String color)
    {
    int mycolor=0;
    if (color.toUpperCase().equals("BLUE"))
    {
    mycolor = blueevent;
    }
    if (color.toUpperCase().equals("GREEN"))
    {
    mycolor = greenevent;
    }
    return(mycolor);
    }
  2. Antony Jekov
    Admin
    Antony Jekov avatar
    88 posts

    Posted 04 Mar 2015 Link to this post

    Closing as duplicate of ticket 912059.

    Regards,
    Antony Jekov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
Back to Top