pedrovgs / DraggablePanel

Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.
Apache License 2.0
2.99k stars 606 forks source link

DraggableView start closeToRight() / closeToLeft() #88

Closed ameruddinjamil closed 8 years ago

ameruddinjamil commented 8 years ago

Hello.

I am using draggableView in my project. At the initializeDraggableView method, I already set the visibility to gone and closeToRight() which I hope when I first time click the list item, the draggableview will show an animation from right to top. But the draggableView just appear on top of the list item which is not so animated. But when I minimized the draggableView and close the draggableView by myself, and click at the other list item, the animation went well.

Thank you.

tuncaulubilge commented 8 years ago

Could you find any solutions to this issue? Tried several methods but no luck

ameruddinjamil commented 8 years ago

Hi there,

Nope, still no solution. On 5 May 2016 22:43, "Tunca Ulubilge" notifications@github.com wrote:

Could you find any solutions to this issue? Tried several methods but no luck

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/pedrovgs/DraggablePanel/issues/88#issuecomment-217172594

ppamorim commented 8 years ago

This is made by design, not a bug.

tuncaulubilge commented 8 years ago

@ppamorim Any suggestions on how to change this? I can fork your project for this feature.

ppamorim commented 8 years ago

You need to do some workarounds to pervent this problem. I solved this on my app doing this:

tuncaulubilge commented 8 years ago

Found an ugly but working solution for this issue.

The trick is, the draggableView has to be visible when you call minimize(). In my layout, I made draggableView visible with both drag views invisible.

When the draggableView global layout is called, I minimize the view and set it to invisible again in a delayed runnable. This way, when I want to display the views with maximize, the animation plays from bottom to top.

Here is the code:

 playerView.getViewTreeObserver().addOnGlobalLayoutListener(
                new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override public void onGlobalLayout() {
                        // gets called after layout has been done but before display
                        playerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                        playerView.minimize();
                        Handler handler = new Handler();
                        handler.postDelayed(new Runnable() {
                            @Override public void run() {
                                playerView.setVisibility(View.INVISIBLE);
                                playerView.setChildViewsVisible();
                            }
                        }, 10);
                    }
                });

Afterwards, when I want to display the player, I just set it to VISIBLE and call maximize()

pedrovgs commented 8 years ago

Sorry guys but this is the original behaviour of the library. As this is not a bug I'm closing the issue.