Code Monkey home page Code Monkey logo

Comments (6)

hameno avatar hameno commented on September 24, 2024

Until this is fixed, you can do the following to prevent this behaviour:

final SlidingUpPanelLayout layout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
layout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {

            private AtomicBoolean mPanelCollapsed = new AtomicBoolean(true);

            @Override
            public void onPanelSlide(final View panel, final float slideOffset) {
            }

            @Override
            public void onPanelExpanded(final View panel) {
                if (mPanelCollapsed.compareAndSet(true, false)) {
                    LOG.trace("onPanelExpanded");
                }
            }

            @Override
            public void onPanelCollapsed(final View panel) {
                if (mPanelCollapsed.compareAndSet(false, true)) {
                    LOG.trace("onPanelCollapsed");
                }
            }
        });

from androidslidinguppanel.

josomers avatar josomers commented on September 24, 2024

Good call! I implemented your solution in my personal dev branch.

from androidslidinguppanel.

tokudu avatar tokudu commented on September 24, 2024

The first thing you mention is actually working as intended. onPanelExpanded is supposed to get called every time the panel is full expanded (i.e. even after it snaps back). The second thing is probably a bug.

from androidslidinguppanel.

iriina avatar iriina commented on September 24, 2024

About the second problem (with the two calls initialState -> finalState), from what I've seen in the debugger, I think what happens is:

public boolean onTouchEvent(MotionEvent ev) {
       ....
       mDragHelper.processTouchEvent(ev);
       ..... 

       case MotionEvent.ACTION_UP: {
       // if isDragViewHit, expand/anchor/collapse the panel
}

The ACTION_UP part is OK, leading to the desired final state. I guess the mDragHelper.processTouchEvent triggers onViewDragStateChanged with STATE_IDLE for the initial state, this dispatching the associated callback for the initial state. I've tried not calling mDragHelper.processTouchEvent(ev) for the ACTION_UP + isDragViewHit case (since it's a case the library gets to handle explicitly) and, at first sight, it seems to work. Yet, I'm not completely sure if it's OK not to let the DragHelper process that event. Maybe it needs to for some specific case in dragging that I might have missed while testing.

from androidslidinguppanel.

tokudu avatar tokudu commented on September 24, 2024

Hi Irina, thanks for having a look. I'll check it out myself this week, when I have time. But this definitely helps!

from androidslidinguppanel.

tokudu avatar tokudu commented on September 24, 2024

Fixed in 532a926

from androidslidinguppanel.

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.