Search in sources :

Example 36 with AnimatedVectorDrawable

use of android.graphics.drawable.AnimatedVectorDrawable in project animate by hitherejoe.

the class AnimatedVectorDrawablesActivity method onAddRemoveImageClick.

@OnClick(R.id.image_add_remove)
public void onAddRemoveImageClick() {
    AnimatedVectorDrawable drawable = mIsAddState ? mRemoveToAddDrawable : mAddToRemoveDrawable;
    mAddRemoveImage.setImageDrawable(drawable);
    drawable.start();
    mIsAddState = !mIsAddState;
}
Also used : AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) OnClick(butterknife.OnClick)

Example 37 with AnimatedVectorDrawable

use of android.graphics.drawable.AnimatedVectorDrawable in project Music-Player by andremion.

the class PlayButtonTransition method createAnimator.

@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
    if (endValues == null || !(endValues.view instanceof FloatingActionButton)) {
        return null;
    }
    FloatingActionButton fabView = (FloatingActionButton) endValues.view;
    Context context = fabView.getContext();
    AnimatedVectorDrawable drawable;
    if (mMode == MODE_PLAY) {
        drawable = (AnimatedVectorDrawable) context.getDrawable(R.drawable.ic_play_animatable);
    } else {
        drawable = (AnimatedVectorDrawable) context.getDrawable(R.drawable.ic_pause_animatable);
    }
    fabView.setImageDrawable(drawable);
    return new AnimatedVectorDrawableWrapper(drawable);
}
Also used : Context(android.content.Context) FloatingActionButton(android.support.design.widget.FloatingActionButton) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable)

Example 38 with AnimatedVectorDrawable

use of android.graphics.drawable.AnimatedVectorDrawable in project platform_frameworks_base by android.

the class VolumeDialog method updateExpandButtonH.

private void updateExpandButtonH() {
    if (D.BUG)
        Log.d(TAG, "updateExpandButtonH");
    mExpandButton.setClickable(!mExpandButtonAnimationRunning);
    if (!(mExpandButtonAnimationRunning && isAttached())) {
        final int res = mExpanded ? R.drawable.ic_volume_collapse_animation : R.drawable.ic_volume_expand_animation;
        if (hasTouchFeature()) {
            mExpandButton.setImageResource(res);
        } else {
            // if there is no touch feature, show the volume ringer instead
            mExpandButton.setImageResource(R.drawable.ic_volume_ringer);
            // remove gray background emphasis
            mExpandButton.setBackgroundResource(0);
        }
        mExpandButton.setContentDescription(mContext.getString(mExpanded ? R.string.accessibility_volume_collapse : R.string.accessibility_volume_expand));
    }
    if (mExpandButtonAnimationRunning) {
        final Drawable d = mExpandButton.getDrawable();
        if (d instanceof AnimatedVectorDrawable) {
            // workaround to reset drawable
            final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) d.getConstantState().newDrawable();
            mExpandButton.setImageDrawable(avd);
            avd.start();
            mHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mExpandButtonAnimationRunning = false;
                    updateExpandButtonH();
                    rescheduleTimeoutH();
                }
            }, mExpandButtonAnimationDuration);
        }
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable) SuppressLint(android.annotation.SuppressLint) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable)

Example 39 with AnimatedVectorDrawable

use of android.graphics.drawable.AnimatedVectorDrawable in project plaid by nickbutcher.

the class HomeActivity method checkConnectivity.

private void checkConnectivity() {
    final ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    connected = activeNetworkInfo != null && activeNetworkInfo.isConnected();
    if (!connected) {
        loading.setVisibility(View.GONE);
        if (noConnection == null) {
            final ViewStub stub = (ViewStub) findViewById(R.id.stub_no_connection);
            noConnection = (ImageView) stub.inflate();
        }
        final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_no_connection);
        if (noConnection != null && avd != null) {
            noConnection.setImageDrawable(avd);
            avd.start();
        }
        connectivityManager.registerNetworkCallback(new NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(), connectivityCallback);
        monitoringConnectivity = true;
    }
}
Also used : ViewStub(android.view.ViewStub) NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) NetworkRequest(android.net.NetworkRequest) AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable)

Example 40 with AnimatedVectorDrawable

use of android.graphics.drawable.AnimatedVectorDrawable in project platform_frameworks_base by android.

the class PageIndicator method playAnimation.

private void playAnimation(ImageView imageView, int res) {
    final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getContext().getDrawable(res);
    imageView.setImageDrawable(avd);
    avd.forceAnimationOnUI();
    avd.start();
    // TODO: Figure out how to user an AVD animation callback instead, which doesn't
    // seem to be working right now...
    postDelayed(mAnimationDone, ANIMATION_DURATION);
}
Also used : AnimatedVectorDrawable(android.graphics.drawable.AnimatedVectorDrawable)

Aggregations

AnimatedVectorDrawable (android.graphics.drawable.AnimatedVectorDrawable)56 Drawable (android.graphics.drawable.Drawable)18 TextView (android.widget.TextView)9 Resources (android.content.res.Resources)8 Button (android.widget.Button)8 GridLayout (android.widget.GridLayout)8 ScrollView (android.widget.ScrollView)8 SuppressLint (android.annotation.SuppressLint)5 ColorDrawable (android.graphics.drawable.ColorDrawable)5 InsetDrawable (android.graphics.drawable.InsetDrawable)5 ImageView (android.widget.ImageView)5 Paint (android.graphics.Paint)4 Animatable2 (android.graphics.drawable.Animatable2)4 BitmapDrawable (android.graphics.drawable.BitmapDrawable)4 LayerDrawable (android.graphics.drawable.LayerDrawable)4 AttributeSet (android.util.AttributeSet)4 IOException (java.io.IOException)4 DecimalFormat (java.text.DecimalFormat)4 XmlPullParser (org.xmlpull.v1.XmlPullParser)4 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)4