android.view.ViewGroupOverlay Java Examples

The following examples show how to use android.view.ViewGroupOverlay. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivityTransitionCoordinator.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
protected void moveSharedElementsFromOverlay() {
    int numListeners = mGhostViewListeners.size();
    for (int i = 0; i < numListeners; i++) {
        GhostViewListeners listener = mGhostViewListeners.get(i);
        listener.removeListener();
    }
    mGhostViewListeners.clear();

    if (mWindow == null || !mWindow.getSharedElementsUseOverlay()) {
        return;
    }
    ViewGroup decor = getDecor();
    if (decor != null) {
        ViewGroupOverlay overlay = decor.getOverlay();
        int count = mSharedElements.size();
        for (int i = 0; i < count; i++) {
            View sharedElement = mSharedElements.get(i);
            GhostView.removeGhost(sharedElement);
        }
    }
}
 
Example #2
Source File: FastScroller.java    From AndroidFastScroll with Apache License 2.0 5 votes vote down vote up
public FastScroller(@NonNull ViewGroup view, @NonNull ViewHelper viewHelper,
                    @Nullable Rect padding, @NonNull Drawable trackDrawable,
                    @NonNull Drawable thumbDrawable, @NonNull Consumer<TextView> popupStyle,
                    @NonNull AnimationHelper animationHelper) {

    mMinTouchTargetSize = view.getResources().getDimensionPixelSize(
            R.dimen.afs_min_touch_target_size);
    Context context = view.getContext();
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mView = view;
    mViewHelper = viewHelper;
    mUserPadding = padding;
    mAnimationHelper = animationHelper;

    mTrackWidth = trackDrawable.getIntrinsicWidth();
    mThumbWidth = thumbDrawable.getIntrinsicWidth();
    mThumbHeight = thumbDrawable.getIntrinsicHeight();

    mTrackView = new View(context);
    mTrackView.setBackground(trackDrawable);
    mThumbView = new View(context);
    mThumbView.setBackground(thumbDrawable);
    mPopupView = new AppCompatTextView(context);
    mPopupView.setLayoutParams(new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    popupStyle.accept(mPopupView);

    ViewGroupOverlay overlay = mView.getOverlay();
    overlay.add(mTrackView);
    overlay.add(mThumbView);
    overlay.add(mPopupView);

    postAutoHideScrollbar();
    mPopupView.setAlpha(0);

    mViewHelper.addOnPreDrawListener(this::onPreDraw);
    mViewHelper.addOnScrollChangedListener(this::onScrollChanged);
    mViewHelper.addOnTouchEventListener(this::onTouchEvent);
}
 
Example #3
Source File: BasePopup.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
@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 dimDrawable = new ColorDrawable(mDimColor);
        dimDrawable.setBounds(0, 0, parent.getWidth(), parent.getHeight());
        dimDrawable.setAlpha((int) (255 * mDimValue));
        ViewGroupOverlay overlay = parent.getOverlay();
        overlay.add(dimDrawable);
    }
 
Example #4
Source File: BasePopup.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void applyDim(ViewGroup dimView) {
    Drawable dimDrawable = new ColorDrawable(mDimColor);
    dimDrawable.setBounds(0, 0, dimView.getWidth(), dimView.getHeight());
    dimDrawable.setAlpha((int) (255 * mDimValue));
    ViewGroupOverlay overlay = dimView.getOverlay();
    overlay.add(dimDrawable);
}
 
Example #5
Source File: BasePopup.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
@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();
    }
 
Example #6
Source File: GuiInfoPopupWindow.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
static void applyDim(@NonNull ViewGroup parent){
    Drawable dim = new ColorDrawable(Color.BLACK);
    dim.setBounds(0, 0, parent.getWidth(), parent.getHeight());
    dim.setAlpha((int) (255 * 0.5));

    ViewGroupOverlay overlay = parent.getOverlay();
    overlay.add(dim);
}
 
Example #7
Source File: FastScroller.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public FastScroller(AbsListView listView, int styleResId) {
    mList = listView;
    mOldItemCount = listView.getCount();
    mOldChildCount = listView.getChildCount();

    final Context context = listView.getContext();
    mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mScrollBarStyle = listView.getScrollBarStyle();

    mScrollCompleted = true;
    mState = STATE_VISIBLE;
    mMatchDragPosition =
            context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB;

    mTrackImage = new ImageView(context);
    mTrackImage.setScaleType(ScaleType.FIT_XY);
    mThumbImage = new ImageView(context);
    mThumbImage.setScaleType(ScaleType.FIT_XY);
    mPreviewImage = new View(context);
    mPreviewImage.setAlpha(0f);

    mPrimaryText = createPreviewTextView(context);
    mSecondaryText = createPreviewTextView(context);

    mMinimumTouchTarget = listView.getResources().getDimensionPixelSize(
            com.android.internal.R.dimen.fast_scroller_minimum_touch_target);

    setStyle(styleResId);

    final ViewGroupOverlay overlay = listView.getOverlay();
    mOverlay = overlay;
    overlay.add(mTrackImage);
    overlay.add(mThumbImage);
    overlay.add(mPreviewImage);
    overlay.add(mPrimaryText);
    overlay.add(mSecondaryText);

    getSectionsFromIndexer();
    updateLongList(mOldChildCount, mOldItemCount);
    setScrollbarPosition(listView.getVerticalScrollbarPosition());
    postAutoHide();
}
 
Example #8
Source File: BasePopup.java    From EasyPopup with Apache License 2.0 4 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
private void clearDim(ViewGroup dimView) {
    ViewGroupOverlay overlay = dimView.getOverlay();
    overlay.clear();
}
 
Example #9
Source File: GuiInfoPopupWindow.java    From PhoneProfilesPlus with Apache License 2.0 4 votes vote down vote up
static void clearDim(@NonNull ViewGroup parent) {
    ViewGroupOverlay overlay = parent.getOverlay();
    overlay.clear();
}
 
Example #10
Source File: ViewUtils.java    From fontster with Apache License 2.0 4 votes vote down vote up
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);
  }
}