package com.github.pedrovgs.sample.activity;

import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import com.github.pedrovgs.DraggableView;
import com.github.pedrovgs.sample.R;
import com.squareup.picasso.Picasso;

/**
 * @author Pedro Vicente Gómez Sánchez.
 */
public class VideoSampleActivity extends FragmentActivity {

    private static final String APPLICATION_RAW_PATH = "android.resource://com.github.pedrovgs.sample/";
    private static final String VIDEO_POSTER = "http://wac.450f.edgecastcdn.net/80450F/screencrush.com/files/2013/11/the-amazing-spider-man-2-poster-rhino.jpg";
    private static final String VIDEO_THUMBNAIL = "http://wac.450f.edgecastcdn.net/80450F/screencrush.com/files/2013/11/the-amazing-spider-man-2-poster-green-goblin.jpg";

    @InjectView(R.id.draggable_view)
    DraggableView draggable_view;
    @InjectView(R.id.video_view)
    VideoView video_view;
    @InjectView(R.id.iv_thumbnail)
    ImageView iv_thumbnail;
    @InjectView(R.id.iv_poster)
    ImageView iv_poster;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_sample);
        ButterKnife.inject(this);
        initializeVideoView();
        initializePoster();
    }

    private void initializeVideoView() {
        Uri path = Uri.parse(APPLICATION_RAW_PATH + R.raw.video);
        MediaController mediaController = new MediaController(this);
        video_view.setMediaController(mediaController);
        video_view.setVideoURI(path);
        video_view.start();
    }

    private void initializePoster() {
        Picasso.with(this).load(VIDEO_POSTER).into(iv_poster);
        Picasso.with(this).load(VIDEO_THUMBNAIL).into(iv_thumbnail);
    }

    @OnClick(R.id.video_view)
    void onVideoViewClicked() {
        Toast.makeText(this, "Video view clicked", Toast.LENGTH_SHORT).show();
    }

    @OnClick(R.id.iv_thumbnail)
    void onThubmnailClicked() {
        Toast.makeText(this, "Thumbnail view clicked", Toast.LENGTH_SHORT).show();
    }

    @OnClick(R.id.iv_poster)
    void onPosterClicked() {
        draggable_view.maximize();
    }
}

@@ -362,16 +362,62 @@
 nClick;%0A
+import com.github.pedrovgs.DraggableListener;%0A
 import c
@@ -446,24 +446,24 @@
 ggableView;%0A
-
 import com.g
@@ -1136,18 +1136,17 @@
 raggable
-_v
+V
 iew;%0A   
@@ -1194,18 +1194,17 @@
 ew video
-_v
+V
 iew;%0A   
@@ -1581,24 +1581,818 @@
 zePoster();%0A
+        hookDraggableViewListener();%0A    %7D%0A%0A    private void hookDraggableViewListener() %7B%0A        draggableView.setDraggableListener(new DraggableListener() %7B%0A            @Override%0A            public void onMaximized() %7B%0A                if (!videoView.isPlaying()) %7B%0A                    videoView.start();%0A                %7D%0A            %7D%0A%0A            @Override%0A            public void onMinimized() %7B%0A%0A            %7D%0A%0A            @Override%0A            public void onClosedToLeft() %7B%0A                if (videoView.isPlaying()) %7B%0A                    videoView.pause();%0A                %7D%0A            %7D%0A%0A            @Override%0A            public void onClosedToRight() %7B%0A                if (videoView.isPlaying()) %7B%0A                    videoView.pause();%0A                %7D%0A            %7D%0A        %7D);%0A
     %7D%0A%0A    p
@@ -2571,26 +2571,25 @@
        video
-_v
+V
 iew.setMedia
@@ -2626,26 +2626,25 @@
        video
-_v
+V
 iew.setVideo
@@ -2667,18 +2667,17 @@
    video
-_v
+V
 iew.star
@@ -3242,18 +3242,17 @@
 raggable
-_v
+V
 iew.maxi

Improve VideoSampleActivity with DraggableViewListeners to pause/resume the video