Giter Site home page Giter Site logo

goToDate about android-week-view HOT 17 CLOSED

alamkanak avatar alamkanak commented on May 8, 2024
goToDate

from android-week-view.

Comments (17)

Hugo-Pereira avatar Hugo-Pereira commented on May 8, 2024

bump
got the same problem, goToDate isn't working

from android-week-view.

rincyrose avatar rincyrose commented on May 8, 2024

Got same problem. goToDate is not working as expected.

from android-week-view.

akashdev1 avatar akashdev1 commented on May 8, 2024

same problem.. Goto works only for date within present month.. other month it wont work.. plz fix

from android-week-view.

Hugo-Pereira avatar Hugo-Pereira commented on May 8, 2024

That is weird, with me it doesn't work, even for the current month.
Also, I made it work by multiplying the dateDifference with a value, but that only "works" for devices with the same screen.

Unfortunatelly I don't have enough time to go through the code and try to find out what the real problem is. One thing is for sure though, the width is being calculated wrongly

from android-week-view.

Hugo-Pereira avatar Hugo-Pereira commented on May 8, 2024

Hi folks!

I was able to 'solve' the issue through a work around. I am calling init every in the goToDate method.

  1. replace the call to init() in the constructor with this
     mToday = Calendar.getInstance();
        mToday.set(Calendar.HOUR_OF_DAY, 0);
        mToday.set(Calendar.MINUTE, 0);
        mToday.set(Calendar.SECOND, 0);
        init();
  1. delete the code that sets the mToday variable in the init() method
  2. replace the goToDate method with this one:
  public void goToDate(Calendar date) {

        mToday = date;
        init();
}
  1. replace the two occurences of
boolean sameDay = isSameDay(day, mToday);

with

boolean sameDay = isSameDay(day, Calendar.getInstance());

Not pretty, but it does the job.

from android-week-view.

akashdev1 avatar akashdev1 commented on May 8, 2024

where is method edit()??? can u share the work around library? that's working for you..

from android-week-view.

Hugo-Pereira avatar Hugo-Pereira commented on May 8, 2024

Sorry, I meant init!

It is easy enough to apply the work around, don't think I should share it...

from android-week-view.

akashdev1 avatar akashdev1 commented on May 8, 2024

when i call init(date) in method goToDate method i get this error -->The method init() in the type WeekView is not applicable for the arguments (Calendar)

from android-week-view.

Hugo-Pereira avatar Hugo-Pereira commented on May 8, 2024

Sorry, I was still changing the fix and copy pasted the wrong version.

I edited my post again, it should be alright now.

I might make a pull request because I did other fixes, but it will take time because I will have to trim out the changes I made to best fit my project.

from android-week-view.

akashdev1 avatar akashdev1 commented on May 8, 2024

Thanks for the response. i did exactly has you instructed but hard luck it dint work. :-(

from android-week-view.

entropitor avatar entropitor commented on May 8, 2024

I need to check on this, but when I was hacking on the library, I think I fixed it when adding some brackets to https://github.com/alamkanak/Android-Week-View/blob/master/library/src/main/java/com/alamkanak/weekview/WeekView.java#L1204

changing:

int dateDifference = (int) (date.getTimeInMillis() - today.getTimeInMillis()) / (1000 * 60 * 60 * 24);

to

int dateDifference = (int) ((date.getTimeInMillis() - today.getTimeInMillis()) / (1000 * 60 * 60 * 24));

I'll soon be working some more on the library, and if this is the solution, I will make a PR (if nobody has done it yet by then)

from android-week-view.

entropitor avatar entropitor commented on May 8, 2024

I checked it now, that solves the problem indeed. I'm currently playing with some other stuff, I'll make a PR after that's done.

from android-week-view.

entropitor avatar entropitor commented on May 8, 2024

@alamkanak This problem should be fixed and this issue can be closed.

from android-week-view.

Hugo-Pereira avatar Hugo-Pereira commented on May 8, 2024

this doesn't work for me.
I checked and mWidthPerDay is 0 when the goToDate is called

edit: apparently I am calling goToDate too soon

from android-week-view.

entropitor avatar entropitor commented on May 8, 2024

@Hugo-Pereira my PR #53 will fix that

from android-week-view.

alamkanak avatar alamkanak commented on May 8, 2024

Problem fixed. See #69

from android-week-view.

 avatar commented on May 8, 2024

Do a single and very simple change:

Replace this
mRefreshEvents = true;

with
mRefreshEvents = false;

Method goToDate(Calendar date) should looks like:

public void goToDate(Calendar date) {
    mScroller.forceFinished(true);
    date.set(Calendar.HOUR_OF_DAY, 0);
    date.set(Calendar.MINUTE, 0);
    date.set(Calendar.SECOND, 0);

    mRefreshEvents = false;

    Calendar today = Calendar.getInstance();
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);

    int dateDifference = (int) (date.getTimeInMillis() - today.getTimeInMillis()) / (1000 * 60 * 60 * 24);
    mCurrentOrigin.x = - dateDifference * (mWidthPerDay + mColumnGap);


    invalidate();
}

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.