Java 类android.graphics.drawable.AnimatedVectorDrawable 实例源码

项目:Quadro    文件:ExploreActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_explore);
    iv = (ImageView) findViewById(R.id.search);
    text = (EditText) findViewById(R.id.text);
    searchToBar = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_search_to_bar);
    barToSearch = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_bar_to_search);
    interp = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in);
    duration = getResources().getInteger(R.integer.duration_bar);
    // iv is sized to hold the search+bar so when only showing the search icon, translate the
    // whole view left by half the difference to keep it centered
    offset = -71f * (int) getResources().getDisplayMetrics().scaledDensity;
    iv.setTranslationX(offset);
    iv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            animate();
        }
    });
}
项目:android-WearAccessibilityApp    文件:OpenOnPhoneAnimationActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_on_phone_animation);

    AmbientMode.attachAmbientSupport(this);

    mAnimationCallback =
            new AnimationCallback() {
                @Override
                public void onAnimationEnd(Drawable drawable) {
                    super.onAnimationEnd(drawable);
                    // Go back to main Dialogs screen after animation.
                    finish();
                }
            };

    // Play 'swipe left' animation only once.
    ImageView phoneImage = findViewById(R.id.open_on_phone_animation_image);
    mAnimatedVectorDrawablePhone = (AnimatedVectorDrawable) phoneImage.getDrawable();
    mAnimatedVectorDrawablePhone.registerAnimationCallback(mAnimationCallback);
    mAnimatedVectorDrawablePhone.start();
}
项目:betterHotels    文件:NoHotelsActivity.java   
@TargetApi(Build.VERSION_CODES.M)
private void initUi() {
    initializeToolbar();

    final AnimatedVectorDrawable avd2 = (AnimatedVectorDrawable) tvButton.getBackground();

    tvButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            tvButton.setText("Loading...");
            avd2.start();
        }
    });

    avd2.registerAnimationCallback(new Animatable2.AnimationCallback() {
        @Override
        public void onAnimationEnd(Drawable drawable) {
            tvButton.setText("Try Again");
        }
    });

}
项目:iosched-reader    文件:SocialFragment.java   
@TargetApi(21)
private void setupLogoAnim() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final ImageView iv = (ImageView) getActivity().findViewById(R.id.io_logo);
        final AnimatedVectorDrawable logoAnim =
                (AnimatedVectorDrawable) getActivity().getDrawable(
                        R.drawable.io_logo_social_anim);
        iv.setImageDrawable(logoAnim);
        logoAnim.start();
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                logoAnim.start();
            }
        });
    }
}
项目:UdacityAndroidBasicsNanodegree    文件:HabitAdapter.java   
@Override
public void onBindViewHolder(final HabitViewHolder holder, int position) {

    final Habit habit = habits.get(position);

    holder.habitName.setText(habit.name);
    holder.count.setText(String.format(Locale.getDefault(), "%d", habit.timesCompleted));
    holder.timesPerDay.setText(context.getString(R.string.times_per_day, habit.timesPerDay));

    holder.doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((AnimatedVectorDrawable) holder.doneButton.getDrawable()).start();
            dbHelper.incrementHabit(habit.name);
            Storage.incrementHabit(context, habit.name);
        }
    });
}
项目:android-samples    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ImageView mFabView = (ImageView) findViewById(R.id.fab_view);

    // animate head to leaf
    final AnimatedVectorDrawable faceAVD = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.face_avd);
    mFabView.setImageDrawable(faceAVD);

    findViewById(R.id.animate_btn).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            faceAVD.start();
        }
    });
}
项目:smconf-android    文件:SocialFragment.java   
@TargetApi(21)
private void setupLogoAnim() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final ImageView iv = (ImageView) getActivity().findViewById(R.id.io_logo);
        final AnimatedVectorDrawable logoAnim =
                (AnimatedVectorDrawable) getActivity().getDrawable(
                        R.drawable.io_logo_social_anim);
        iv.setImageDrawable(logoAnim);
        logoAnim.start();
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                logoAnim.start();
            }
        });
    }
}
项目:betterHotels    文件:NoHotelsActivity.java   
@TargetApi(Build.VERSION_CODES.M)
private void initUi() {
    initializeToolbar();

    final AnimatedVectorDrawable avd2 = (AnimatedVectorDrawable) tvButton.getBackground();

    tvButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            tvButton.setText("Loading...");
            avd2.start();
        }
    });

    avd2.registerAnimationCallback(new Animatable2.AnimationCallback() {
        @Override
        public void onAnimationEnd(Drawable drawable) {
            tvButton.setText("Try Again");
        }
    });

}
项目:Floating-Navigation-View    文件:FloatingNavigationView.java   
private void startOpenAnimations() {

        // Icon
        AnimatedVectorDrawable menuIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(),
                R.drawable.ic_menu_animated);
        mFabView.setImageDrawable(menuIcon);
        menuIcon.start();

        // Reveal
        int centerX = mFabRect.centerX();
        int centerY = mFabRect.centerY();
        float startRadius = getMinRadius();
        float endRadius = getMaxRadius();
        Animator reveal = ViewAnimationUtils
                .createCircularReveal(mNavigationView,
                        centerX, centerY, startRadius, endRadius);

        // Fade in
        mNavigationMenuView.setAlpha(0);
        Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 0, 1);

        // Animations
        AnimatorSet set = new AnimatorSet();
        set.playSequentially(reveal, fade);
        set.start();
    }
项目:materialup    文件:RecyclerFragment.java   
public void checkEmptyOrConnection() {
    if (!Utils.hasInternet(getActivity())) {
        if (getAdapter().getItemCount() == 0) {
            mEmpty.setVisibility(View.GONE);
            mEmptyImage.setVisibility(View.VISIBLE);
            if (UI.isLollipop()) {
                final AnimatedVectorDrawable avd =
                        (AnimatedVectorDrawable) ContextCompat.getDrawable(getActivity(), R.drawable.avd_no_connection);
                mEmptyImage.setImageDrawable(avd);
                avd.start();
            } else {
                mEmptyImage.setImageResource(R.drawable.no_connection);
            }
        } else {
            Toast.makeText(getActivity(), R.string.check_network, Toast.LENGTH_SHORT).show();
        }
    }
}
项目:TrekAdvisor    文件:MovableMarker.java   
/**
 * The {@code mRounded} drawable is just the end state of the {@code mStaticToDynamic}
 * {@link AnimatedVectorDrawable}.
 * The {@code mStatic} drawable is the end state of the {@code mDynamicToStatic}
 * {@link AnimatedVectorDrawable}. <br>
 *
 */
public MovableMarker(Context context, boolean staticForm, MarkerGson.Marker marker) {
    super(context);

    mRounded = (AnimatedVectorDrawable) context.getDrawable(R.drawable.avd_marker_rounded);
    mStatic = context.getDrawable(R.drawable.vd_marker_location_rounded);
    mStaticToDynamic = (AnimatedVectorDrawable) context.getDrawable(R.drawable.avd_marker_location_rounded);
    mDynamicToStatic = (AnimatedVectorDrawable) context.getDrawable(R.drawable.avd_marker_rounded_location);

    /* Keep a reference on the model object */
    mMarker = marker;

    /* Init the drawable */
    if (staticForm) {
        initStatic();
    } else {
        initRounded();
    }
}
项目:Amumu    文件:HomeActivity.java   
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);
        noConnection.setImageDrawable(avd);
        avd.start();

        connectivityManager.registerNetworkCallback(
                new NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(),
                connectivityCallback);
        monitoringConnectivity = true;
    }
}
项目:2015-Google-I-O-app    文件:SocialFragment.java   
@TargetApi(21)
private void setupLogoAnim() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final ImageView iv = (ImageView) getActivity().findViewById(R.id.io_logo);
        final AnimatedVectorDrawable logoAnim =
                (AnimatedVectorDrawable) getActivity().getDrawable(
                        R.drawable.io_logo_social_anim);
        iv.setImageDrawable(logoAnim);
        logoAnim.start();
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                logoAnim.start();
            }
        });
    }
}
项目:android-proguards    文件:HomeActivity.java   
void revealPostingProgress() {
    Animator reveal = ViewAnimationUtils.createCircularReveal(fabPosting,
            (int) fabPosting.getPivotX(),
            (int) fabPosting.getPivotY(),
            0f,
            fabPosting.getWidth() / 2)
            .setDuration(600L);
    reveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(this));
    reveal.start();
    AnimatedVectorDrawable uploading =
            (AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading);
    if (uploading != null) {
        fabPosting.setImageDrawable(uploading);
        uploading.start();
    }
}
项目:android-proguards    文件:HomeActivity.java   
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;
    }
}
项目:OldDriver-master    文件:HomeActivity.java   
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);
        noConnection.setImageDrawable(avd);
        avd.start();

        connectivityManager.registerNetworkCallback(
                new NetworkRequest.Builder()
                .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(),
                connectivityCallback);
        monitoringConnectivity = true;
    }
}
项目:Reactive-Popular-Movies    文件:MovieDetailsActivity.java   
@Override
public void showFavoriteMovie() {
    if (!isFavorite) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

            AnimatedVectorDrawable emptyHeart = (AnimatedVectorDrawable)
                    emptyHeartConstantState.newDrawable();
            fab.setImageDrawable(emptyHeart);
            emptyHeart.start();

        } else {
            fab.setImageResource(R.drawable.heart_fill);
        }
        isFavorite = true;
    }
}
项目:Reactive-Popular-Movies    文件:MovieDetailsActivity.java   
@Override
public void showNonFavoriteMovie() {
    if (isFavorite) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

            AnimatedVectorDrawable fullHeart = (AnimatedVectorDrawable)
                    fullHeartConstantState.newDrawable();
            fab.setImageDrawable(fullHeart);
            fullHeart.start();

        } else {
            fab.setImageResource(R.drawable.fab_heart_empty);
        }
        isFavorite = false;
    }
}
项目:FMTech    文件:SocialFragment.java   
@TargetApi(21)
private void setupLogoAnim() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final ImageView iv = (ImageView) getActivity().findViewById(R.id.io_logo);
        final AnimatedVectorDrawable logoAnim =
                (AnimatedVectorDrawable) getActivity().getDrawable(
                        R.drawable.io_logo_social_anim);
        iv.setImageDrawable(logoAnim);
        logoAnim.start();
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                logoAnim.start();
            }
        });
    }
}
项目:multi-seek-bar    文件:AnimatedPinDrawable.java   
public AnimatedPinDrawable(Context context) {
    super();
    Drawable collapsed = context.getDrawable(R.drawable.pin_collapsed);
    Drawable expanded = context.getDrawable(R.drawable.pin_expanded);
    AnimatedVectorDrawable expanding = (AnimatedVectorDrawable) context
        .getDrawable(R.drawable.pin_collapsed_to_expanded_animation);
    AnimatedVectorDrawable collapsing = (AnimatedVectorDrawable) context
        .getDrawable(R.drawable.pin_expanded_to_collapsed_animation);

    addState(STATE_SET_PRESSED, expanded, STATE_EXPANDED_ID);
    addState(STATE_SET_UNPRESSED, collapsed, STATE_COLLAPSED_ID);
    addTransition(STATE_COLLAPSED_ID, STATE_EXPANDED_ID, expanding, false);
    addTransition(STATE_EXPANDED_ID, STATE_COLLAPSED_ID, collapsing, false);

    paint.setColor(Color.BLUE);
    paint.setTextSize(24f);
    paint.setTextAlign(Paint.Align.CENTER);
    paint.setAntiAlias(true);
    duration = context.getResources().getInteger(android.R.integer.config_mediumAnimTime);
}
项目:Decor    文件:SearchAnimateDecorator.java   
@Override
protected void apply(ImageView view, TypedArray typedArray) {
    boolean shouldAnimate = typedArray.getBoolean(R.styleable.SearchAnimateDecorator_decorAnimateSearch, false);
    if(!shouldAnimate) return;

    mIv = view;
    mSearchToBar = (AnimatedVectorDrawable) view.getContext().getResources().getDrawable(R.drawable.anim_search_to_bar);
    mBarToSearch = (AnimatedVectorDrawable) view.getContext().getResources().getDrawable(R.drawable.anim_bar_to_search);
    mInterp = AnimationUtils.loadInterpolator(view.getContext(), android.R.interpolator.linear_out_slow_in);
    mDuration = view.getContext().getResources().getInteger(R.integer.duration_bar);
    // iv is sized to hold the search+bar so when only showing the search icon, translate the
    // whole view left by half the difference to keep it centered
    mOffset = -71f * (int) view.getContext().getResources().getDisplayMetrics().scaledDensity;
    view.setTranslationX(mOffset);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            animate(v);
        }
    });
}
项目:JJCamera    文件:SocialFragment.java   
@TargetApi(21)
private void setupLogoAnim() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final ImageView iv = (ImageView) getActivity().findViewById(R.id.io_logo);
        final AnimatedVectorDrawable logoAnim =
                (AnimatedVectorDrawable) getActivity().getDrawable(
                        R.drawable.io_logo_social_anim);
        iv.setImageDrawable(logoAnim);
        logoAnim.start();
        iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                logoAnim.start();
            }
        });
    }
}
项目:plaid    文件:HomeActivity.java   
void revealPostingProgress() {
    Animator reveal = ViewAnimationUtils.createCircularReveal(fabPosting,
            (int) fabPosting.getPivotX(),
            (int) fabPosting.getPivotY(),
            0f,
            fabPosting.getWidth() / 2)
            .setDuration(600L);
    reveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(this));
    reveal.start();
    AnimatedVectorDrawable uploading =
            (AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading);
    if (uploading != null) {
        fabPosting.setImageDrawable(uploading);
        uploading.start();
    }
}
项目:AnimatedVectorMorphingTool    文件:MainActivity.java   
/**
 * Launch the animation on the currentAnimatedVectorDrawable
 */
private void launchAnimBackup(){
    if(!backupRoundTripFirstLaunched) {
        if (backupRoundTrip.getLevel() == 1) {
            //then reverse
            backupRoundTrip.setLevel(0);
        } else {
            //then reverse
            backupRoundTrip.setLevel(1);
        }
    }else{
        backupRoundTripFirstLaunched=false;
    }
    //find the current AnimatedVectorDrawable displayed
    currentBackupDrawable = (AnimatedVectorDrawable) backupRoundTrip.getCurrent();
    //start the animation
    currentBackupDrawable.start();
}
项目:AnimatedVectorMorphingTool    文件:MainActivity.java   
/**
 * Launch the animation on the currentAnimatedVectorDrawable
 * As the levellist solution (ahead) has a bug, I do it in a simple way
 */
private void launchAnimBackup() {
    //initialize
    if (backupRoundTripFirstLaunched) {
        reverse = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.animated_ic_check_box_black_24dp_reverse, getTheme());
        initial = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.animated_ic_check_box_black_24dp, getTheme());
        //if you want to avoid the color bug (animation not played on color at the second time)
        //comment that line (ok it's memory consumption)
        backupRoundTripFirstLaunched=false;
    }
    //set the drawable depending on the direction (reverse or not)
    if (reverseState) {
        //then reverse
        imageView2.setImageDrawable(reverse);
    } else {
        //then reverse
        imageView2.setImageDrawable(initial);
    }
    reverseState=!reverseState;
    //launch the animation
    ((AnimatedVectorDrawable) imageView2.getDrawable()).start();
}
项目:AnimatedVectorMorphingTool    文件:MainActivity.java   
/**
 * Launch the animation on the currentAnimatedVectorDrawable
 */
private void launchAnimBackup(){
    if(!backupRoundTripFirstLaunched) {
        if (backupRoundTrip.getLevel() == 1) {
            //then reverse
            backupRoundTrip.setLevel(0);
        } else {
            //then reverse
            backupRoundTrip.setLevel(1);
        }
    }else{
        backupRoundTripFirstLaunched=false;
    }
    //find the current AnimatedVectorDrawable displayed
    currentBackupDrawable = (AnimatedVectorDrawable) backupRoundTrip.getCurrent();
    //start the animation
    currentBackupDrawable.start();
}
项目:AnimatedVectorMorphingTool    文件:MainActivity.java   
/**
 * Launch the animation on the currentAnimatedVectorDrawable
 */
private void launchAnimBackup(){
    if(!backupRoundTripFirstLaunched) {
        if (backupRoundTrip.getLevel() == 1) {
            //then reverse
            backupRoundTrip.setLevel(0);
        } else {
            //then reverse
            backupRoundTrip.setLevel(1);
        }
    }else{
        backupRoundTripFirstLaunched=false;
    }
    //find the current AnimatedVectorDrawable displayed
    currentBackupDrawable = (AnimatedVectorDrawable) backupRoundTrip.getCurrent();
    //start the animation
    currentBackupDrawable.start();
}
项目:AnimatedVectorMorphingTool    文件:MainActivity.java   
/**
 * Launch the animation on the currentAnimatedVectorDrawable
 * As the levellist solution (ahead) has a bug, I do it in a simple way
 */
private void launchAnimBackup() {
    //initialize
    if (backupRoundTripFirstLaunched) {
        reverse = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.animated_ic_check_box_black_24dp_reverse, getTheme());
        initial = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.animated_ic_check_box_black_24dp, getTheme());
        //if you want to avoid the color bug (animation not played on color at the second time)
        //comment that line (ok it's memory consumption)
        backupRoundTripFirstLaunched=false;
    }
    //set the drawable depending on the direction (reverse or not)
    if (reverseState) {
        //then reverse
        imageView2.setImageDrawable(reverse);
    } else {
        //then reverse
        imageView2.setImageDrawable(initial);
    }
    reverseState=!reverseState;
    //launch the animation
    ((AnimatedVectorDrawable) imageView2.getDrawable()).start();
}
项目:AnimatedVectorMorphingTool    文件:MainActivity.java   
/**
 * Launch the animation on the currentAnimatedVectorDrawable
 */
private void launchAnimBackup(){
    if(!backupRoundTripFirstLaunched) {
        if (backupRoundTrip.getLevel() == 1) {
            //then reverse
            backupRoundTrip.setLevel(0);
        } else {
            //then reverse
            backupRoundTrip.setLevel(1);
        }
    }else{
        backupRoundTripFirstLaunched=false;
    }
    //find the current AnimatedVectorDrawable displayed
    currentBackupDrawable = (AnimatedVectorDrawable) backupRoundTrip.getCurrent();
    //start the animation
    currentBackupDrawable.start();
}
项目:appcutt    文件:PhotoDetailActivity.java   
@OnClick(R.id.fab)
void onClickFab() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Drawable drawable = fab.getDrawable();
        if (drawable instanceof AnimatedVectorDrawable) {
            if (((AnimatedVectorDrawable) drawable).isRunning()) return;

            int drawableResId = fab.isSelected() ? R.drawable.ic_pause_to_play : R.drawable.ic_play_to_pause;
            fab.setImageResource(drawableResId);

            drawable = fab.getDrawable();
            ((AnimatedVectorDrawable) drawable).start();
        }
    }

    if (fab.isSelected()) {
        imgPreview.pause();
    } else {
        imgPreview.resume();
    }

    fab.setSelected(!fab.isSelected());
}
项目:iosched    文件:MyIOFragment.java   
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mLoadingSwitcher = (ViewSwitcher) view.findViewById(R.id.loading_switcher);
    mLoadingView = (LottieAnimationView) view.findViewById(R.id.loading_anim);
    mRecyclerView = (RecyclerView) view.findViewById(android.R.id.list);
    mRecyclerView.addItemDecoration(new DividerDecoration(getContext()));
    mAdapter = new MyIOAdapter(getContext(), this);
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(
            new StickyHeadersLinearLayoutManager<MyIOAdapter>(getContext()));
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            mScrolled = true;
            recyclerView.removeOnScrollListener(this);
        }
    });
    View header = view.findViewById(R.id.header_anim);
    if (header instanceof ImageView) {
        AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(
                getContext(), R.drawable.avd_header_my_io);
        ((ImageView) header).setImageDrawable(avd);
        avd.start();
    }
}
项目:iosched    文件:SessionDetailFragment.java   
private void showInSchedule(boolean isInSchedule, boolean animate) {
    mAddScheduleFab.setChecked(isInSchedule);
    mAddScheduleFab.setContentDescription(getString(isInSchedule
            ? R.string.remove_from_schedule
            : R.string.add_to_schedule));
    if (!animate) return;

    AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(
            getContext(), isInSchedule ? R.drawable.avd_bookmark : R.drawable.avd_unbookmark);
    mAddScheduleFab.setImageDrawable(avd);
    ObjectAnimator backgroundColor = ObjectAnimator.ofArgb(
            mAddScheduleFab,
            UIUtils.BACKGROUND_TINT,
            isInSchedule ? Color.WHITE
                    : ContextCompat.getColor(getContext(), R.color.lightish_blue));
    backgroundColor.setDuration(400L);
    backgroundColor.setInterpolator(AnimationUtils.loadInterpolator(getContext(),
            android.R.interpolator.fast_out_slow_in));
    backgroundColor.start();
    avd.start();
}
项目:iosched    文件:FeedFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.feed_fragment, container, false);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.feed_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mFeedAdapter = new FeedAdapter(getContext());
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), VERTICAL));
    mRecyclerView.setAdapter(mFeedAdapter);
    View header = view.findViewById(R.id.header_anim);
    if (header instanceof ImageView) {
        AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(
                getContext(), R.drawable.avd_header_feed);
        ((ImageView) header).setImageDrawable(avd);
        avd.start();
    }
    return view;
}
项目:Orpheus    文件:ControlsScreenView.java   
@TargetApi(21)
void setupDrawables21() {
    //add state transitions
    AnimatedStateListDrawable drawable = (AnimatedStateListDrawable) play.getDrawable();
    drawable.addTransition(R.id.pause_state, R.id.play_state, (AnimatedVectorDrawable)
            ContextCompat.getDrawable(getContext(), R.drawable.vector_pause_play_black_36dp), false);
    drawable.addTransition(R.id.play_state, R.id.pause_state, (AnimatedVectorDrawable)
            ContextCompat.getDrawable(getContext(), R.drawable.vector_play_pause_black_36dp), false);

    /*
    AnimatedStateListDrawable repeatDrawable = (AnimatedStateListDrawable) repeat.getDrawable();
    repeatDrawable.addTransition(R.id.repeat_off_state, R.id.repeat_on_state, (AnimatedVectorDrawable)
            ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_off_on_black_36dp), true);
    repeatDrawable.addTransition(R.id.repeat_on_state, R.id.repeat_one_state, (AnimatedVectorDrawable)
            ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_on_one_black_36dp), true);
    repeatDrawable.addTransition(R.id.repeat_one_state, R.id.repeat_off_state, (AnimatedVectorDrawable)
            ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_one_off_black_36dp), true);
    repeatDrawable.addTransition(R.id.repeat_off_state, R.id.repeat_one_state, (AnimatedVectorDrawable)
            ContextCompat.getDrawable(getContext(), R.drawable.vector_repeat_off_one_black_36dp), true);
            */
}
项目:PeSanKita-android    文件:AudioView.java   
private void togglePlayToPause() {
  controlToggle.displayQuick(pauseButton);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    AnimatedVectorDrawable playToPauseDrawable = (AnimatedVectorDrawable)getContext().getDrawable(R.drawable.play_to_pause_animation);
    pauseButton.setImageDrawable(playToPauseDrawable);
    playToPauseDrawable.start();
  }
}
项目:PeSanKita-android    文件:AudioView.java   
private void togglePauseToPlay() {
  controlToggle.displayQuick(playButton);

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    AnimatedVectorDrawable pauseToPlayDrawable = (AnimatedVectorDrawable)getContext().getDrawable(R.drawable.pause_to_play_animation);
    playButton.setImageDrawable(pauseToPlayDrawable);
    pauseToPlayDrawable.start();
  }
}
项目:quidditchtimekeeper    文件:GameActivity.java   
public void animatePlayPause(View w)
{
    if(game.clocks[game.activeTime].getMode().equals("timer") && !game.clocks[game.activeTime].isRunning() && game.clocks[game.activeTime].getTimeRemaining()==0)
    {
        //nicht starten
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("You can't start the timer because it is already 00:00.");

        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();

            } });

        AlertDialog alertDialog = builder.create();
        alertDialog.show();
    }
    else
    {
        toggleWatches();
        AnimatedVectorDrawable drawable = play ? playToPause : pauseToPlay;
        playPause[game.activeTime].setImageDrawable(drawable);
        drawable.start();
        play = !play;
    }
}
项目:android-WearAccessibilityApp    文件:ImagesActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_images);

    AmbientMode.attachAmbientSupport(this);

    // Used to repeat animation from the beginning.
    mAnimationCallback =
            new AnimationCallback() {
                @Override
                public void onAnimationEnd(Drawable drawable) {
                    super.onAnimationEnd(drawable);
                    ((AnimatedVectorDrawable) drawable).start();
                }
            };

    // Play 'swipe left' animation on loop.
    ImageView mSwipeLeftImage = findViewById(R.id.swipe_left_image);
    mAnimatedVectorDrawableSwipe = (AnimatedVectorDrawable) mSwipeLeftImage.getDrawable();
    mAnimatedVectorDrawableSwipe.start();
    mAnimatedVectorDrawableSwipe.registerAnimationCallback(mAnimationCallback);

    // Play 'tap' animation on loop.
    ImageView mTapImage = findViewById(R.id.tap_image);
    mAnimatedVectorDrawableTap = (AnimatedVectorDrawable) mTapImage.getDrawable();
    mAnimatedVectorDrawableTap.start();
    mAnimatedVectorDrawableTap.registerAnimationCallback(mAnimationCallback);
}
项目:Mire    文件:BottomSheetLib.java   
private void showClose()
{
       if (stateDismiss == DISMISS_CLOSE) 
    {
        return;
    }
       stateDismiss = DISMISS_CLOSE;

       final AnimatedVectorDrawable downToClose = (AnimatedVectorDrawable)ContextCompat.getDrawable(this, R.animator.avd_down_to_close);

    close.setImageDrawable(downToClose);
       downToClose.start();
   }
项目:Mire    文件:BottomSheetLib.java   
private void showDown()
{
       if (stateDismiss == DISMISS_DOWN)
    {
        return;
    }
       stateDismiss = DISMISS_DOWN;

       final AnimatedVectorDrawable closeToDown = (AnimatedVectorDrawable)ContextCompat.getDrawable(this, R.animator.avd_close_to_down);

    close.setImageDrawable(closeToDown);
       closeToDown.start();
   }