This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Overrid | |
| protected void onDraw(Canvas canvas) { | |
| super.onDraw(canvas); | |
| canvas.save(); | |
| canvas.translate(10, 15); | |
| canvas.drawText("Hello world", 1, 5, p); | |
| canvas.restore(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void loadImageWithReduction(ImageView view, int imageIndex) { | |
| Drawable drawable = changeColorOfDrawable(R.drawable.face_black, Color.parseColor(drawableColor[imageIndex])); | |
| view.setImageDrawable(drawable); | |
| } | |
| private Drawable changeColorOfDrawable(@DrawableRes int drawableResId, int color) { | |
| Drawable drawable = ContextCompat.getDrawable(this, drawableResId); | |
| drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN); | |
| return drawable; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void animateSingleView(ViewGroup windowRoot, int viewPosition, View view) { | |
| view.setTranslationY(windowRoot.getHeight()); | |
| view.setAlpha(0); | |
| view.animate() | |
| .translationY(0) | |
| .alpha(1) | |
| .setStartDelay(START_DELAY) | |
| .setDuration(DURATION_INITIAL + DURATION_NEXT_VIEW_FACTOR * viewPosition) | |
| .setInterpolator(new DecelerateInterpolator(INTERPOLATOR_FACTOR)).start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void startSlideInAnimation() { | |
| ViewGroup windowRoot = (ViewGroup) findViewById(android.R.id.content); | |
| ViewGroup contentRoot = (ViewGroup) windowRoot.getChildAt(0); | |
| for (int i = 0; i < contentRoot.getChildCount(); i++) { | |
| View v = contentRoot.getChildAt(i); | |
| animateSingleView(windowRoot, i, v); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private boolean animated = false; | |
| @Override | |
| public void onWindowFocusChanged(boolean hasFocus) { | |
| super.onWindowFocusChanged(hasFocus); | |
| if (hasFocus && !animated) { | |
| startSlideInAnimation(); | |
| animated = true; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| animatorSet.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AnimatorSet animatorSet = new AnimatorSet(); | |
| animatorSet.play(revealAnimator).before(alphaAnimator); | |
| animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); | |
| animatorSet.addListener(new AnimatorListenerAdapter() { | |
| @Override | |
| public void onAnimationEnd(Animator animation) { | |
| value.setText("0"); | |
| overlay.remove(revealView); | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); | |
| alphaAnimator.setDuration(getResources().getInteger(android.R.integer.config_mediumAnimTime)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| float radius = (float) Math.sqrt(Math.pow(container.getHeight(), 2) + Math.pow(container.getWidth(), 2)); | |
| Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealView.getWidth(), revealView.getHeight(), 0.0f, radius); | |
| revealAnimator.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); | |
| revealAnimator.addListener(new AnimatorListenerAdapter() { | |
| @Override | |
| public void onAnimationEnd(Animator animation) { | |
| value.setText("0"); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ViewGroupOverlay overlay = container.getOverlay(); | |
| final View revealView = new View(this); | |
| revealView.setBottom(container.getHeight()); | |
| revealView.setRight(container.getWidth()); | |
| revealView.setBackgroundColor(ContextCompat.getColor(this, R.color.colorAccent)); | |
| overlay.add(revealView); |
NewerOlder