Search in sources :

Example 1 with MyJsonService

use of com.alamkanak.weekview.sample.apiclient.MyJsonService in project Android-Week-View by alamkanak.

the class AsynchronousActivity method onMonthChange.

@Override
public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) {
    // downloaded using retrofit, visit http://square.github.io/retrofit
    if (!calledNetwork) {
        RestAdapter retrofit = new RestAdapter.Builder().setEndpoint("https://api.myjson.com/bins").build();
        MyJsonService service = retrofit.create(MyJsonService.class);
        service.listEvents(this);
        calledNetwork = true;
    }
    // Return only the events that matches newYear and newMonth.
    List<WeekViewEvent> matchedEvents = new ArrayList<WeekViewEvent>();
    for (WeekViewEvent event : events) {
        if (eventMatches(event, newYear, newMonth)) {
            matchedEvents.add(event);
        }
    }
    return matchedEvents;
}
Also used : MyJsonService(com.alamkanak.weekview.sample.apiclient.MyJsonService) ArrayList(java.util.ArrayList) RestAdapter(retrofit.RestAdapter) WeekViewEvent(com.alamkanak.weekview.WeekViewEvent)

Aggregations

WeekViewEvent (com.alamkanak.weekview.WeekViewEvent)1 MyJsonService (com.alamkanak.weekview.sample.apiclient.MyJsonService)1 ArrayList (java.util.ArrayList)1 RestAdapter (retrofit.RestAdapter)1