Search in sources :

Example 41 with Animatable

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);
}
Also used : BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) QualityInfo(com.facebook.imagepipeline.image.QualityInfo) ImageInfo(com.facebook.imagepipeline.image.ImageInfo)

Example 42 with Animatable

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;
        }
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) ClipDrawable(android.graphics.drawable.ClipDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Animatable(android.graphics.drawable.Animatable)

Example 43 with Animatable

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()));
    }
}
Also used : BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) ControllerListener(com.facebook.drawee.controller.ControllerListener) QualityInfo(com.facebook.imagepipeline.image.QualityInfo) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) Uri(android.net.Uri) Nullable(android.support.annotation.Nullable)

Example 44 with Animatable

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;
}
Also used : Drawable(android.graphics.drawable.Drawable) SelectedStateListDrawable(com.yalantis.ucrop.util.SelectedStateListDrawable) Animatable(android.graphics.drawable.Animatable) MenuItem(android.view.MenuItem)

Example 45 with Animatable

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();
}
Also used : LinearProgressDrawable(com.rey.material.drawable.LinearProgressDrawable) TypedArray(android.content.res.TypedArray) CircularProgressDrawable(com.rey.material.drawable.CircularProgressDrawable) Animatable(android.graphics.drawable.Animatable)

Aggregations

Animatable (android.graphics.drawable.Animatable)67 Drawable (android.graphics.drawable.Drawable)34 AnimationDrawable (android.graphics.drawable.AnimationDrawable)17 BitmapDrawable (android.graphics.drawable.BitmapDrawable)17 ClipDrawable (android.graphics.drawable.ClipDrawable)17 LayerDrawable (android.graphics.drawable.LayerDrawable)17 AlphaAnimation (android.view.animation.AlphaAnimation)17 LinearInterpolator (android.view.animation.LinearInterpolator)17 Transformation (android.view.animation.Transformation)17 ShapeDrawable (android.graphics.drawable.ShapeDrawable)12 StateListDrawable (android.graphics.drawable.StateListDrawable)9 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)8 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)7 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)6 DraweeController (com.facebook.drawee.interfaces.DraweeController)5 QualityInfo (com.facebook.imagepipeline.image.QualityInfo)4 Uri (android.net.Uri)3 Nullable (android.support.annotation.Nullable)3 ControllerListener (com.facebook.drawee.controller.ControllerListener)3 View (android.view.View)2