forked from Prototik/HoloEverywhere
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add StateOverlay to RelativeLayout (close Prototik#819)
- Loading branch information
Sergey Shatunov
committed
Apr 5, 2014
1 parent
fc7880d
commit 8dfe309
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.holoeverywhere.widget; | ||
|
||
import android.content.Context; | ||
import android.util.AttributeSet; | ||
|
||
import org.holoeverywhere.drawable.DrawableCompat; | ||
|
||
public class RelativeLayout extends android.widget.RelativeLayout implements DrawableCompat.IStateOverlay { | ||
private final DrawableCompat.StateOverlay mStateOverlay; | ||
|
||
public RelativeLayout(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public RelativeLayout(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public RelativeLayout(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
mStateOverlay = new DrawableCompat.StateOverlay(this, context, attrs, defStyle); | ||
} | ||
|
||
@Override | ||
public boolean isActivated() { | ||
return mStateOverlay.isActivated(); | ||
} | ||
|
||
@Override | ||
public void setActivated(boolean activated) { | ||
mStateOverlay.setActivated(activated); | ||
} | ||
|
||
@Override | ||
protected int[] onCreateDrawableState(int extraSpace) { | ||
if (mStateOverlay == null) { | ||
return super.onCreateDrawableState(extraSpace); | ||
} | ||
return mStateOverlay.onCreateDrawableState(extraSpace); | ||
} | ||
|
||
@Override | ||
public int[] superOnCreateDrawableState(int extraSpace) { | ||
return super.onCreateDrawableState(extraSpace); | ||
} | ||
} |