android.graphics.drawable.AnimatedVectorDrawable#start()源码实例Demo

下面列出了android.graphics.drawable.AnimatedVectorDrawable#start() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_on_phone_animation);

    AmbientModeSupport.attach(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();
}
 
源代码2 项目: 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();
}
 
源代码3 项目: 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();
}
 
源代码4 项目: 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();
}
 
源代码5 项目: 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();
}
 
源代码6 项目: wear-os-samples   文件: ImagesActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_images);

    AmbientModeSupport.attach(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);
}
 
源代码7 项目: BaldPhone   文件: HomeScreenActivity.java
@Override
public void run() {
    final Drawable d = notificationsButton.getDrawable();
    if (d instanceof AnimatedVectorDrawable) {
        final AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) d;
        animatedVectorDrawable.start();
        final int minusSeconds = Math.min((int) (Math.max((notificationCount - NOTIFICATIONS_ALOT) * 0.5f, 0)), 7);
        handler.postDelayed(this, (10 - minusSeconds) * D.SECOND);
    }
}
 
private void triggerAvatarStrokeTransformation(boolean appear) {

        // Scale thin line behind avatar
        int lineScaleX = appear ? 1 : 10;
        topHeaderDividerLine.animate().scaleX(lineScaleX).setDuration(200);

        // Animate avatar stroke vector path
        AnimatedVectorDrawable drawable = appear ? appearingImageStroke : disappearingImageStroke;
        imageStrokeVectorDrawable.setImageDrawable(drawable);
        drawable.start();

        userAvatarStrokeVisible = appear;
    }
 
源代码9 项目: deltachat-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();
  }
}
 
源代码10 项目: deltachat-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();
  }
}
 
源代码11 项目: auid2   文件: MainActivity.java
@Override
public void onClick(View v) {
    final ImageView imageView = (ImageView) v;
    final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) imageView.getDrawable();
    avd.start();

}
 
源代码12 项目: Silence   文件: 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();
  }
}
 
源代码13 项目: Silence   文件: 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();
  }
}
 
源代码14 项目: Focus   文件: SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if(SkinPreference.getInstance().getSkinName().equals("night")){
        super.setTheme(R.style.AppTheme_Dark);
    }else {
        super.setTheme(R.style.AppTheme);
    }


    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //隐藏状态栏

    setContentView(R.layout.activity_welcome);


    if (UserPreference.queryValueByKey(UserPreference.FIST_USE_NEW_COMER, "0").equals("0")){
        sampleWelcomeScreen = new WelcomeHelper(this, NewComerActivity.class);
        sampleWelcomeScreen.forceShow();

    }else {
        Intent intent = getIntent();

        if (!isTaskRoot()) {
            finish();
            return;
        }

        ImageView imageview= findViewById(R.id.imageView);
        AnimatedVectorDrawable animatedVectorDrawable =  ((AnimatedVectorDrawable) imageview.getDrawable());
        animatedVectorDrawable.start();

        //跳转到 {@link MainActivity}
        new AppStartTask(new TaskListener() {
            @Override
            public void onFinish(String jsonString) {

                finish();
                MainActivity.activityStart(SplashActivity.this);

            }
        }).execute();
    }



}
 
源代码15 项目: Focus   文件: SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if(SkinPreference.getInstance().getSkinName().equals("night")){
        super.setTheme(R.style.AppTheme_Dark);
    }else {
        super.setTheme(R.style.AppTheme);
    }


    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //隐藏状态栏

    setContentView(R.layout.activity_welcome);


    if (UserPreference.queryValueByKey(UserPreference.FIST_USE_NEW_COMER, "0").equals("0")){
        sampleWelcomeScreen = new WelcomeHelper(this, NewComerActivity.class);
        sampleWelcomeScreen.forceShow();

    }else {
        Intent intent = getIntent();

        if (!isTaskRoot()) {
            finish();
            return;
        }

        ImageView imageview= findViewById(R.id.imageView);
        AnimatedVectorDrawable animatedVectorDrawable =  ((AnimatedVectorDrawable) imageview.getDrawable());
        animatedVectorDrawable.start();

        //跳转到 {@link MainActivity}
        new AppStartTask(new TaskListener() {
            @Override
            public void onFinish(String jsonString) {

                finish();
                MainActivity.activityStart(SplashActivity.this);

            }
        }).execute();
    }



}
 
@TargetApi(Build.VERSION_CODES.M)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_view);
        final WaterRefreshView waterRefreshView = (WaterRefreshView) findViewById(R.id.waterrefreshview);
        waterRefreshView.setOnRefreshListener(new WaterRefreshView.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ToastUtils.showMessage("刷新成功");
                        waterRefreshView.refreshSuccess();
                    }
                }, 2000);
            }
        });
        final SwipeLayout swipeLayout = (SwipeLayout) findViewById(R.id.swipe_edit_layout);
        swipeLayout.setOnMenuClickListener(new SwipeLayout.OnMenuClickListener() {
            @Override
            public void onMenuClick(View v) {
                transWaterRefreshView(waterRefreshView);
                ObjectAnimator alpha = ObjectAnimator.ofFloat(swipeLayout, "alpha", 1f, 0f);
                alpha.setDuration(500);
                alpha.setInterpolator(new DecelerateInterpolator());
                alpha.start();
                alpha.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        super.onAnimationEnd(animation);
                        swipeLayout.setVisibility(View.GONE);
                    }
                });
            }
        });
//        final SwipeLayout swipeLayout2 = (SwipeLayout) findViewById(R.id.swipe_edit_layout2);
//        swipeLayout2.setOnMenuClickListener(new SwipeLayout.OnMenuClickListener() {
//            @Override
//            public void onMenuClick(View v) {
////                transWaterRefreshView(waterRefreshView);
//                ObjectAnimator alpha = ObjectAnimator.ofFloat(swipeLayout2, "translationX", 0,swipeLayout2.getWidth());
//                alpha.setDuration(500);
//                alpha.setInterpolator(new DecelerateInterpolator());
//                alpha.start();
//                alpha.addListener(new AnimatorListenerAdapter() {
//                    @Override
//                    public void onAnimationEnd(Animator animation) {
//                        super.onAnimationEnd(animation);
//                        swipeLayout2.setVisibility(View.GONE);
//                    }
//                });
//            }
//        });
        swipeLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                transY = swipeLayout.getHeight();
                swipeLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });

        ImageView iv_vector = (ImageView) findViewById(R.id.iv_test_view_vector_jrtt);
        AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) iv_vector.getDrawable();
        drawable.start();
        ImageView iv_tick = (ImageView) findViewById(R.id.iv_test_view_vector_tick);
        drawableTick = (AnimatedVectorDrawable) iv_tick.getDrawable();
        drawableTick.start();


        for (int i = 0; i < 5; i++) {
            TestFragment testFragment = new TestFragment();
            Bundle bundle = new Bundle();
            bundle.putString("pos", String.valueOf(i + 1));
            testFragment.setArguments(bundle);
            mFragmentList.add(testFragment);
        }


        final BezierIndicatorView bezierIndicatorView = (BezierIndicatorView) findViewById(R.id.bezierIndicatorView);
        ViewPager viewPager = (ViewPager) findViewById(R.id.test_viewpager);
        viewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
        viewPager.setOnPageChangeListener(bezierIndicatorView);
        viewPager.setCurrentItem(0);
        bezierIndicatorView.setAdapter(viewPager.getAdapter());
    }
 
源代码17 项目: lock-screen   文件: Animate.java
@TargetApi(Build.VERSION_CODES.M)
public static void animate(AppCompatImageView view, AnimatedVectorDrawable scanFingerprint) {
    view.setImageDrawable(scanFingerprint);
    scanFingerprint.start();
}
 
源代码18 项目: Spotlight   文件: SpotlightView.java
/**
 * Add arc above/below the circular target overlay.
 */
private void addArcAnimation(final Activity activity) {
    AppCompatImageView mImageView = new AppCompatImageView(activity);
    mImageView.setImageResource(R.drawable.ic_spotlight_arc);
    LayoutParams params = new LayoutParams(2 * (circleShape.getRadius() + extraPaddingForArc),
            2 * (circleShape.getRadius() + extraPaddingForArc));


    if (targetView.getPoint().y > getHeight() / 2) {//bottom
        if (targetView.getPoint().x > getWidth() / 2) {//Right
            params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.RIGHT | Gravity.BOTTOM;
        } else {
            params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.LEFT | Gravity.BOTTOM;
        }
    } else {//up
        mImageView.setRotation(180); //Reverse the view
        if (targetView.getPoint().x > getWidth() / 2) {//Right
            params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.RIGHT | Gravity.BOTTOM;
        } else {
            params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc;
            params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc;
            params.gravity = Gravity.LEFT | Gravity.BOTTOM;
        }

    }
    mImageView.postInvalidate();
    mImageView.setLayoutParams(params);
    addView(mImageView);

    PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(lineAndArcColor,
            PorterDuff.Mode.SRC_ATOP);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        AnimatedVectorDrawable avd = (AnimatedVectorDrawable)
                ContextCompat.getDrawable(activity, R.drawable.avd_spotlight_arc);
        avd.setColorFilter(porterDuffColorFilter);
        mImageView.setImageDrawable(avd);
        avd.start();
    } else {
        AnimatedVectorDrawableCompat avdc =
                AnimatedVectorDrawableCompat.create(activity, R.drawable.avd_spotlight_arc);
        avdc.setColorFilter(porterDuffColorFilter);
        mImageView.setImageDrawable(avdc);
        avdc.start();
    }

    new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
        @Override
        public void run() {
            addPathAnimation(activity);
        }
    }, 400);
}
 
源代码19 项目: android-proguards   文件: HomeActivity.java
@Override
public void onReceive(Context context, Intent intent) {
    ensurePostingProgressInflated();
    switch (intent.getAction()) {
        case PostStoryService.BROADCAST_ACTION_SUCCESS:
            // success animation
            AnimatedVectorDrawable complete =
                    (AnimatedVectorDrawable) getDrawable(R.drawable.avd_upload_complete);
            if (complete != null) {
                fabPosting.setImageDrawable(complete);
                complete.start();
                fabPosting.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fabPosting.setVisibility(View.GONE);
                    }
                }, 2100); // length of R.drawable.avd_upload_complete
            }

            // actually add the story to the grid
            Story newStory = intent.getParcelableExtra(PostStoryService.EXTRA_NEW_STORY);
            adapter.addAndResort(Collections.singletonList(newStory));
            break;
        case PostStoryService.BROADCAST_ACTION_FAILURE:
            // failure animation
            AnimatedVectorDrawable failed =
                    (AnimatedVectorDrawable) getDrawable(R.drawable.avd_upload_error);
            if (failed != null) {
                fabPosting.setImageDrawable(failed);
                failed.start();
            }
            // remove the upload progress 'fab' and reshow the regular one
            fabPosting.animate()
                    .alpha(0f)
                    .rotation(90f)
                    .setStartDelay(2000L) // leave error on screen briefly
                    .setDuration(300L)
                    .setInterpolator(AnimUtils.getFastOutSlowInInterpolator(HomeActivity
                            .this))
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            fabPosting.setVisibility(View.GONE);
                            fabPosting.setAlpha(1f);
                            fabPosting.setRotation(0f);
                        }
                    });
            break;
    }
    unregisterPostStoryResultListener();
}
 
源代码20 项目: attendee-checkin   文件: CheckinHolder.java
public void animateCheckin() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) mCheckin.getDrawable();
        drawable.start();
    }
}