Giter Site home page Giter Site logo

Comments (2)

alamkanak avatar alamkanak commented on May 7, 2024

Currently the week view does not provide a ready-made solution for async event loading. But there is a simple hack. Use the following code to achieve what you want.

@Override
public List onMonthChange(int newYear, int newMonth) {
    // Populate the week view with some events.
    List events = new ArrayList();

    // Fetch events for the date user selected.
    fetchEventsinBackground();
}

// Callback when fetchEvents finishes.
public void setEventList(Activity activity, final List eventModels) {

    // Hide the progress dialog.
    if(mProgressDialog != null && mProgressDialog.isShowing()) {
        mProgressDialog.dismiss();
    }

    // Refresh the week view.
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            // Store the returned events in a global variable for later use.
            mEventModels = eventModels;

            // This line will trigger the method 'onMonthChange()' again.
            mWeekView.notifyDatasetChanged();
        }
    });
}

@Override
public List<WeekViewEvent> onMonthChange(int year, int month) {
    // TODO Be sure to check if the variables year and month equals the year and month of the events of mEventModels.
    return getWeekViewEventsFromEventModels(mEventModels);
}

from android-week-view.

shalinipk avatar shalinipk commented on May 7, 2024

Thank you for your prompt response.
Java doesn't support 2 methods with same signature, so I can't have something like this in the same class:

@OverRide
public List onMonthChange(int year, int month) {
// TODO Be sure to check if the variables year and month equals the year and month of the events of mEventModels.
return getWeekViewEventsFromEventModels(mEventModels);
}
@OverRide
public List onMonthChange(int newYear, int newMonth) {
// Populate the week view with some events.
List events = new ArrayList();

// Fetch events for the date user selected.
fetchEventsinBackground();

}
If mWeekView.notifyDatasetChanged(); triggers onMonthChange() again, then it results in an infinite loop with fetchEventsinBackground() being called again & again!

Is there a better way out ? Thanks for all the help!

from android-week-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.