Giter Site home page Giter Site logo

Comments (11)

spartacusrex99 avatar spartacusrex99 commented on July 29, 2024 1

There is a much easier fix..

Switch OnSingleTapConfirmed for onSingleTapUp..

OnSingleTapConfirmed waits to make sure you are not double clicking.

from compactcalendarview.

SundeepK avatar SundeepK commented on July 29, 2024

I'll have to run the example that's shipped with the code to test things out when I get the time, but what version are you running? Are you on the latest?

from compactcalendarview.

broakenmedia avatar broakenmedia commented on July 29, 2024

Yep, latest!

from compactcalendarview.

SundeepK avatar SundeepK commented on July 29, 2024

Ok thanks. There is a slight bit of lag clicking days, it's something that I wanted to looks at for a while. There's some calculations that are running to find the correct day that was click. The only things I can do is run some android code profiling commands to figure out where most of the cpu time is spent. I have a suspicion though that the calendar is being redrawn an extra time than needed. So instead of drawing once, it draws twice.

from compactcalendarview.

SundeepK avatar SundeepK commented on July 29, 2024

So after a little investigation and profiling, the code doesn't look like it's actually slow or drawing unnecessarily. However, I am using GestureDetector.SimpleOnGestureListener to listen for onSingleTapConfirmed event. Looking through android source code, basically, GestureDetectorCompat android will wait for some time until an event is considered a single tap event. This time is what you see as the lag (at least I think so).

As an experiment, you can move the code from onSingleTapConfirmed method to on down in the CompactCalendar class. You will see that the UI updates immediately. However, this causes other issues with scrolling and oddities with gesture detection.

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
           // Date onDateClicked = compactCalendarController.onSingleTapConfirmed(e);
           // invalidate();
           // if(listener != null){
           // listener.onDayClick(onDateClicked);
           // }
            return super.onSingleTapConfirmed(e);
        }

        @Override
        public boolean onDown(MotionEvent e) {
            Date onDateClicked = compactCalendarController.onSingleTapConfirmed(e);
            invalidate();
            if(listener != null){
                listener.onDayClick(onDateClicked);
            }
            return compactCalendarController.onDown(e);
        }

So the fix? Well I can see implementing custom gesture detection as one way of doing things without much thought. But I'll have to think about this a little bit :)

from compactcalendarview.

SundeepK avatar SundeepK commented on July 29, 2024

Thanks for the comment, I'll investigate this soon then.

from compactcalendarview.

yoavst avatar yoavst commented on July 29, 2024

@spartacusrex99 fix is great, but why isn't it integrated? your comment is from april.

from compactcalendarview.

SundeepK avatar SundeepK commented on July 29, 2024

@yoavst Mostly because I have been implementing other feature and enhacements. There is some pull request I want to merge before. Once that feature is merged I will have a look at this.

from compactcalendarview.

yoavst avatar yoavst commented on July 29, 2024

Thanks! Currently I'm not using this library, but I'll be happy to use this library for performance reason.

from compactcalendarview.

SundeepK avatar SundeepK commented on July 29, 2024

So good news, this has been fixed and will be merged some time this week. Will update once a new version is out.

from compactcalendarview.

SundeepK avatar SundeepK commented on July 29, 2024

Merged will release a new version some time in the next few days.

from compactcalendarview.

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.