Angus Kong | 8e5e4ee | 2013-07-30 11:36:00 -0700 | [diff] [blame] | 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 | */ |
Angus Kong | bd26069 | 2013-08-07 14:52:56 -0700 | [diff] [blame] | 26 | public class CameraPreviewData extends SimpleViewData { |
Angus Kong | 8e5e4ee | 2013-07-30 11:36:00 -0700 | [diff] [blame] | 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 |
Angus Kong | c27d21b | 2013-08-12 15:03:45 -0700 | [diff] [blame] | 43 | public int getViewType() { |
| 44 | return ImageData.TYPE_STICKY_VIEW; |
| 45 | } |
| 46 | |
| 47 | @Override |
Sascha Haeberling | fae11a1 | 2013-08-15 14:29:49 -0700 | [diff] [blame^] | 48 | public int getLocalDataType() { |
Angus Kong | c27d21b | 2013-08-12 15:03:45 -0700 | [diff] [blame] | 49 | return LOCAL_CAMERA_PREVIEW; |
Angus Kong | 8e5e4ee | 2013-07-30 11:36:00 -0700 | [diff] [blame] | 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 | } |