Giter Site home page Giter Site logo

Comments (13)

masterofn1 avatar masterofn1 commented on July 29, 2024 1

@aKuriel make sure to check if the events are already rendered. As per my checking onmontchangelistener is being called three times.

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@aKuriel This seems to be an error on your side. Does it also happen when you run the demo app ?

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

it's always being called 3 times, for the period before the current period, for the current period and for the periode after the current period.

from android-week-view.

entropitor avatar entropitor commented on July 29, 2024

@khent04 Check the documentation at https://github.com/alamkanak/Android-Week-View/blob/ed450d8c68a82fa176d37140880a6c921c98c521/library/src/main/java/com/alamkanak/weekview/MonthLoader.java#L41

from android-week-view.

masterofn1 avatar masterofn1 commented on July 29, 2024

Hi @caske33 , yeaps.. Thanks to that but i already checked that couple of weeks ago. I am just responding to issue.
Maybe we should address that to him

from android-week-view.

entropitor avatar entropitor commented on July 29, 2024

Oops, indeed, sorry!

@aKuriel: check my previous comment

from android-week-view.

aKuriel avatar aKuriel commented on July 29, 2024

i have this code:


        final List<WeekViewEvent> events = new ArrayList<>();
        Calendar calendarStart = Calendar.getInstance(Locale.US);
        Calendar calendar = Calendar.getInstance(Locale.US);
        calendarStart.add(Calendar.HOUR_OF_DAY, -5);
        events.add(new WeekViewEvent(1, "Evento 1", calendarStart, calendar));

        // wvEventos is the WeekView
        wvEventos.setMonthChangeListener(new MonthLoader.MonthChangeListener() {
              @Override
              public List<? extends WeekViewEvent> onMonthChange(int newYear, int newMonth) {
                      return events;
              }
         });

As you can see events list is initialized out of onMonthChange interface, but still adding events 3 times to view.

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@aKuriel See the link caske posted above: https://github.com/alamkanak/Android-Week-View/blob/ed450d8c68a82fa176d37140880a6c921c98c521/library/src/main/java/com/alamkanak/weekview/MonthLoader.java#L41

You should only return the events that are part of the period, but you always return the same list and because the MonthChangeListener.onMonthChange() is always called 3 times (as documented in the link above), your events are added 3 times.

from android-week-view.

aKuriel avatar aKuriel commented on July 29, 2024

should to be a filter in the api side, something like:

if(events are not for this month){
    // dont add to calendar.
}

or

if(id of event already exists){
  // override event or skip adding event
}

a common use case it's to load first the whole events list, for example a query:

SELECT * FROM EVENTS WHERE BETWEEN start AND end;

with the current api we have to handle every interface method call:

if(myListItems are from this month){
 add event to list return;
}

to much work for something that should to be skipped.

or maybe i have not understanding the right implementation of this method, could you sir, please, explain me? i'm new with this api and excuse me if i don't understand so fast.

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@aKuriel The query you should use would be SELECT * FROM EVENT WHERE BETWEEN startOfTheMonth AND endOfTheMonth. This would solve your problem. This is not something the library should do, the library asks which events to draw for a certain month, then you have to return only the events of that month.

from android-week-view.

aKuriel avatar aKuriel commented on July 29, 2024

sure, we can do it in the api user side, i just giving my opinion, we can skip this validation part of previous current and next month, for a more comfortable use of api, you guys are doing a very good work, we are gonna be happy if your team can consider my suggest.
Regards.

from android-week-view.

jhoobergs avatar jhoobergs commented on July 29, 2024

@aKuriel This monthLoader is used for efficiency, events are only loaded when the user is actually looking at a date near the date of the event.

So i'm afraid we won't implement your suggestion.

from android-week-view.

aKuriel avatar aKuriel commented on July 29, 2024

just another opinion: this init way is ugly. thanks.

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.