Java 类android.view.ViewGroupOverlay 实例源码

项目:librus-client    文件:ItemDetailsTransition.java   
@Override
    public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues,
                                   final TransitionValues endValues) {
        if (startValues != null && endValues != null) {
            final ViewGroupOverlay overlay = sceneRoot.getOverlay();
            final View view = endValues.view;
            View bottomPanel = endValues.view.findViewById(R.id.fragment_announcement_details_bottom_panel);
            final TextView topPanel = (TextView) endValues.view.findViewById(R.id.fragment_announcement_details_top_panel);

//           TOP PANEL
            ValueAnimator text = ValueAnimator.ofFloat(14, 20);
            text.addUpdateListener(valueAnimator -> topPanel.setTextSize(TypedValue.COMPLEX_UNIT_SP, (Float) valueAnimator.getAnimatedValue()));
            Animator top = ObjectAnimator.ofFloat(topPanel, "alpha", 0.5f, 1f);
            Animator bottom = ObjectAnimator.ofFloat(bottomPanel, "alpha", 0.5f, 1f);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(bottom, top);
            set.addListener(getOverlayListener(overlay, view));
            return set;
        } else {
            return null;
        }
    }
项目:GitHub    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    private void applyDim(Activity activity) {
        ViewGroup parent = (ViewGroup) activity.getWindow().getDecorView().getRootView();
        //activity跟布局
//        ViewGroup parent = (ViewGroup) parent1.getChildAt(0);
        Drawable dim = new ColorDrawable(mDimColor);
        dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
        dim.setAlpha((int) (255 * mDimValue));
        ViewGroupOverlay overlay = parent.getOverlay();
        overlay.add(dim);
    }
项目:GitHub    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void applyDim(ViewGroup dimView) {
    ViewGroup parent = dimView;
    Drawable dim = new ColorDrawable(mDimColor);
    dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
    dim.setAlpha((int) (255 * mDimValue));
    ViewGroupOverlay overlay = parent.getOverlay();
    overlay.add(dim);
}
项目:GitHub    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    private void clearDim(Activity activity) {
        ViewGroup parent = (ViewGroup) activity.getWindow().getDecorView().getRootView();
        //activity跟布局
//        ViewGroup parent = (ViewGroup) parent1.getChildAt(0);
        ViewGroupOverlay overlay = parent.getOverlay();
        overlay.clear();
    }
项目:TappyBLE    文件:HexCommandAdapter.java   
private void emphasizeUserError(ViewGroup v) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Context ctx = v.getContext();
        final ViewGroupOverlay overlay = v.getOverlay();

        final View revealView = new View(v.getContext());
        revealView.setBottom(v.getHeight());
        revealView.setRight(v.getWidth());
        revealView.setBackgroundColor(ContextCompat.getColor(ctx, R.color.colorErrorTrans));

        overlay.add(revealView);

        float radius = (float) Math.sqrt(Math.pow(v.getHeight(), 2) + Math.pow(v.getWidth(), 2));
        Animator revealAnimator =
                ViewAnimationUtils.createCircularReveal(revealView,
                        (revealView.getWidth() / 2), revealView.getHeight(), 0.0f, radius);
        //TODO: move this into resources
        revealAnimator.setDuration(500);

        Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
        alphaAnimator.setDuration(200);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(revealAnimator).before(alphaAnimator);
        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                overlay.remove(revealView);
            }
        });

        animatorSet.start();
    }
    else {
        Toast.makeText(v.getContext(),R.string.unsupported_url_prefix,Toast.LENGTH_SHORT).show();
    }
}
项目:TappyBLE    文件:UrlCommandAdapter.java   
private void emphasizeUserError(ViewGroup v) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Context ctx = v.getContext();
        final ViewGroupOverlay overlay = v.getOverlay();

        final View revealView = new View(v.getContext());
        revealView.setBottom(v.getHeight());
        revealView.setRight(v.getWidth());
        revealView.setBackgroundColor(ContextCompat.getColor(ctx, R.color.colorErrorTrans));

        overlay.add(revealView);

        float radius = (float) Math.sqrt(Math.pow(v.getHeight(), 2) + Math.pow(v.getWidth(), 2));
        Animator revealAnimator =
                ViewAnimationUtils.createCircularReveal(revealView,
                        (revealView.getWidth() / 2), revealView.getHeight(), 0.0f, radius);
        //TODO: move this into resources
        revealAnimator.setDuration(500);

        Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
        alphaAnimator.setDuration(200);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.play(revealAnimator).before(alphaAnimator);
        animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                overlay.remove(revealView);
            }
        });

        animatorSet.start();
    }
    else {
        Toast.makeText(v.getContext(),R.string.unsupported_url_prefix,Toast.LENGTH_SHORT).show();
    }
}
项目:EasyPopup    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    private void applyDim(Activity activity) {
        ViewGroup parent = (ViewGroup) activity.getWindow().getDecorView().getRootView();
        //activity跟布局
//        ViewGroup parent = (ViewGroup) parent1.getChildAt(0);
        Drawable dim = new ColorDrawable(mDimColor);
        dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
        dim.setAlpha((int) (255 * mDimValue));
        ViewGroupOverlay overlay = parent.getOverlay();
        overlay.add(dim);
    }
项目:EasyPopup    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void applyDim(ViewGroup dimView) {
    ViewGroup parent = dimView;
    Drawable dim = new ColorDrawable(mDimColor);
    dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
    dim.setAlpha((int) (255 * mDimValue));
    ViewGroupOverlay overlay = parent.getOverlay();
    overlay.add(dim);
}
项目:EasyPopup    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    private void clearDim(Activity activity) {
        ViewGroup parent = (ViewGroup) activity.getWindow().getDecorView().getRootView();
        //activity跟布局
//        ViewGroup parent = (ViewGroup) parent1.getChildAt(0);
        ViewGroupOverlay overlay = parent.getOverlay();
        overlay.clear();
    }
项目:GitHub    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void clearDim(ViewGroup dimView) {
    ViewGroup parent = dimView;
    ViewGroupOverlay overlay = parent.getOverlay();
    overlay.clear();
}
项目:EasyPopup    文件:EasyPopup.java   
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void clearDim(ViewGroup dimView) {
    ViewGroup parent = dimView;
    ViewGroupOverlay overlay = parent.getOverlay();
    overlay.clear();
}
项目:Fontster    文件:ViewUtils.java   
public static void reveal(Activity activity, View view, View sourceView, int colorRes) {
  if (activity == null || view == null || sourceView == null) return;
  if (isLollipop()) {
    final ViewGroupOverlay groupOverlay =
        (ViewGroupOverlay) activity.getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    view.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(activity);
    revealView.setTop(displayRect.top);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes));
    groupOverlay.add(revealView);

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    try {
      final Animator revealAnimator =
          ViewAnimationUtils.createCircularReveal(revealView,
              revealCenterX, revealCenterY, 0.0f, revealRadius);
      revealAnimator.setDuration(
          activity.getResources().getInteger(android.R.integer.config_mediumAnimTime));

      final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
      alphaAnimator.setDuration(
          activity.getResources().getInteger(android.R.integer.config_shortAnimTime));
      alphaAnimator.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
          super.onAnimationEnd(animation);
          view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in));
          view.setVisibility(View.VISIBLE);
        }
      });

      final AnimatorSet animatorSet = new AnimatorSet();
      animatorSet.play(revealAnimator).before(alphaAnimator);
      animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
      animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animator) {
          groupOverlay.remove(revealView);
        }
      });

      animatorSet.start();
    } catch (IllegalStateException e) {
      Timber.i("View is detached - not animating");
    }
  } else {
    view.setVisibility(View.VISIBLE);
  }
}
项目:Thrift-box    文件:ActivityHelper.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void reveal5(View sourceView, int colorRes, final AnimatorListenerWrapper listener) {
    final ViewGroupOverlay groupOverlay =
            (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator revealAnimator =
            ViewAnimationUtils.createCircularReveal(revealView,
                    revealCenterX, revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_longAnimTime));

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_mediumAnimTime));
    alphaAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            listener.onAnimationStart();
        }
    });

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(revealAnimator).before(alphaAnimator);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}
项目:repmaxcalculator-android    文件:MainActivity.java   
private void reveal(View sourceView, int colorRes, Animator.AnimatorListener listener) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        listener.onAnimationEnd(null);
        return;
    }

    final ViewGroupOverlay groupOverlay =
            (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator revealAnimator =
            ViewAnimationUtils.createCircularReveal(revealView,
                    revealCenterX, revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_longAnimTime));
    revealAnimator.addListener(listener);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_mediumAnimTime));

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(revealAnimator).before(alphaAnimator);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}
项目:repmaxcalculator-android    文件:ConverterActivity.java   
private void reveal(View sourceView, int colorRes, Animator.AnimatorListener listener) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        listener.onAnimationEnd(null);
        return;
    }

    final ViewGroupOverlay groupOverlay =
            (ViewGroupOverlay) getWindow().getDecorView().getOverlay();

    final Rect displayRect = new Rect();
    mDisplayView.getGlobalVisibleRect(displayRect);

    // Make reveal cover the display and status bar.
    final View revealView = new View(this);
    revealView.setBottom(displayRect.bottom);
    revealView.setLeft(displayRect.left);
    revealView.setRight(displayRect.right);
    revealView.setBackgroundColor(getResources().getColor(colorRes));
    groupOverlay.add(revealView);

    final int[] clearLocation = new int[2];
    sourceView.getLocationInWindow(clearLocation);
    clearLocation[0] += sourceView.getWidth() / 2;
    clearLocation[1] += sourceView.getHeight() / 2;

    final int revealCenterX = clearLocation[0] - revealView.getLeft();
    final int revealCenterY = clearLocation[1] - revealView.getTop();

    final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2);
    final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2);
    final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2);
    final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2));

    final Animator revealAnimator =
            ViewAnimationUtils.createCircularReveal(revealView,
                    revealCenterX, revealCenterY, 0.0f, revealRadius);
    revealAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_longAnimTime));
    revealAnimator.addListener(listener);

    final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    alphaAnimator.setDuration(
            getResources().getInteger(android.R.integer.config_mediumAnimTime));

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(revealAnimator).before(alphaAnimator);
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            groupOverlay.remove(revealView);
            mCurrentAnimator = null;
        }
    });

    mCurrentAnimator = animatorSet;
    animatorSet.start();
}