blob: 8b0df06a9cbb955f89ffa1a1b7c604a1de499165 [file] [log] [blame]
Jorim Jaggi605f1902014-06-25 05:23:42 +02001/*
2 * Copyright (C) 2014 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
17package com.android.systemui.statusbar;
18
19import android.content.Context;
20import android.graphics.Canvas;
21import android.view.View;
22
23/**
24 * A view that mirrors the visual contents of another one. Should be used for animation purposes
25 * only, as this view doesn't have any input handling.
26 */
27public class MirrorView extends View {
28
29 private View mView;
30 private int mFixedWidth;
31 private int mFixedHeight;
32
33 public MirrorView(Context context) {
34 super(context);
35 }
36
37 public void setMirroredView(View v, int width, int height) {
38 mView = v;
39 mFixedWidth = width;
40 mFixedHeight = height;
41 requestLayout();
42 invalidate();
43 }
44
45 @Override
46 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
47 if (mView != null) {
48 setMeasuredDimension(mFixedWidth, mFixedHeight);
49 } else {
50 setMeasuredDimension(0, 0);
51 }
52 }
53
54 @Override
55 protected void onDraw(Canvas canvas) {
56 if (mView != null) {
57 mView.draw(canvas);
58 }
59 }
60}