當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。