如何使用https://github.com/alamkanak/Android-Week-View设置下个月的活动?

时间:2019-02-12 05:39:54

标签: java android

我正在使用library,因此不能创建下个月的活动。 这是我们获取当月事件的方法

 public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) {
    // Download events from network if it hasn't been done already. To understand how events are
    // downloaded using retrofit, visit http://square.github.io/retrofit
    //Here we will handle the http request to insert user to mysql db
    if (!calledNetwork) {
        RestAdapter retrofit = new RestAdapter.Builder().
                // setEndpoint("https://api.myjson.com/bins")
                        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;
}


/**
 * Checks if an event falls into a specific year and month.
 *
 * @param event The event to check for.
 * @param year  The year.
 * @param month The month.
 * @return True if the event matches the year and month.
 */
private boolean eventMatches(WeekViewEvent event, int year, int month) {
    return (event.getStartTime().get(Calendar.YEAR) == year && event.getStartTime().get(Calendar.MONTH) == month - 1)
            || (event.getEndTime().get(Calendar.YEAR) == year && event.getEndTime().get(Calendar.MONTH) == month - 1);
}

@Override
public void success(List<Event> events, Response response) {
    System.out.println("Response Is " + response.toString());
    Log.w("s wrapped in gson => ", new Gson().toJson(response));
    this.events.clear();
    for (Event event : events) {
        this.events.add(event.toWeekViewEvent());
    }
    getWeekView().notifyDatasetChanged();
}

@Override
public void failure(RetrofitError error) {
    error.printStackTrace();
    Toast.makeText(this, R.string.async_error, Toast.LENGTH_SHORT).show();
}
/*code o show eveents on calI/

我希望添加下个月的活动。请帮我创建下个月的活动。谢谢

0 个答案:

没有答案