Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用设置下个月的事件https://github.com/alamkanak/Android-Week-View?_Java_Android - Fatal编程技术网

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

Java 如何使用设置下个月的事件https://github.com/alamkanak/Android-Week-View?,java,android,Java,Android,我正在使用,创建下个月事件是不可接受的。 这是我们获取当月事件的方法 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 retrofi

我正在使用,创建下个月事件是不可接受的。 这是我们获取当月事件的方法

 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/
公共列表