Skip to content
This repository was archived by the owner on Nov 22, 2017. It is now read-only.

List view is destroying UI of draggable pannel in sample app #17

Closed
manpreetsinghsodhi opened this issue Oct 27, 2014 · 23 comments
Closed

Comments

@manpreetsinghsodhi
Copy link

I imported your sample app and done minor changes. In framelayout i took first element as Listview(as i need to show working same as youtube app). When we minimize the vedio and i select any other element from listview then draggable pannel UI is getting distorted.
I changed activity_youtube_sample.xml as following

<!-- Movie Thumbnail -->

<ListView
        android:id="@+id/ivx_thumbnail"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />

<!-- DraggablePanel -->

<com.github.pedrovgs.DraggablePanel
        android:id="@+id/draggable_panel"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        draggable_panel:x_scale_factor="@dimen/x_scale_factor"
        draggable_panel:y_scale_factor="@dimen/y_scale_factor"
        draggable_panel:top_fragment_height="@dimen/top_fragment_height"
        draggable_panel:top_fragment_margin_right="@dimen/top_fragment_margin"
        draggable_panel:top_fragment_margin_bottom="@dimen/top_fragment_margin"
        draggable_panel:enable_horizontal_alpha_effect="false"/>
Even i tried putting listview and draggable pannel in separate linear layout(with match parent) but still not working. And the rest of the code is as it is. I captured vedio of the error http://videobam.com/IUjYH This library is not working for me in this situation. Kindly help.
@Fiddl3
Copy link
Contributor

Fiddl3 commented Oct 27, 2014

I had a similar problem with vitamio VideoView as dragView and resizeTransformer.

Solution: Move methods responsible for changing a position of seconView to layoutChange listener of dragView.

in DraggableView.mapGui()

...

    private void mapGUI(TypedArray attributes) {

        final int dragViewId = attributes.getResourceId(R.styleable.draggable_view_top_view_id, R.id.drag_view);
        final int secondViewId = attributes.getResourceId(R.styleable.draggable_view_bottom_view_id, R.id.second_view);
        dragView = findViewById(dragViewId);
        secondView = findViewById(secondViewId);

        ViewTreeObserver observer = dragView.getViewTreeObserver();
        observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                changeSecondViewPosition();
                changeSecondViewAlpha();
            }
        });
    }

...

and comment in: DraggableViewCallback.onViewPositionChanged()

...

    @Override
    public void onViewPositionChanged(View changedView, int left, int top, int dx, int dy) {
        draggableView.updateLastDragViewPosition(top, left);

        if (draggableView.isDragViewAtBottom()) {
            draggableView.changeDragViewViewAlpha();
        } else {
            draggableView.restoreAlpha();
            draggableView.changeDragViewScale();
            draggableView.changeDragViewPosition();
            //draggableView.changeSecondViewAlpha();
            //draggableView.changeSecondViewPosition();
            draggableView.changeBackgroundAlpha();
        }
    }
...

also there is bug in DraggableView.smoothSlideTo(float slideOffset)

        int x = (int) (slideOffset * (getWidth() - transformer.getMinWidth()));
        int y = (int) (topBound + slideOffset * getVerticalDragRange());

should be:

        int x = (int) (slideOffset * (getWidth() - transformer.getMinWidth() - transformer.getMarginRight()));
        int y = (int) (topBound + slideOffset * getVerticalDragRange());

and some in resize tranformer...

@Fiddl3
Copy link
Contributor

Fiddl3 commented Oct 27, 2014

You need to create local copy of library (clone git repo), add it as module, add module dependency in grade (I'm using Android Studio), and modify java sources.
In eclipse create android library project, make changes, compile and add .jar to libs, of your project.

Changes You need to make:
In Class:
https://github.com/pedrovgs/DraggablePanel/blob/develop/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java#L334
modify/replace mapGUI (Copy&Paste from above answer)

and in https://github.com/pedrovgs/DraggablePanel/blob/develop/draggablepanel/src/main/java/com/github/pedrovgs/DraggableViewCallback.java#L58

add comment in line 66&67, or replace whole onViewPositionChanged() from my prev answer

Sorry for my English, I hope You'll understand now.

@manpreetsinghsodhi
Copy link
Author

Hi i implemented the changes you suggested but still it is not working fine. There is a problem of rendering when i drag from top to bottom and bottom to top again and also it is taking a lot of time.

I am sending you screenshots when i drag from top to bottom
device-2014-10-27-155051

And when i drag from bottom to top then it is displaying as follows
device-2014-10-27-155135

So please help me

@manpreetsinghsodhi
Copy link
Author

And what are changes in code should i do in resize transformer?

@manpreetsinghsodhi manpreetsinghsodhi changed the title List view is destrying UI of draggable pannel in your same app List view is destroying UI of draggable pannel in your sample app Oct 27, 2014
@Fiddl3
Copy link
Contributor

Fiddl3 commented Oct 27, 2014

You using ScaleTransformer which is default (seems more smooth, but not working with vitamio)... in ScaleTransformer view position is changed by ViewHelper.

Add brake point in addOnGlobalLayoutListener you implemented, and check whether it is fired

If not, you should reverse changes and study dragView & secondView positions while dragging, and in OnLayout https://github.com/pedrovgs/DraggablePanel/blob/develop/draggablepanel/src/main/java/com/github/pedrovgs/DraggableView.java#L308

and check if positions are proper...

@manpreetsinghsodhi
Copy link
Author

I implemented the library as it is in sample . Haven't changed anything other than changes you suggested. So how to resolve it now .
Is there any alternate for this draggable pannel on github or anywhere else?

@manpreetsinghsodhi manpreetsinghsodhi changed the title List view is destroying UI of draggable pannel in your sample app List view is destroying UI of draggable pannel in sample app Oct 27, 2014
@Fiddl3
Copy link
Contributor

Fiddl3 commented Oct 27, 2014

Can you share your code (Add whole project to Archive)? I'll take look and may be able to help.

@manpreetsinghsodhi
Copy link
Author

@Fiddle3 sure .Can i have your mail id or skype id ?

@Fiddl3
Copy link
Contributor

Fiddl3 commented Oct 27, 2014

[email protected]

@pedrovgs
Copy link
Owner

Guys I was on holidays and I couldn't comment about this issues. Sorry.

Instead of copy paste code modifications why don't you fork this project to your github and send me a pull request with your changes?

@manpreetsinghsodhi if you want some help, please upload your project to any repository and give me access. My mail is pedrovicente.gomez (at) gmail (dot) com. And I'll take a look.

Please, don't open more issues related with the same problem. I'm going to help you with this in this issue and close other issues opened by @manpreetsinghsodhi because every issue opened is related with the same problem.

@Fiddl3
Copy link
Contributor

Fiddl3 commented Oct 27, 2014

I'll send pull request, but I have to test it more deeply

@manpreetsinghsodhi
Copy link
Author

@pedrovgs sure !!

@manpreetsinghsodhi
Copy link
Author

@pedrovgs Hi i added you as a collaborator to my repository. I uploaded the files that are causing me error. Please have a look. Issue you already know . I uploaded vedio in earlier issue as well. Looking positively for help.

@pedrovgs
Copy link
Owner

I'll take a look this weekend. Thanks!

@Fiddl3
Copy link
Contributor

Fiddl3 commented Nov 6, 2014

@pedrovgs I tried to explore why this issue occurs, but I haven't enough time to investigate this deeply, so, for now, i use temp fix with ViewTreeObserver and it works
I made some other changes in library, take look Fiddl3@b0f253e

I'll continue working on this when I'll have time, and send you a pull request... Maybe you'll resolve this issue earlier

@pedrovgs
Copy link
Owner

pedrovgs commented Nov 6, 2014

@Fiddl3 thanks! @manpreetsinghsodhi can you check if that version of the library is working for you?

@Fiddl3
Copy link
Contributor

Fiddl3 commented Nov 6, 2014

@pedrovgs here is updated sample app that I send to @manpreetsinghsodhi last week Fiddl3@e6f64b6

@manpreetsinghsodhi
Copy link
Author

Fiddle when vedio plays it is again cutting edges at bottom(only on vedio play). I will send you my project in android studio.

@Fiddl3
Copy link
Contributor

Fiddl3 commented Nov 7, 2014

I don't have time to resolve all of your problems... especially if I don't know what is the problem...

I suppose that video aspect ratio is different than dragView aspect ratio and part of video is cutoff (at bottom), the solution for this "issue" is to change dragView height programmatically to adjust it to video height

There is more problems to solve for example, when you drag YT player the video doesn't change its dimensions. There will be many more so You should teach yourself how to resolve them.

@pedrovgs
Copy link
Owner

@manpreetsinghsodhi I've created a new branch with a ListView below DraggablePanel in YoutubeSampleActivity. It's working fine to me.

https://github.com/pedrovgs/DraggablePanel/tree/manpreetsinghsodhi-issue17

@pedrovgs
Copy link
Owner

@manpreetsinghsodhi I think I've found the bug. It's related with YouTube player view. This view is executing requestLayout when I still think my view was in other position :) I've changed onLayout method to fix this issue. Please, review if it's working for to and tell me to do a public release to maven central.

This is the branch: https://github.com/pedrovgs/DraggablePanel/tree/manpreetsinghsodhi-issue17

@manpreetsinghsodhi
Copy link
Author

Thanks. This issue is solved.

@pedrovgs
Copy link
Owner

\o/ Released and uploaded to Maven Central Repository in Release 1.3.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants