summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/HolographicLinearLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/HolographicLinearLayout.java')
-rw-r--r--src/com/android/launcher2/HolographicLinearLayout.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/com/android/launcher2/HolographicLinearLayout.java b/src/com/android/launcher2/HolographicLinearLayout.java
index 986a063e5..c6a8d6aff 100644
--- a/src/com/android/launcher2/HolographicLinearLayout.java
+++ b/src/com/android/launcher2/HolographicLinearLayout.java
@@ -17,13 +17,21 @@
package com.android.launcher2;
import android.content.Context;
+import android.content.res.TypedArray;
import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
+import android.widget.ImageView;
import android.widget.LinearLayout;
+import com.android.launcher.R;
+
public class HolographicLinearLayout extends LinearLayout {
private final HolographicViewHelper mHolographicHelper;
+ private ImageView mImageView;
+ private int mImageViewId;
public HolographicLinearLayout(Context context) {
this(context, null);
@@ -36,16 +44,37 @@ public class HolographicLinearLayout extends LinearLayout {
public HolographicLinearLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.HolographicLinearLayout,
+ defStyle, 0);
+ mImageViewId = a.getResourceId(R.styleable.HolographicLinearLayout_sourceImageViewId, -1);
+ a.recycle();
+
setWillNotDraw(false);
mHolographicHelper = new HolographicViewHelper(context);
}
@Override
+ protected void drawableStateChanged() {
+ super.drawableStateChanged();
+
+ if (mImageView != null) {
+ Drawable d = mImageView.getDrawable();
+ if (d instanceof StateListDrawable) {
+ StateListDrawable sld = (StateListDrawable) d;
+ sld.setState(getDrawableState());
+ }
+ }
+ }
+
+ @Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// One time call to generate the pressed/focused state -- must be called after
// measure/layout
- mHolographicHelper.generatePressedFocusedStates(this);
+ if (mImageView == null) {
+ mImageView = (ImageView) findViewById(mImageViewId);
+ }
+ mHolographicHelper.generatePressedFocusedStates(mImageView);
}
}