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


Java TransitionDrawable.getDrawable方法代码示例

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


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

示例5: processNewTile

import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
private void processNewTile(final float dx, final float dy, Drawable drawable, boolean fromCache)
{
    if (drawable != null) {
        image = drawable;
        
        if (!fromCache) {
       	 Rect bounds = image.getBounds();
       	 width = (float)Math.round(bounds.width());
       	 height = (float)Math.round(bounds.height());
        } else {
       	 if (image instanceof TransitionDrawable) {
       		 TransitionDrawable transDrawable = (TransitionDrawable) drawable;
       		 BitmapDrawable tile = (BitmapDrawable) transDrawable.getDrawable(1);
       		 width = tile.getBitmap().getWidth();
       		 height = tile.getBitmap().getHeight();
       	 }	 
        }

        recalculateDrawableRect(dx, dy);
        
        if (image instanceof TransitionDrawable) {
            ((TransitionDrawable) image).setCallback(Cell.this);
            ((TransitionDrawable) image).startTransition(150);
            
            rootView.postDelayed(new Runnable(){public void run(){onIsReady();}}, 150);
        }
    }
}
 
开发者ID:lemberg,项目名称:mappwidget,代码行数:29,代码来源:Cell.java

示例6: setImage

import android.graphics.drawable.TransitionDrawable; //导入方法依赖的package包/类
private void setImage(View view, final Drawable drawable, boolean crossfade) {
	if (view instanceof TextView) {
		// Cross-fading is not implemented for TextView since it's not in use.  It would be easy to add it, though.
		TextView textView = (TextView) view;
		textView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
	} else if (view instanceof ImageView) {
		final ImageView imageView = (ImageView) view;
		if (crossfade && drawable != null) {
			Drawable existingDrawable = imageView.getDrawable();
			if (existingDrawable == null) {
				Bitmap emptyImage;
				if(drawable.getIntrinsicWidth() > 0 && drawable.getIntrinsicHeight() > 0) {
					emptyImage = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
				} else {
					emptyImage = Bitmap.createBitmap(imageSizeDefault, imageSizeDefault, Bitmap.Config.ARGB_8888);
				}
				existingDrawable = new BitmapDrawable(context.getResources(), emptyImage);
			} else if(existingDrawable instanceof TransitionDrawable) {
				// This should only ever be used if user is skipping through many songs quickly
				TransitionDrawable tmp = (TransitionDrawable) existingDrawable;
				existingDrawable = tmp.getDrawable(tmp.getNumberOfLayers() - 1);
			}
			if(existingDrawable != null && drawable != null) {
				Drawable[] layers = new Drawable[]{existingDrawable, drawable};
				final TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
				imageView.setImageDrawable(transitionDrawable);
				transitionDrawable.startTransition(250);

				// Get rid of transition drawable after transition occurs
				handler.postDelayed(new Runnable() {
					@Override
					public void run() {
						// Only execute if still on same transition drawable
						if (imageView.getDrawable() == transitionDrawable) {
							imageView.setImageDrawable(drawable);
						}
					}
				}, 500L);
			} else {
				imageView.setImageDrawable(drawable);
			}
		} else {
			imageView.setImageDrawable(drawable);
		}
	}
}
 
开发者ID:nvllsvm,项目名称:Audinaut,代码行数:47,代码来源:ImageLoader.java


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