use of android.graphics.drawable.Animatable in project fresco by facebook.
the class ImageFormatProgressiveJpegFragment method setImageUri.
private void setImageUri(Uri uri) {
mDebugOutput.setText("");
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setProgressiveRenderingEnabled(mProgressiveRenderingEnabled).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setRetainImageOnFailure(true).setControllerListener(new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @javax.annotation.Nullable ImageInfo imageInfo, @javax.annotation.Nullable Animatable animatable) {
if (imageInfo != null) {
QualityInfo qualityInfo = imageInfo.getQualityInfo();
logScan(qualityInfo, true);
}
}
@Override
public void onIntermediateImageSet(String id, @javax.annotation.Nullable ImageInfo imageInfo) {
if (imageInfo != null) {
QualityInfo qualityInfo = imageInfo.getQualityInfo();
logScan(qualityInfo, false);
}
}
@Override
public void onIntermediateImageFailed(String id, Throwable throwable) {
mDebugOutput.append(String.format(Locale.getDefault(), "onIntermediateImageFailed, %s\n", throwable.getMessage()));
}
}).build();
mSimpleDraweeView.setController(controller);
}
use of android.graphics.drawable.Animatable in project Libraries-for-Android-Developers by eoecn.
the class IcsProgressBar method onDraw.
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
Drawable d = mCurrentDrawable;
if (d != null) {
// Translate canvas so a indeterminate circular progress bar with padding
// rotates properly in its animation
canvas.save();
canvas.translate(getPaddingLeft() + mIndeterminateRealLeft, getPaddingTop() + mIndeterminateRealTop);
long time = getDrawingTime();
if (mAnimation != null) {
mAnimation.getTransformation(time, mTransformation);
float scale = mTransformation.getAlpha();
try {
mInDrawing = true;
d.setLevel((int) (scale * MAX_LEVEL));
} finally {
mInDrawing = false;
}
if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) {
mLastDrawTime = SystemClock.uptimeMillis();
postInvalidateDelayed(mAnimationResolution);
}
}
d.draw(canvas);
canvas.restore();
if (mShouldStartAnimationDrawable && d instanceof Animatable) {
((Animatable) d).start();
mShouldStartAnimationDrawable = false;
}
}
}
use of android.graphics.drawable.Animatable in project remusic by aa112901.
the class QuickControlsFragment method updateNowplayingCard.
public void updateNowplayingCard() {
mTitle.setText(MusicPlayer.getTrackName());
mArtist.setText(MusicPlayer.getArtistName());
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
if (imageInfo == null) {
return;
}
QualityInfo qualityInfo = imageInfo.getQualityInfo();
FLog.d("Final image received! " + "Size %d x %d", "Quality level %d, good enough: %s, full quality: %s", imageInfo.getWidth(), imageInfo.getHeight(), qualityInfo.getQuality(), qualityInfo.isOfGoodEnoughQuality(), qualityInfo.isOfFullQuality());
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
//FLog.d("Intermediate image received");
}
@Override
public void onFailure(String id, Throwable throwable) {
mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
}
};
Uri uri = null;
try {
uri = Uri.parse(MusicPlayer.getAlbumPath());
} catch (Exception e) {
e.printStackTrace();
}
if (uri != null) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mAlbumArt.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
mAlbumArt.setController(controller);
} else {
mAlbumArt.setImageURI(Uri.parse("content://" + MusicPlayer.getAlbumPath()));
}
}
use of android.graphics.drawable.Animatable in project uCrop by Yalantis.
the class UCropActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.ucrop_menu_activity, menu);
// Change crop & loader menu icons color to match the rest of the UI colors
MenuItem menuItemLoader = menu.findItem(R.id.menu_loader);
Drawable menuItemLoaderIcon = menuItemLoader.getIcon();
if (menuItemLoaderIcon != null) {
try {
menuItemLoaderIcon.mutate();
menuItemLoaderIcon.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
menuItemLoader.setIcon(menuItemLoaderIcon);
} catch (IllegalStateException e) {
Log.i(TAG, String.format("%s - %s", e.getMessage(), getString(R.string.ucrop_mutate_exception_hint)));
}
((Animatable) menuItemLoader.getIcon()).start();
}
MenuItem menuItemCrop = menu.findItem(R.id.menu_crop);
Drawable menuItemCropIcon = ContextCompat.getDrawable(this, mToolbarCropDrawable);
if (menuItemCropIcon != null) {
menuItemCropIcon.mutate();
menuItemCropIcon.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
menuItemCrop.setIcon(menuItemCropIcon);
}
return true;
}
use of android.graphics.drawable.Animatable in project material by rey5137.
the class ProgressView method applyStyle.
protected void applyStyle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ProgressView, defStyleAttr, defStyleRes);
int progressId = 0;
int progressMode = -1;
float progress = -1;
float secondaryProgress = -1;
for (int i = 0, count = a.getIndexCount(); i < count; i++) {
int attr = a.getIndex(i);
if (attr == R.styleable.ProgressView_pv_autostart)
mAutostart = a.getBoolean(attr, false);
else if (attr == R.styleable.ProgressView_pv_circular)
mCircular = a.getBoolean(attr, true);
else if (attr == R.styleable.ProgressView_pv_progressStyle)
progressId = a.getResourceId(attr, 0);
else if (attr == R.styleable.ProgressView_pv_progressMode)
progressMode = a.getInteger(attr, 0);
else if (attr == R.styleable.ProgressView_pv_progress)
progress = a.getFloat(attr, 0);
else if (attr == R.styleable.ProgressView_pv_secondaryProgress)
secondaryProgress = a.getFloat(attr, 0);
}
a.recycle();
boolean needStart = false;
if (needCreateProgress(mCircular)) {
mProgressId = progressId;
if (mProgressId == 0)
mProgressId = mCircular ? R.style.Material_Drawable_CircularProgress : R.style.Material_Drawable_LinearProgress;
needStart = mProgressDrawable != null && ((Animatable) mProgressDrawable).isRunning();
mProgressDrawable = mCircular ? new CircularProgressDrawable.Builder(context, mProgressId).build() : new LinearProgressDrawable.Builder(context, mProgressId).build();
ViewUtil.setBackground(this, mProgressDrawable);
} else if (mProgressId != progressId) {
mProgressId = progressId;
if (mProgressDrawable instanceof CircularProgressDrawable)
((CircularProgressDrawable) mProgressDrawable).applyStyle(context, mProgressId);
else
((LinearProgressDrawable) mProgressDrawable).applyStyle(context, mProgressId);
}
if (progressMode >= 0) {
if (mProgressDrawable instanceof CircularProgressDrawable)
((CircularProgressDrawable) mProgressDrawable).setProgressMode(progressMode);
else
((LinearProgressDrawable) mProgressDrawable).setProgressMode(progressMode);
}
if (progress >= 0)
setProgress(progress);
if (secondaryProgress >= 0)
setSecondaryProgress(secondaryProgress);
if (needStart)
start();
}
Aggregations