• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.videoeditor.widgets;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 import android.view.GestureDetector;
22 import android.view.MotionEvent;
23 import android.view.SurfaceView;
24 
25 /**
26  * Surface view for video preview.
27  */
28 public class PreviewSurfaceView extends SurfaceView {
29     private GestureDetector mSimpleGestureDetector;
30 
PreviewSurfaceView(Context context, AttributeSet attrs, int defStyle)31     public PreviewSurfaceView(Context context, AttributeSet attrs, int defStyle) {
32         super(context, attrs, defStyle);
33     }
34 
PreviewSurfaceView(Context context, AttributeSet attrs)35     public PreviewSurfaceView(Context context, AttributeSet attrs) {
36         this(context, attrs, 0);
37     }
38 
PreviewSurfaceView(Context context)39     public PreviewSurfaceView(Context context) {
40         this(context, null, 0);
41     }
42 
43     /**
44      * @param detector The gesture detector
45      */
setGestureListener(GestureDetector detector)46     public void setGestureListener(GestureDetector detector) {
47         mSimpleGestureDetector = detector;
48     }
49 
50     @Override
onTouchEvent(MotionEvent ev)51     public boolean onTouchEvent(MotionEvent ev) {
52         // Let the gesture detector inspect all events.
53         if (mSimpleGestureDetector != null) {
54             mSimpleGestureDetector.onTouchEvent(ev);
55         }
56 
57         super.onTouchEvent(ev);
58         return true;
59     }
60 }
61