项目:GitHub
文件:MainActivity.java
@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();
}
}
}
}
});
}
项目:GitHub
文件:MainActivity.java
@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);
}
}
项目:GitHub
文件:ClassicsHeader.java
@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毫秒之后再弹回
}
@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);
}
项目:GitHub
文件:GenericDraweeHierarchy.java
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));
}
项目:RLibrary
文件:AVLoadingIndicatorView.java
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;
}
}
}
项目:GitHub
文件:ForwardingControllerListener.java
@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);
}
}
}
项目:GitHub
文件:InstrumentedDraweeView.java
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();
}
};
}
项目:Rxjava2.0Demo
文件:ClassicsHeader.java
@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毫秒之后再弹回
}
项目:RunMap
文件:SplashActivity.java
@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,animatable);
mSplashPresenter.startCountDown(1);
}
})
.build();
splashDraweee.setController(controller);
}
项目:SRecyclerView
文件:AVLoadingIndicatorView.java
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;
}
}
}
项目:UltimateRecyclerView
文件:RecyclerViewLoadingView.java
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;
}
}
}
项目:start-guide
文件:FinalActivity.java
@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);
}
@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);
}
}
项目:android-animated-menu-items
文件:MainActivity.java
@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();
}
}
}
}
});
}
项目:VirtualHook
文件:LoadingIndicatorView.java
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;
}
}
}
项目:android-mvvm-architecture
文件:MainActivity.java
@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);
}
}
项目:Markwon
文件:AsyncDrawable.java
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);
}
}
项目:android-mvp-architecture
文件:MainActivity.java
@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);
}
}
项目:android-list-to-grid
文件:MainActivity.java
@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);
}
项目:react-native-udesk
文件:UdeskUtil.java
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,animatable);
if (imageInfo == null || mPhotoDraweeView == null) {
return;
}
mPhotoDraweeView.update(imageInfo.getWidth(),imageInfo.getHeight());
}
});
mPhotoDraweeView.setController(controller.build());
}
项目:Animated-Vector-Drawables
文件:Bindings.java
@BindingAdapter("animateOnClick")
public static void setAnimateOnClick(final ImageView view,final Drawable backDrawable) {
final Animatable front = (Animatable) view.getDrawable();
view.setonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (null == backDrawable) {
front.start();
} else {
if (null == view.getTag()) {
view.setimageDrawable((Drawable) front);
front.start();
view.setTag(0);
} else {
view.setimageDrawable(backDrawable);
((Animatable) backDrawable).start();
view.setTag(null);
}
}
}
});
}
项目:SmartRefreshLayout
文件:ClassicsHeader.java
@Override
public int onFinish(@NonNull 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毫秒之后再弹回
}
项目:Camera-Roll-Android-App
文件:MainActivity.java
public void fabClicked(View v) {
if (v instanceof FloatingActionButton) {
FloatingActionButton fab = (FloatingActionButton) v;
Drawable drawable = fab.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent();
i.setAction(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
if (i.resolveActivity(getPackageManager()) != null) {
startActivity(i);
} else {
Toast.makeText(MainActivity.this,getString(R.string.error),Toast.LENGTH_SHORT).show();
}
}
},(int) (500 * Util.getAnimatorSpeed(this)));
}
@Override
public boolean onoptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackpressed();
break;
case R.id.rotate:
Drawable d = item.getIcon();
if (d instanceof Animatable && !((Animatable) d).isRunning()) {
((Animatable) d).start();
}
rotate90degrees();
break;
case R.id.done:
done(item.getActionView());
break;
case R.id.restore:
CropImageView imageView = findViewById(R.id.cropImageView);
imageView.restore();
break;
default:
break;
}
return super.onoptionsItemSelected(item);
}
项目:QuickDrawEverywhere
文件:TapBarMenu.java
/**
* Open the menu.
*/
public void open() {
state = State.OPENED;
showIcons(true);
animator[LEFT].setFloatValues(button[LEFT],0);
animator[RIGHT].setFloatValues(button[RIGHT],width);
animator[RADIUS].setFloatValues(button[RADIUS],0);
animator[TOP].setFloatValues(button[TOP],0);
animator[BottOM].setFloatValues(button[BottOM],height);
animatorSet.cancel();
animatorSet.start();
if (iconopenedDrawable instanceof Animatable) {
((Animatable) iconopenedDrawable).start();
}
ViewGroup parentView = (ViewGroup) TapBarMenu.this.getParent();
this.animate()
.y(menuAnchor == MENU_ANCHOR_BottOM ? parentView.getBottom() - height : 0)
.setDuration(animationDuration)
.setInterpolator(DECELERATE_INTERPOLATOR)
.start();
}
项目:QuickDrawEverywhere
文件:TapBarMenu.java
/**
* Close the menu.
*/
public void close() {
updateDimensions(width,height);
state = State.CLOSED;
showIcons(false);
animator[LEFT].setFloatValues(0,button[LEFT]);
animator[RIGHT].setFloatValues(width,button[RIGHT]);
animator[RADIUS].setFloatValues(0,button[RADIUS]);
animator[TOP].setFloatValues(0,button[TOP]);
animator[BottOM].setFloatValues(height,button[BottOM]);
animatorSet.cancel();
animatorSet.start();
if (iconClosedDrawable instanceof Animatable) {
((Animatable) iconClosedDrawable).start();
}
this.animate()
.y(yPosition)
.setDuration(animationDuration)
.setInterpolator(DECELERATE_INTERPOLATOR)
.start();
}
项目:QuickDrawEverywhere
文件:TapBarMenu.java
private void updateDimensions(float w,float h) {
int ratio;
width = w;
height = h;
button[RADIUS] = buttonSize;
setButtonPosition(width);
if (iconClosedDrawable instanceof Animatable) {
ratio = 3;
} else {
ratio = 5;
}
float iconLeft = button[LEFT] + buttonSize / ratio;
float iconTop = (height - buttonSize) / 2 + buttonSize / ratio;
float iconRight = button[RIGHT] - buttonSize / ratio;
float iconBottom = (height + buttonSize) / 2 - buttonSize / ratio;
iconopenedDrawable
.setBounds((int) iconLeft,(int) iconTop,(int) iconRight,(int) iconBottom);
iconClosedDrawable
.setBounds((int) iconLeft,(int) iconBottom);
}
项目:MenuSet
文件:TapBarMenu.java
/**
* Open the menu.
*/
public void open() {
state = State.OPENED;
showIcons(true);
animator[LEFT].setFloatValues(button[LEFT],0);
animator[RIGHT].setFloatValues(button[RIGHT],width);
animator[RADIUS].setFloatValues(button[RADIUS],0);
animator[TOP].setFloatValues(button[TOP],0);
animator[BottOM].setFloatValues(button[BottOM],height);
animatorSet.cancel();
animatorSet.start();
if (iconopenedDrawable instanceof Animatable) {
((Animatable) iconopenedDrawable).start();
}
ViewGroup parentView = (ViewGroup) TapBarMenu.this.getParent();
this.animate()
.y(menuAnchor == MENU_ANCHOR_BottOM ? parentView.getBottom() - height : 0)
.setDuration(animationDuration)
.setInterpolator(DECELERATE_INTERPOLATOR)
.start();
}
项目:MenuSet
文件:TapBarMenu.java
/**
* Close the menu.
*/
public void close() {
updateDimensions(width,height);
state = State.CLOSED;
showIcons(false);
animator[LEFT].setFloatValues(0,button[LEFT]);
animator[RIGHT].setFloatValues(width,button[RIGHT]);
animator[RADIUS].setFloatValues(0,button[RADIUS]);
animator[TOP].setFloatValues(0,button[TOP]);
animator[BottOM].setFloatValues(height,button[BottOM]);
animatorSet.cancel();
animatorSet.start();
if (iconClosedDrawable instanceof Animatable) {
((Animatable) iconClosedDrawable).start();
}
this.animate()
.y(yPosition)
.setDuration(animationDuration)
.setInterpolator(DECELERATE_INTERPOLATOR)
.start();
}
项目:MenuSet
文件:TapBarMenu.java
private void updateDimensions(float w,float h) {
int ratio;
width = w;
height = h;
button[RADIUS] = buttonSize;
setButtonPosition(width);
if (iconClosedDrawable instanceof Animatable) {
ratio = 3;
} else {
ratio = 5;
}
float iconLeft = button[LEFT] + buttonSize / ratio;
float iconTop = (height - buttonSize) / 2 + buttonSize / ratio;
float iconRight = button[RIGHT] - buttonSize / ratio;
float iconBottom = (height + buttonSize) / 2 - buttonSize / ratio;
iconopenedDrawable.setBounds((int) iconLeft,(int) iconBottom);
iconClosedDrawable.setBounds((int) iconLeft,(int) iconBottom);
}
项目:GitHub
文件:ImageViewTarget.java
private void maybeUpdateAnimatable(@Nullable Z resource) {
if (resource instanceof Animatable) {
animatable = (Animatable) resource;
animatable.start();
} else {
animatable = null;
}
}
项目:GitHub
文件:MainActivity.java
项目:GitHub
文件:ProgressImageView.java
public void start() {
setVisibility(View.VISIBLE);
Animatable animatable = (Animatable) getDrawable();
if (!animatable.isRunning()) {
animatable.start();
}
}
项目:GitHub
文件:ProgressImageView.java
public void stop() {
Animatable animatable = (Animatable) getDrawable();
if (animatable.isRunning()) {
animatable.stop();
}
setVisibility(View.GONE);
}
项目:GitHub
文件:ClassicsHeader.java
@Override
public void onRefreshReleased(RefreshLayout layout,int headerHeight,int extendHeight) {
if (mProgressDrawable != null) {
mProgressDrawable.start();
} else {
Drawable drawable = mProgressView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
} else {
mProgressView.animate().rotation(36000).setDuration(100000);
}
}
}
项目:GitHub
文件:PicassoDrawable.java
/**
* Create or update the drawable on the target {@link ImageView} to display the supplied bitmap
* image.
*/
static void setBitmap(ImageView target,Context context,Bitmap bitmap,Picasso.LoadedFrom loadedFrom,boolean noFade,boolean debugging) {
Drawable placeholder = target.getDrawable();
if (placeholder instanceof Animatable) {
((Animatable) placeholder).stop();
}
PicassoDrawable drawable =
new PicassoDrawable(context,bitmap,placeholder,loadedFrom,noFade,debugging);
target.setimageDrawable(drawable);
}
项目:GitHub
文件:PicassoDrawable.java
/**
* Create or update the drawable on the target {@link ImageView} to display the supplied
* placeholder image.
*/
static void setPlaceholder(ImageView target,Drawable placeholderDrawable) {
target.setimageDrawable(placeholderDrawable);
if (target.getDrawable() instanceof Animatable) {
((Animatable) target.getDrawable()).start();
}
}
项目:GitHub
文件:DraweeSpanStringBuilder.java
@Override
public void onFinalimageset(
String id,Animatable animatable) {
if (mEnableResizing &&
imageInfo != null &&
mDraweeSpan.getDraweeHolder().getTopLevelDrawable() != null) {
Drawable topLevelDrawable = mDraweeSpan.getDraweeHolder().getTopLevelDrawable();
Rect topLevelDrawableBounds = topLevelDrawable.getBounds();
if (mFixedHeight != UNSET_SIZE) {
float imageWidth = ((float) mFixedHeight / imageInfo.getHeight()) * imageInfo.getWidth();
int imageWidthPx = (int) imageWidth;
if (topLevelDrawableBounds.width() != imageWidthPx ||
topLevelDrawableBounds.height() != mFixedHeight) {
topLevelDrawable.setBounds(0,imageWidthPx,mFixedHeight);
if (mDraweeSpanChangedListener != null) {
mDraweeSpanChangedListener.onDraweeSpanChanged(DraweeSpanStringBuilder.this);
}
}
} else if (topLevelDrawableBounds.width() != imageInfo.getWidth() ||
topLevelDrawableBounds.height() != imageInfo.getHeight()) {
topLevelDrawable.setBounds(0,imageInfo.getWidth(),imageInfo.getHeight());
if (mDraweeSpanChangedListener != null) {
mDraweeSpanChangedListener.onDraweeSpanChanged(DraweeSpanStringBuilder.this);
}
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。