本文整理汇总了Java中android.graphics.drawable.Animatable类的典型用法代码示例。如果您正苦于以下问题:Java Animatable类的具体用法?Java Animatable怎么用?Java Animatable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Animatable类属于android.graphics.drawable包,在下文中一共展示了Animatable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("Anim Items");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (menu != null) {
for (int i = 0; i < menu.size(); i++) {
Drawable drawable = menu.getItem(i).getIcon();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
}
}
}
});
}
示例2: onOptionsItemSelected
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Drawable drawable = item.getIcon();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
switch (item.getItemId()) {
case R.id.action_cut:
return true;
case R.id.action_copy:
return true;
case R.id.action_share:
return true;
case R.id.action_delete:
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例3: onFinish
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
public int onFinish(RefreshLayout layout, boolean success) {
if (mProgressDrawable != null) {
mProgressDrawable.stop();
} else {
Drawable drawable = mProgressView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).stop();
} else {
mProgressView.animate().rotation(0).setDuration(300);
}
}
mProgressView.setVisibility(GONE);
if (success) {
mTitleText.setText(REFRESH_HEADER_FINISH);
setLastUpdateTime(new Date());
} else {
mTitleText.setText(REFRESH_HEADER_FAILED);
}
return mFinishDuration;//延迟500毫秒之后再弹回
}
示例4: convert
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Nullable
static Resource<Bitmap> convert(BitmapPool bitmapPool, Drawable drawable, int width, int height) {
// Handle DrawableContainer or StateListDrawables that may contain one or more BitmapDrawables.
drawable = drawable.getCurrent();
Bitmap result = null;
boolean isRecycleable = false;
if (drawable instanceof BitmapDrawable) {
result = ((BitmapDrawable) drawable).getBitmap();
} else if (!(drawable instanceof Animatable)) {
result = drawToBitmap(bitmapPool, drawable, width, height);
// We created and drew to the Bitmap, so it's safe for us to recycle or re-use.
isRecycleable = true;
}
BitmapPool toUse = isRecycleable ? bitmapPool : NO_RECYCLE_BITMAP_POOL;
return BitmapResource.obtain(result, toUse);
}
示例5: setProgress
import android.graphics.drawable.Animatable; //导入依赖的package包/类
private void setProgress(float progress) {
Drawable progressBarDrawable = mFadeDrawable.getDrawable(PROGRESS_BAR_IMAGE_INDEX);
if (progressBarDrawable == null) {
return;
}
// display progressbar when not fully loaded, hide otherwise
if (progress >= 0.999f) {
if (progressBarDrawable instanceof Animatable) {
((Animatable) progressBarDrawable).stop();
}
fadeOutLayer(PROGRESS_BAR_IMAGE_INDEX);
} else {
if (progressBarDrawable instanceof Animatable) {
((Animatable) progressBarDrawable).start();
}
fadeInLayer(PROGRESS_BAR_IMAGE_INDEX);
}
// set drawable level, scaled to [0, 10000] per drawable specification
progressBarDrawable.setLevel(Math.round(progress * 10000));
}
示例6: drawTrack
import android.graphics.drawable.Animatable; //导入依赖的package包/类
void drawTrack(Canvas canvas) {
final Drawable d = mIndicator;
if (d != null) {
// Translate canvas so a indeterminate circular progress bar with padding
// rotates properly in its animation
final int saveCount = canvas.save();
canvas.translate(getPaddingLeft(), getPaddingTop());
d.draw(canvas);
canvas.restoreToCount(saveCount);
if (mShouldStartAnimationDrawable && d instanceof Animatable) {
((Animatable) d).start();
mShouldStartAnimationDrawable = false;
}
}
}
示例7: onFinalImageSet
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
public synchronized void onFinalImageSet(
String id,
@Nullable INFO imageInfo,
@Nullable Animatable animatable) {
final int numberOfListeners = mListeners.size();
for (int i = 0; i < numberOfListeners; ++i) {
try {
ControllerListener<? super INFO> listener = mListeners.get(i);
if (listener != null) {
listener.onFinalImageSet(id, imageInfo, animatable);
}
} catch (Exception exception) {
// Don't punish the other listeners if we're given a bad one.
onException("InternalListener exception in onFinalImageSet", exception);
}
}
}
示例8: init
import android.graphics.drawable.Animatable; //导入依赖的package包/类
private void init() {
mInstrumentation = new Instrumentation(this);
mListener = new BaseControllerListener<Object>() {
@Override
public void onSubmit(String id, Object callerContext) {
mInstrumentation.onStart();
}
@Override
public void onFinalImageSet(
String id,
@Nullable Object imageInfo,
@Nullable Animatable animatable) {
mInstrumentation.onSuccess();
}
@Override
public void onFailure(String id, Throwable throwable) {
mInstrumentation.onFailure();
}
@Override
public void onRelease(String id) {
mInstrumentation.onCancellation();
}
};
}
示例9: onFinish
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
public int onFinish(RefreshLayout layout, boolean success) {
if (mProgressDrawable != null) {
mProgressDrawable.stop();
} else {
Drawable drawable = mProgressView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).stop();
} else {
mProgressView.animate().rotation(0).setDuration(300);
}
}
mProgressView.setVisibility(GONE);
if (success) {
mTitleText.setText(REFRESH_HEADER_FINISH);
if (mLastTime != null) {
setLastUpdateTime(new Date());
}
} else {
mTitleText.setText(REFRESH_HEADER_FAILED);
}
return mFinishDuration;//延迟500毫秒之后再弹回
}
示例10: onCreate
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ButterKnife.bind(this);
Uri uri = Uri.parse("asset:///splash.webp");
mSplashPresenter = new SplashPresenterImpl(this);
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(uri)
.setAutoPlayAnimations(true)
.setControllerListener(new BaseControllerListener<ImageInfo>(){
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
super.onFinalImageSet(id, imageInfo, animatable);
mSplashPresenter.startCountDown(1);
}
})
.build();
splashDraweee.setController(controller);
}
示例11: drawTrack
import android.graphics.drawable.Animatable; //导入依赖的package包/类
void drawTrack(Canvas canvas) {
final Drawable d = DEFAULT_ANIMATION;
if (d != null) {
// Translate canvas so a indeterminate circular progress bar with padding
// rotates properly in its animation
final int saveCount = canvas.save();
canvas.translate(getPaddingLeft(), getPaddingTop());
d.draw(canvas);
canvas.restoreToCount(saveCount);
if (mShouldStartAnimationDrawable && d instanceof Animatable) {
((Animatable) d).start();
mShouldStartAnimationDrawable = false;
}
}
}
示例12: onStart
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
// Animate checkmark
mFinalCheckmarkImageView.postDelayed(new Runnable() {
@Override
public void run() {
mFinalCheckmarkImageView.setVisibility(View.VISIBLE);
Drawable drawable = mFinalCheckmarkImageView.getDrawable();
((Animatable) drawable).start();
playGoodJob();
}
}, DEFAULT_PLAYER_DELAY);
}
示例13: setCallback2
import android.graphics.drawable.Animatable; //导入依赖的package包/类
public void setCallback2(@Nullable Callback callback) {
this.callback = callback;
super.setCallback(callback);
// if not null -> means we are attached
if (callback != null) {
loader.load(destination, this);
} else {
if (result != null) {
result.setCallback(null);
// let's additionally stop if it Animatable
if (result instanceof Animatable) {
((Animatable) result).stop();
}
}
loader.cancel(destination);
}
}
示例14: onOptionsItemSelected
import android.graphics.drawable.Animatable; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_list_to_grid) {
if (!((Animatable) item.getIcon()).isRunning()) {
if (gridLayoutManager.getSpanCount() == 1) {
item.setIcon(AnimatedVectorDrawableCompat.create(MainActivity.this, R.drawable.avd_list_to_grid));
gridLayoutManager.setSpanCount(3);
} else {
item.setIcon(AnimatedVectorDrawableCompat.create(MainActivity.this, R.drawable.avd_grid_to_list));
gridLayoutManager.setSpanCount(1);
}
((Animatable) item.getIcon()).start();
simpleAdapter.notifyItemRangeChanged(0, simpleAdapter.getItemCount());
}
return true;
}
return super.onOptionsItemSelected(item);
}
示例15: loadImage
import android.graphics.drawable.Animatable; //导入依赖的package包/类
public static void loadImage(final PhotoDraweeView mPhotoDraweeView,
Uri uri) {
PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
controller.setUri(uri);
controller.setAutoPlayAnimations(true);
controller.setOldController(mPhotoDraweeView.getController());
controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
super.onFinalImageSet(id, imageInfo, animatable);
if (imageInfo == null || mPhotoDraweeView == null) {
return;
}
mPhotoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
}
});
mPhotoDraweeView.setController(controller.build());
}