当前位置: 首页>>代码示例>>Java>>正文


Java TransitionDrawable.getNumberOfLayers方法代码示例

本文整理汇总了Java中android.graphics.drawable.TransitionDrawable.getNumberOfLayers方法的典型用法代码示例。如果您正苦于以下问题:Java TransitionDrawable.getNumberOfLayers方法的具体用法?Java TransitionDrawable.getNumberOfLayers怎么用?Java TransitionDrawable.getNumberOfLayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.drawable.TransitionDrawable的用法示例。


在下文中一共展示了TransitionDrawable.getNumberOfLayers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDraw

import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
	Drawable drawable = this.getDrawable();
	if(drawable != null) {
		if(drawable instanceof BitmapDrawable) {
			if (isBitmapRecycled(drawable)) {
				this.setImageDrawable(null);
				setInvalidated(true);
			}
		} else if(drawable instanceof TransitionDrawable) {
			TransitionDrawable transitionDrawable = (TransitionDrawable) drawable;

			// If last bitmap in chain is recycled, just blank this out since it would be invalid anyways
			Drawable lastDrawable = transitionDrawable.getDrawable(transitionDrawable.getNumberOfLayers() - 1);
			if(isBitmapRecycled(lastDrawable)) {
				this.setImageDrawable(null);
				setInvalidated(true);
			} else {
				// Go through earlier bitmaps and make sure that they are not recycled
				for (int i = 0; i < transitionDrawable.getNumberOfLayers(); i++) {
					Drawable layerDrawable = transitionDrawable.getDrawable(i);
					if (isBitmapRecycled(layerDrawable)) {
						// If anything in the chain is broken, just get rid of transition and go to last drawable
						this.setImageDrawable(lastDrawable);
						break;
					}
				}
			}
		}
	}

	super.onDraw(canvas);
}
 
开发者ID:nvllsvm,项目名称:Audinaut,代码行数:34,代码来源:RecyclingImageView.java

示例2: removeDrawableAndHolder

import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
private void removeDrawableAndHolder() {
    // Remove drawable
    Drawable drawable = getDrawable();
    if (drawable instanceof TransitionDrawable) {
        TransitionDrawable tDrawable = (TransitionDrawable) drawable;
        int number = tDrawable.getNumberOfLayers();
        if (number > 0) {
            drawable = tDrawable.getDrawable(number - 1);
        }
    }
    if (drawable instanceof ImageDrawable) {
        ((ImageDrawable) drawable).recycle();
    }
    setImageDrawable(null);

    // Remove holder
    if (mHolder != null) {
        mHolder.release(this);

        ImageWrapper imageWrapper = mHolder.getValue();
        if (mHolder.isFree()) {
            // ImageWrapper is free, stop animate
            imageWrapper.stop();
            if (!mHolder.isInMemoryCache()) {
                // ImageWrapper is not needed any more, recycle it
                imageWrapper.recycle();
            }
        }

        mHolder = null;
    }
}
 
开发者ID:seven332,项目名称:Nimingban,代码行数:33,代码来源:LoadImageView.java

示例3: start

import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
public void start() {
    Drawable drawable = getDrawable();
    if (drawable instanceof TransitionDrawable) {
        TransitionDrawable tDrawable = (TransitionDrawable) drawable;
        int number = tDrawable.getNumberOfLayers();
        if (number > 0) {
            drawable = tDrawable.getDrawable(number - 1);
        }
    }

    if (drawable instanceof ImageDrawable) {
        ((ImageDrawable) drawable).start();
    }
}
 
开发者ID:seven332,项目名称:Nimingban,代码行数:15,代码来源:LoadImageView.java

示例4: stop

import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
public void stop() {
    Drawable drawable = getDrawable();
    if (drawable instanceof TransitionDrawable) {
        TransitionDrawable tDrawable = (TransitionDrawable) drawable;
        int number = tDrawable.getNumberOfLayers();
        if (number > 0) {
            drawable = tDrawable.getDrawable(number - 1);
        }
    }

    if (drawable instanceof ImageDrawable) {
        ((ImageDrawable) drawable).stop();
    }
}
 
开发者ID:seven332,项目名称:Nimingban,代码行数:15,代码来源:LoadImageView.java


注:本文中的android.graphics.drawable.TransitionDrawable.getNumberOfLayers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。