• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 package com.android.systemui.statusbar;
18 
19 import android.content.Context;
20 import android.content.res.TypedArray;
21 import android.util.AttributeSet;
22 import android.widget.ImageView;
23 
24 import com.android.systemui.R;
25 
26 /**
27  * An ImageView which supports an attribute specifying whether it has overlapping rendering
28  * commands and therefore does not need a layer when alpha is changed.
29  */
30 public class AlphaOptimizedImageView extends ImageView {
31     private final boolean mHasOverlappingRendering;
32 
AlphaOptimizedImageView(Context context)33     public AlphaOptimizedImageView(Context context) {
34         this(context, null /* attrs */);
35     }
36 
AlphaOptimizedImageView(Context context, AttributeSet attrs)37     public AlphaOptimizedImageView(Context context, AttributeSet attrs) {
38         this(context, attrs, 0 /* defStyleAttr */);
39     }
40 
AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr)41     public AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr) {
42         this(context, attrs, defStyleAttr, 0 /* defStyleRes */);
43     }
44 
AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)45     public AlphaOptimizedImageView(Context context, AttributeSet attrs, int defStyleAttr,
46             int defStyleRes) {
47         super(context, attrs, defStyleAttr, defStyleRes);
48 
49         TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
50                 R.styleable.AlphaOptimizedImageView, 0, 0);
51 
52         try {
53             // Default to true, which is what View.java defaults to
54             mHasOverlappingRendering = a.getBoolean(
55                     R.styleable.AlphaOptimizedImageView_hasOverlappingRendering, true);
56         } finally {
57             a.recycle();
58         }
59     }
60 
61     @Override
hasOverlappingRendering()62     public boolean hasOverlappingRendering() {
63         return mHasOverlappingRendering;
64     }
65 }
66