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 605 forks source link

When onMaximised|Minimised are actually called? #37

Closed frakc closed 9 years ago

frakc commented 9 years ago

Just tried to changed style of youtube player id for maximised panel and minimised. However when I drag panel up and down i never see corresponding log messages.

 private void hookDraggablePanelListeners() {
        draggablePanel.setDraggableListener(
                new DraggableListener() {

                    @Override
                    public void onMaximized() {
                        playVideo();
                        youtubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.DEFAULT);
                        Toast.makeText(getActivity(),"Maximised",Toast.LENGTH_SHORT).show();
                        Log.e("dragg", "maximised");
                    }

                    @Override
                    public void onMinimized() {
                        youtubePlayer.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS);
                        Toast.makeText(getActivity(), "Minimised", Toast.LENGTH_SHORT)
                                .show();
                        Log.e("dragg", "minimised");

                    }

                    @Override
                    public void onClosedToLeft() {
                        pauseVideo();
                    }

                    @Override
                    public void onClosedToRight() {
                        pauseVideo();
                    }
                }
        );
    }

Note: video is paused, when closed to right or left not because of listeners, but because of " YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.github.pedrovgs.DraggableView{41c02fd0 V.E..... .......D 0,0-720,1134 #7f0d00ac app:id/draggable_view}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: -720, top: 734, right: 720, bottom: 0 (these should all be positive)." When youtube fragment is out of screen

edit: My xml

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:draggable_panel="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fl_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFFFF"
        android:orientation="vertical">

        <android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/swipe_container"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <com.twotoasters.jazzylistview.JazzyGridView
                android:animationCache="false"
                android:scrollingCache="false"
                android:animateLayoutChanges="true"
                android:id="@+id/listView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:divider="@android:color/transparent"
                android:dividerHeight="0dip"
                android:numColumns="1"
                android:background="#40000000"
                android:verticalSpacing="16dip"
                android:horizontalSpacing="16dip"
                android:stretchMode="columnWidth" />
        </android.support.v4.widget.SwipeRefreshLayout>
    </LinearLayout>

    <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_view_id="@+id/minimised_video"
        draggable_panel:top_view_resize="true"
        draggable_panel:top_fragment_height="@dimen/top_fragment_height"
        draggable_panel:enable_horizontal_alpha_effect="false" />
</FrameLayout>
frakc commented 9 years ago

Solved Correct way to initialise is

 initializeYoutubeFragment();
        hookDraggablePanelListeners();
        initializeDraggablePanel();

Contradictory to sample