本文整理匯總了Java中android.graphics.drawable.Drawable.isStateful方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.isStateful方法的具體用法?Java Drawable.isStateful怎麽用?Java Drawable.isStateful使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.Drawable
的用法示例。
在下文中一共展示了Drawable.isStateful方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setHotspot
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void setHotspot(Drawable hotspot) {
if (mHotspot != null) {
mHotspot.setCallback(null);
unscheduleDrawable(mHotspot);
}
if (hotspot != null) {
hotspot.setCallback(this);
if (hotspot.isStateful()) {
hotspot.setState(getDrawableState());
}
}
mHotspot = hotspot;
invalidate();
}
示例2: drawableStateChanged
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
boolean invalidate = false;
for (DrawableInfo drawable : mDrawables) {
Drawable d = drawable.mDrawable;
if (d.isStateful() && d.setState(getDrawableState())) {
invalidate = true;
}
}
if (invalidate) {
invalidate();
}
}
示例3: drawableStateChanged
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@SuppressWarnings("ConstantConditions")
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
final int[] state = getDrawableState();
boolean changed = false;
Drawable d = mStatusBarScrim;
if (d != null && d.isStateful()) {
changed |= d.setState(state);
}
d = mContentScrim;
if (d != null && d.isStateful()) {
changed |= d.setState(state);
}
if (mCollapsingTextHelper != null) {
changed |= mCollapsingTextHelper.setState(state);
}
if (changed) {
invalidate();
}
}
示例4: drawableStateChanged
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
final Drawable d = mMarginDrawable;
if (d != null && d.isStateful()) {
d.setState(getDrawableState());
}
}
示例5: isStateful
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public boolean isStateful() {
if (!mIsStatefulCalculated) {
mIsStateful = false;
for (int i = 0; i < mLayers.length; i++) {
Drawable drawable = mLayers[i];
mIsStateful |= drawable != null && drawable.isStateful();
}
mIsStatefulCalculated = true;
}
return mIsStateful;
}
示例6: setForeground
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* Supply a Drawable that is to be rendered on top of all of the child
* views in the frame layout. Any padding in the Drawable will be taken
* into account by ensuring that the children are inset to be placed
* inside of the padding area.
*
* @param drawable The Drawable to be drawn on top of the children.
*/
public void setForeground(Drawable drawable) {
if (mForeground != drawable) {
if (mForeground != null) {
mForeground.setCallback(null);
unscheduleDrawable(mForeground);
}
mForeground = drawable;
if (drawable != null) {
setWillNotDraw(false);
drawable.setCallback(this);
if (drawable.isStateful()) {
drawable.setState(getDrawableState());
}
if (mForegroundGravity == Gravity.FILL) {
Rect padding = new Rect();
drawable.getPadding(padding);
}
} else {
setWillNotDraw(true);
}
requestLayout();
invalidate();
}
}
示例7: getIndicator
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
* Gets the indicator for the item at the given position. If the indicator
* is stateful, the state will be given to the indicator.
*
* @param pos The flat list position of the item whose indicator
* should be returned.
* @return The indicator in the proper state.
*/
private Drawable getIndicator( ExpandableHListConnector.PositionMetadata pos ) {
Drawable indicator;
if( pos.position.type == ExpandableHListPosition.GROUP ) {
indicator = mGroupIndicator;
if( indicator != null && indicator.isStateful() ) {
// Empty check based on availability of data. If the groupMetadata isn't null,
// we do a check on it. Otherwise, the group is collapsed so we consider it
// empty for performance reasons.
boolean isEmpty = ( pos.groupMetadata == null ) || ( pos.groupMetadata.lastChildFlPos == pos.groupMetadata.flPos );
final int stateSetIndex = ( pos.isExpanded() ? 1 : 0 ) | // Expanded?
( isEmpty ? 2 : 0 ); // Empty?
indicator.setState( GROUP_STATE_SETS[stateSetIndex] );
}
}
else {
indicator = mChildIndicator;
if( indicator != null && indicator.isStateful() ) {
// No need for a state sets array for the child since it only has two states
final int stateSet[] = pos.position.flatListPos == pos.groupMetadata.lastChildFlPos ? CHILD_LAST_STATE_SET : EMPTY_STATE_SET;
indicator.setState( stateSet );
}
}
return indicator;
}
示例8: updateDrawable
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void updateDrawable(Drawable d) {
boolean sameDrawable = false;
boolean sCompatDrawableVisibilityDispatch = false;
if (mDrawable != null) {
sameDrawable = mDrawable == d;
mDrawable.setCallback(null);
unscheduleDrawable(mDrawable);
if (!sCompatDrawableVisibilityDispatch && !sameDrawable && isAttachedWindow) {
mDrawable.setVisible(false, false);
}
}
mDrawable = d;
if (d != null) {
d.setCallback(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
d.setLayoutDirection(getLayoutDirection());
}
if (d.isStateful()) {
d.setState(getDrawableState());
}
if (!sameDrawable || sCompatDrawableVisibilityDispatch) {
final boolean visible = sCompatDrawableVisibilityDispatch
? getVisibility() == VISIBLE
: isAttachedWindow && getWindowVisibility() == VISIBLE && isShown();
d.setVisible(visible, true);
}
d.setLevel(mLevel);
mDrawableWidth = d.getIntrinsicWidth();
mDrawableHeight = d.getIntrinsicHeight();
// applyImageTint();
// applyColorMod();
//
// configureBounds();
} else {
mDrawableWidth = mDrawableHeight = -1;
}
}
示例9: drawableStateChanged
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
Drawable d = mDrawable;
if (d != null && d.isStateful()) {
d.setState(getDrawableState());
}
}
示例10: drawableStateChanged
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@CallSuper
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
final Drawable selectionDivider = mSelectionDivider;
if (selectionDivider != null && selectionDivider.isStateful()
&& selectionDivider.setState(getDrawableState())) {
invalidateDrawable(selectionDivider);
}
}
示例11: drawableStateChanged
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
protected void drawableStateChanged() {
super.drawableStateChanged();
Drawable d = this.mMarginDrawable;
if (d != null && d.isStateful()) {
d.setState(getDrawableState());
}
}
示例12: drawLeadingMargin
import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, int end, boolean first, Layout layout) {
if (!first
|| !LeadingMarginUtils.selfStart(start, text, this)) {
return;
}
final Drawable drawable = theme.getTaskListDrawable();
if (drawable == null) {
return;
}
final int save = c.save();
try {
final int width = theme.getBlockMargin();
final int height = bottom - top;
final int w = (int) (width * .75F + .5F);
final int h = (int) (height * .75F + .5F);
drawable.setBounds(0, 0, w, h);
if (drawable.isStateful()) {
final int[] state;
if (isDone) {
state = STATE_CHECKED;
} else {
state = STATE_NONE;
}
drawable.setState(state);
}
final int l;
if (dir > 0) {
l = x + (width * (blockIndent - 1)) + ((width - w) / 2);
} else {
l = x - (width * blockIndent) + ((width - w) / 2);
}
final int t = top + ((height - h) / 2);
c.translate(l, t);
drawable.draw(c);
} finally {
c.restoreToCount(save);
}
}