Home | History | Annotate | Download | only in data
      1 /*
      2  * Copyright (C) 2013 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.camera.data;
     18 
     19 import android.view.View;
     20 
     21 import com.android.camera.ui.FilmStripView.ImageData;
     22 
     23 /**
     24  * A class implementing {@link LocalData} to represent a camera preview.
     25  */
     26 public class CameraPreviewData extends SimpleViewData {
     27 
     28     private boolean mPreviewLocked;
     29 
     30     /**
     31      * Constructor.
     32      *
     33      * @param v      The {@link android.view.View} for camera preview.
     34      * @param width  The width of the camera preview.
     35      * @param height The height of the camera preview.
     36      */
     37     public CameraPreviewData(View v, int width, int height) {
     38         super(v, width, height, -1, -1);
     39         mPreviewLocked = true;
     40     }
     41 
     42     @Override
     43     public int getViewType() {
     44         return ImageData.VIEW_TYPE_STICKY;
     45     }
     46 
     47     @Override
     48     public int getLocalDataType() {
     49         return LOCAL_CAMERA_PREVIEW;
     50     }
     51 
     52     @Override
     53     public boolean canSwipeInFullScreen() {
     54         return !mPreviewLocked;
     55     }
     56 
     57     /**
     58      * Locks the camera preview. When the camera preview is locked, swipe
     59      * to film strip is not allowed. One case is when the video recording
     60      * is in progress.
     61      *
     62      * @param lock {@code true} if the preview should be locked. {@code false}
     63      *             otherwise.
     64      */
     65     public void lockPreview(boolean lock) {
     66         mPreviewLocked = lock;
     67     }
     68 }
     69