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

ResizeTransformer can't be used from DraggablePanel, you have to use DraggableView #38

Closed
frakc opened this issue Jan 16, 2015 · 17 comments

Comments

@frakc
Copy link

frakc commented Jan 16, 2015

There were many issues, that minimised youtubeplayersupportfragment displays only topleft corner of the video. And there were recommendations which did not work: set draggable_panel:top_view_resize="true"/ It did not work because this paramenter was never transmited to draggableview ( as i see in latest 1.6 snapshot version of source library) after I modefied

        public void initializeView() {
    checkFragmentConsistency();
    checkSupportFragmentManagerConsistency();

    inflate(getContext(), R.layout.draggable_panel, this);
    draggableView = (DraggableView) findViewById(R.id.draggable_view);
    draggableView.setTopViewHeight(topFragmentHeight);
    draggableView.setFragmentManager(fragmentManager);
    draggableView.attachTopFragment(topFragment);
    draggableView.setXTopViewScaleFactor(xScaleFactor);
    draggableView.setYTopViewScaleFactor(yScaleFactor);
    draggableView.setTopViewMarginRight(topFragmentMarginRight);
    draggableView.setTopViewMarginBottom(topFragmentMarginBottom);
    draggableView.attachBottomFragment(bottomFragment);
    draggableView.setDraggableListener(draggableListener);
      draggableView.setTopViewResize(true);
    draggableView.setHorizontalAlphaEffectEnabled(enableHorizontalAlphaEffect);
  }

inside DragablePanel.java? I can see nice resied minimised youtubeplayerfragment
ScreenShot
But new issue arise from this. Dragview became overlaped by few pixels and i cant understand where it comes from.

01-16 12:04:41.863  30020-30020/bigdig.yarh.ellotv.activitytry W/YouTubeAndroidPlayerAPIYouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor android.widget.FrameLayout{41c08630 V.E..... ........ 360,914-720,1114 #7f0d00ae app:id/drag_view}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 0, top: 0, right: -3, bottom: -1 (these should all be positive).
@pedrovgs
Copy link
Owner

DraggablePanel is a DraggableView facade and is not easy to support resize feature right now. You can use DraggableView with resize enabled and add your fragment manually as DraggablePanel does. That's why the sample code is not using this feature.

@pedrovgs pedrovgs changed the title ResizeTransformer stops youtubevideofragment in draggable panel ResizeTransformer can't be used from DraggablePanel, you have to use DraggableView Jan 18, 2015
@frakc
Copy link
Author

frakc commented Jan 19, 2015

@pedrovgs but main problem - resize transformer causes youtubefragment to be few pixel under some view, which make youtube player to stop, as anything is not allowed to be above it

@pedrovgs
Copy link
Owner

Can you upload a screenshot whit your device layout bounds option activated?

@frakc
Copy link
Author

frakc commented Jan 19, 2015

@pedrovgs screenshoot
As You can see if you magnify image, video fragme is slightly overlaped a bottom

@pedrovgs
Copy link
Owner

I don't see any problem :S can you add an arrow or something like that pointing to the problem? Why do you say that youtube player is going to stop the video if youtube fragment is under some view?

I guess you are using the last library version.

@frakc
Copy link
Author

frakc commented Feb 2, 2015

@pedrovgs
Yes, I am using last library version.
quot from google dev https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubePlayerFragment?hl=ru "Note that while videos are playing, this View has a minimum size of 200x110 dp. If you make the view any smaller, videos will automatically stop playing. Also, it is not permitted to overlay this fragment's view with other views while a video is playing. "
And if you will try to put any overlay to youtubeplayerview or youtubeplayerfragment you will see that it is true - video will stop plaing in 2 second if overlay vill not move out of youtubeplayer bounds.

Also in last line of error log in topic body, you will see distances with negative numbers which point to overlaping.

I also tried to point it on this image, do you see that top view is just few pixels below bottomview?
http://oi61.tinypic.com/2vv8dw5.jpg

@sierra-delta
Copy link

I'm also seeing this behaviour where the youtube video will stop sometimes in minimized view.

I am using DraggableView and the youtube video resizes correctly.

03-28 15:06:47.630 3783-3783/com.myapp W/YouTubeAndroidPlayerAPI﹕ YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor android.widget.FrameLayout{1e96423f V.E..... .......D 1189,897-2395,1334 #7f0a0043 app:id/youtubeVideoContainer}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 0, top: 0, right: -3, bottom: -1 (these should all be positive).

@v-b7
Copy link

v-b7 commented Mar 29, 2015

@ninja-tortoise There might be an issue with ResizeTransformer or with YouTubePlayerFragment. A quick fix would be to add padding or margin (bottom and right) to YouTubePlayerView after the fragment's view was created

@sierra-delta
Copy link

@NoStake This worked like charm. Thanks a lot.

@pedrovgs
Copy link
Owner

@ninja-tortoise can you upload your previous DraggablePanel configuration to a sample project? I'd like to fix this issue :)

@kriishna
Copy link

landscspe
Hi Pedrovgs,

i had a problem with landscape view while using draggable panel, can u mention any hint or help to solve this feature.. i am trying to implement fullscreen mode...

@pedrovgs
Copy link
Owner

The current workaround is change your DraggablePanel to use DraggableView. I'm trying to get time to improve this project but I'm working in another open source project right now...sorry.

@kriishna
Copy link

kriishna commented Jul 7, 2015

Hi Pedrovgs,

Thanks for giving reply for my previous question, Hope you are doing well and busy with you work, i have one more doubt regarding draggable panel , if u have some free time can u clarify me ,

if we use "draggableView.setTopViewHeight(topFragmentHeight);" for top view fragment like 200 dip in Portrait mode , when the screen is in landscape mode, still the topFragmentHeight is 200dp, to show topview (video view) in full screen mode this is stopping me, if we change topFragmentHeight to 400 dp , in portrait mode it will bit more and in landscape view the top view(video view) will be fitted to fullscreen.. i guess this is stopping to load in full screen,, i tried from sidewith different approaches other than this way..

can u share your valuable inputs ..

@pedrovgs
Copy link
Owner

pedrovgs commented Aug 2, 2015

Thie setTopViewHeight is a method only valid in the portrait mode. If you want to develop a landscape mode you'll have to override some of the current behavior.

@frakc
Copy link
Author

frakc commented Sep 15, 2015

besides overlappind, there also was issue with minimal player size for YouTubePlayerSupportFragment,which is limited to 200*110 dp. I fixed it in following way:
At first wrap frame which will hold youtube fragment and add top and bottom padding

 <FrameLayout
            android:id="@+id/top"
            android:layout_width="match_parent"
            android:layout_height="220dip"
            android:paddingBottom="5dip"
            android:paddingTop="5dip"
            android:layout_alignParentTop="true"
            >

            <FrameLayout
                android:id="@+id/youtube_here"
                android:layout_width="match_parent"

                android:layout_height="match_parent">

            </FrameLayout>
        </FrameLayout>

then
change updateScale method in resizetransformer to

  @Override public void updateScale(float verticalDragOffset) {
    int newWidth = (int) (getOriginalWidth() * (1 - verticalDragOffset / getXScaleFactor()));
    int newHeight = (int) (getOriginalHeight() * (1 - verticalDragOffset / getYScaleFactor()));
    if(newWidth>minX)layoutParams.width = newWidth;
    if(newHeight>minY)layoutParams.height = newHeight;

    getView().setLayoutParams(layoutParams);
  }

and constructor to

  private int minX,minY;
  ResizeTransformer(View view, View parent) {
    super(view, parent);
    layoutParams = (RelativeLayout.LayoutParams) view.getLayoutParams();
    minX = (int) TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_DIP, 210, view.getContext()
        .getResources()
        .getDisplayMetrics()
    );
    minY = (int) TypedValue.applyDimension(
        TypedValue.COMPLEX_UNIT_DIP, 114, view.getContext().getResources().getDisplayMetrics()
    );

  }

that will ensure that player will not be smalle then minimal dimentions and will not be overlaped by bottom fragment

@Ambilash
Copy link

Hi frank,
I have tried what you mentioned i am able to get resize transformer with youtube fragment but when minimized it seams that touches on minimized view is not recognized.It is not sliding to right or left for close its only maximizing.Can you update your code to sample.

@Swapnildhamale92
Copy link

Hi Frakc,
I implemented your suggestions but the top video fragment is going below the screen,its not position well and also when minimized it seams that touches on minimized view is not recognized.It is not sliding to right or left for close its only maximizing..

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

No branches or pull requests

7 participants