androidx.core.widget.NestedScrollView Java Examples

The following examples show how to use androidx.core.widget.NestedScrollView. 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: HomeSearch.java    From toktok-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onFinishInflate() {
    mBackground = (TransitionDrawable) getBackground();
    mBackground.startTransition(500);

    mBase = this.findViewById(R.id.home_search_layout);
    mCardView = this.findViewById(R.id.home_search_bar);
    NestedScrollView mRecycler = this.findViewById(R.id.home_search_bar_recycler);

    Animation searchBarAnimation = AnimationUtils.loadAnimation(mCardView.getContext(), R.anim.abc_fade_in);
    mCardView.startAnimation(searchBarAnimation);

    mInput = this.findViewById(R.id.home_search_input);

    super.onFinishInflate();
}
 
Example #2
Source File: FastScrollerBuilder.java    From AndroidFastScroll with Apache License 2.0 6 votes vote down vote up
@NonNull
private FastScroller.ViewHelper getOrCreateViewHelper() {
    if (mViewHelper != null) {
        return mViewHelper;
    }
    if (mView instanceof ViewHelperProvider) {
        return ((ViewHelperProvider) mView).getViewHelper();
    } else if (mView instanceof RecyclerView) {
        return new RecyclerViewHelper((RecyclerView) mView, mPopupTextProvider);
    } else if (mView instanceof NestedScrollView) {
        throw new UnsupportedOperationException("Please use "
                + FastScrollNestedScrollView.class.getSimpleName() + " instead of "
                + NestedScrollView.class.getSimpleName() + "for fast scroll");
    } else if (mView instanceof ScrollView) {
        throw new UnsupportedOperationException("Please use "
                + FastScrollScrollView.class.getSimpleName() + " instead of "
                + ScrollView.class.getSimpleName() + "for fast scroll");
    } else if (mView instanceof WebView) {
        throw new UnsupportedOperationException("Please use "
                + FastScrollWebView.class.getSimpleName() + " instead of "
                + WebView.class.getSimpleName() + "for fast scroll");
    } else {
        throw new UnsupportedOperationException(mView.getClass().getSimpleName()
                + " is not supported for fast scroll");
    }
}
 
Example #3
Source File: CapturePictureUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 通过 NestedScrollView 绘制为 Bitmap
 * @param scrollView {@link NestedScrollView}
 * @param config     {@link Bitmap.Config}
 * @return {@link Bitmap}
 */
public static Bitmap snapshotByNestedScrollView(final NestedScrollView scrollView, final Bitmap.Config config) {
    if (scrollView == null || config == null) return null;
    try {
        View view = scrollView.getChildAt(0);
        int width = view.getWidth();
        int height = view.getHeight();

        Bitmap bitmap = Bitmap.createBitmap(width, height, config);
        Canvas canvas = new Canvas(bitmap);
        canvas.drawColor(BACKGROUND_COLOR);
        scrollView.layout(0, 0, scrollView.getMeasuredWidth(),
                scrollView.getMeasuredHeight());
        scrollView.draw(canvas);
        return bitmap;
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "snapshotByNestedScrollView");
    }
    return null;
}
 
Example #4
Source File: WebFragment.java    From materialistic with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (isNewInstance()) {
        mFragmentView = inflater.inflate(R.layout.fragment_web, container, false);
        mFullscreenView = (ViewGroup) mFragmentView.findViewById(R.id.fullscreen);
        mScrollViewContent = (ViewGroup) mFragmentView.findViewById(R.id.scroll_view_content);
        mScrollView = (NestedScrollView) mFragmentView.findViewById(R.id.nested_scroll_view);
        mControls = (ViewSwitcher) mFragmentView.findViewById(R.id.control_switcher);
        mWebView = (WebView) mFragmentView.findViewById(R.id.web_view);
        mButtonRefresh = (ImageButton) mFragmentView.findViewById(R.id.button_refresh);
        mButtonMore = mFragmentView.findViewById(R.id.button_more);
        mButtonNext = mFragmentView.findViewById(R.id.button_next);
        mButtonNext.setEnabled(false);
        mEditText = (EditText) mFragmentView.findViewById(R.id.edittext);
        setUpWebControls(mFragmentView);
        setUpWebView(mFragmentView);
    }
    return mFragmentView;
}
 
Example #5
Source File: ListViewUtils.java    From DevUtils with Apache License 2.0 6 votes vote down vote up
/**
 * 滚动到指定位置 ( 有滚动过程 ) - 相对于上次移动的最后位置移动
 * @param view {@link View}
 * @param x    X 轴开始坐标
 * @param y    Y 轴开始坐标
 * @param <T>  泛型
 * @return {@link View}
 */
public static <T extends View> T smoothScrollBy(final T view, final int x, final int y) {
    if (view != null) {
        if (view instanceof NestedScrollView) {
            ((NestedScrollView) view).smoothScrollBy(x, y);
        } else if (view instanceof ScrollView) {
            ((ScrollView) view).smoothScrollBy(x, y);
        } else if (view instanceof HorizontalScrollView) {
            ((HorizontalScrollView) view).smoothScrollBy(x, y);
        } else if (view instanceof RecyclerView) {
            ((RecyclerView) view).smoothScrollBy(x, y);
        } else if (view instanceof ListView) {
            ((ListView) view).smoothScrollBy(y, 200); // PositionScroller.SCROLL_DURATION
        } else if (view instanceof GridView) {
            ((GridView) view).smoothScrollBy(y, 200);
        }
    }
    return view;
}
 
Example #6
Source File: BackdropBottomSheetBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 6 votes vote down vote up
/**
 * Look into the CoordiantorLayout for the {@link BottomSheetBehaviorGoogleMapsLike}
 * @param coordinatorLayout with app:layout_behavior= {@link BottomSheetBehaviorGoogleMapsLike}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof NestedScrollView) {

            try {
                BottomSheetBehaviorGoogleMapsLike temp = BottomSheetBehaviorGoogleMapsLike.from(child);
                mBottomSheetBehaviorRef = new WeakReference<>(temp);
                break;
            }
            catch (IllegalArgumentException e){}
        }
    }
}
 
Example #7
Source File: ScrollingAppBarLayoutBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 6 votes vote down vote up
/**
 * Look into the CoordiantorLayout for the {@link BottomSheetBehaviorGoogleMapsLike}
 * @param coordinatorLayout with app:layout_behavior= {@link BottomSheetBehaviorGoogleMapsLike}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof NestedScrollView) {

            try {
                BottomSheetBehaviorGoogleMapsLike temp = BottomSheetBehaviorGoogleMapsLike.from(child);
                mBottomSheetBehaviorRef = new WeakReference<>(temp);
                break;
            }
            catch (IllegalArgumentException e){}
        }
    }
}
 
Example #8
Source File: DynamicScrollUtils.java    From dynamic-support with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize nested scroll view fields so that we can access them via reflection.
 */
private static void initializeNestedScrollViewFields() {
    if (F_NESTED_SCROLL_VIEW_EDGE_GLOW_TOP != null
            && F_NESTED_SCROLL_VIEW_EDGE_GLOW_BOTTOM != null) {
        F_NESTED_SCROLL_VIEW_EDGE_GLOW_TOP.setAccessible(true);
        F_NESTED_SCROLL_VIEW_EDGE_GLOW_BOTTOM.setAccessible(true);

        return;
    }

    Class<?> clazz = NestedScrollView.class;
    for (Field field : clazz.getDeclaredFields()) {
        switch (field.getName()) {
            case "mEdgeGlowTop":
                field.setAccessible(true);
                F_NESTED_SCROLL_VIEW_EDGE_GLOW_TOP = field;
                break;
            case "mEdgeGlowBottom":
                field.setAccessible(true);
                F_NESTED_SCROLL_VIEW_EDGE_GLOW_BOTTOM = field;
                break;
        }
    }
}
 
Example #9
Source File: MergedAppBarLayoutBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 6 votes vote down vote up
/**
 * Look into the CoordiantorLayout for the {@link BottomSheetBehaviorGoogleMapsLike}
 * @param coordinatorLayout with app:layout_behavior= {@link BottomSheetBehaviorGoogleMapsLike}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof NestedScrollView) {

            try {
                BottomSheetBehaviorGoogleMapsLike temp = BottomSheetBehaviorGoogleMapsLike.from(child);
                mBottomSheetBehaviorRef = new WeakReference<>(temp);
                break;
            }
            catch (IllegalArgumentException e){}
        }
    }
}
 
Example #10
Source File: ScrollAwareFABBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 6 votes vote down vote up
/**
 * Look into the CoordiantorLayout for the {@link BottomSheetBehaviorGoogleMapsLike}
 * @param coordinatorLayout with app:layout_behavior= {@link BottomSheetBehaviorGoogleMapsLike}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

    for (int i = 0; i < coordinatorLayout.getChildCount(); i++) {
        View child = coordinatorLayout.getChildAt(i);

        if (child instanceof NestedScrollView) {

            try {
                BottomSheetBehaviorGoogleMapsLike temp = BottomSheetBehaviorGoogleMapsLike.from(child);
                mBottomSheetBehaviorRef = new WeakReference<>(temp);
                break;
            }
            catch (IllegalArgumentException e){}
        }
    }
}
 
Example #11
Source File: ViewTooltip.java    From ViewTooltip with Apache License 2.0 5 votes vote down vote up
private ViewTooltip(MyContext myContext, View view) {
    this.view = view;
    this.tooltip_view = new TooltipView(myContext.getContext());
    final NestedScrollView scrollParent = findScrollParent(view);
    if (scrollParent != null) {
        scrollParent.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                tooltip_view.setTranslationY(tooltip_view.getTranslationY() - (scrollY - oldScrollY));
            }
        });
    }
}
 
Example #12
Source File: ViewTooltip.java    From ViewTooltip with Apache License 2.0 5 votes vote down vote up
private ViewTooltip(MyContext myContext, View rootView, View view) {
    this.rootView = rootView;
    this.view = view;
    this.tooltip_view = new TooltipView(myContext.getContext());
    final NestedScrollView scrollParent = findScrollParent(view);
    if (scrollParent != null) {
        scrollParent.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                tooltip_view.setTranslationY(tooltip_view.getTranslationY() - (scrollY - oldScrollY));
            }
        });
    }
}
 
Example #13
Source File: ViewTooltip.java    From ViewTooltip with Apache License 2.0 5 votes vote down vote up
private NestedScrollView findScrollParent(View view) {
    if (view.getParent() == null || !(view.getParent() instanceof View)) {
        return null;
    } else if (view.getParent() instanceof NestedScrollView) {
        return ((NestedScrollView) view.getParent());
    } else {
        return findScrollParent(((View) view.getParent()));
    }
}
 
Example #14
Source File: BackdropBottomSheetBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 5 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
    if (dependency instanceof NestedScrollView) {
        try {
            BottomSheetBehaviorGoogleMapsLike.from(dependency);
            return true;
        }
        catch (IllegalArgumentException e){}
    }
    return false;
}
 
Example #15
Source File: ScrollAwareFABBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 5 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
    if (dependency instanceof NestedScrollView) {
        try {
            BottomSheetBehaviorGoogleMapsLike.from(dependency);
            return true;
        }
        catch (IllegalArgumentException e){}
    }
    return false;
}
 
Example #16
Source File: MergedAppBarLayoutBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 5 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
    if (dependency instanceof NestedScrollView) {
        try {
            BottomSheetBehaviorGoogleMapsLike.from(dependency);
            return true;
        }
        catch (IllegalArgumentException e){}
    }
    return false;
}
 
Example #17
Source File: ScrollingAppBarLayoutBehavior.java    From CustomBottomSheetBehavior with Apache License 2.0 5 votes vote down vote up
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
    if (dependency instanceof NestedScrollView) {
        try {
            BottomSheetBehaviorGoogleMapsLike.from(dependency);
            return true;
        }
        catch (IllegalArgumentException e){}
    }
    return false;
}
 
Example #18
Source File: Util.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
public static boolean isScrollableView(View mView) {
    return mView instanceof ScrollView
            || mView instanceof HorizontalScrollView
            || mView instanceof NestedScrollView
            || mView instanceof AbsListView
            || mView instanceof RecyclerView
            || mView instanceof ViewPager
            || mView instanceof WebView;
}
 
Example #19
Source File: BottomSheetBehaviorTest.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Test
@SmallTest
public void testFindScrollingChildEnabled() {
  Context context = activityTestRule.getActivity();
  NestedScrollView disabledParent = new NestedScrollView(context);
  disabledParent.setNestedScrollingEnabled(false);
  NestedScrollView enabledChild = new NestedScrollView(context);
  enabledChild.setNestedScrollingEnabled(true);
  disabledParent.addView(enabledChild);

  View scrollingChild = getBehavior().findScrollingChild(disabledParent);
  assertThat(scrollingChild, is((View) enabledChild));
}
 
Example #20
Source File: WebFragmentTest.java    From materialistic with Apache License 2.0 5 votes vote down vote up
@Config(shadows = ShadowNestedScrollView.class)
@Test
public void testScrollToTop() {
    NestedScrollView scrollView = activity.findViewById(R.id.nested_scroll_view);
    scrollView.smoothScrollTo(0, 1);
    assertThat(customShadowOf(scrollView).getSmoothScrollY()).isEqualTo(1);
    activity.fragment.scrollToTop();
    assertThat(customShadowOf(scrollView).getSmoothScrollY()).isEqualTo(0);

}
 
Example #21
Source File: WebFragmentTest.java    From materialistic with Apache License 2.0 5 votes vote down vote up
@Config(shadows = ShadowNestedScrollView.class)
@Test
public void testScroll() {
    ShadowNestedScrollView shadowScrollView =
            customShadowOf((NestedScrollView) activity.findViewById(R.id.nested_scroll_view));
    WebFragment fragment = (WebFragment) activity.getSupportFragmentManager()
            .findFragmentByTag(WebFragment.class.getName());
    fragment.scrollToNext();
    assertThat(shadowScrollView.getLastScrollDirection()).isEqualTo(View.FOCUS_DOWN);
    fragment.scrollToPrevious();
    assertThat(shadowScrollView.getLastScrollDirection()).isEqualTo(View.FOCUS_UP);
    fragment.scrollToTop();
    assertThat(shadowScrollView.getSmoothScrollY()).isEqualTo(0);
}
 
Example #22
Source File: SlideInContactsLayout.java    From toktok-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean dispatchTouchEvent(@NonNull MotionEvent ev) {
    Float y = ev.getY();
    NestedScrollView v = this.findViewById(R.id.contacts_nested);

    switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mInitialMotionY = y;
            break;
        case MotionEvent.ACTION_MOVE:
            break;
        case MotionEvent.ACTION_UP:
            double dy = mInitialMotionY - y;
            if (dy > 0) {
                if (mDragOffset < 0.5 && !scrollActive) {
                    smoothSlideTo(0.f);
                    scrollActive = true;
                    mStatusBar.setVisibility(View.VISIBLE);
                    mStatusBar.bringToFront();
                    scrollTop = v.getBottom();
                }
            } else {
                if (!scrollActive && Math.abs(dy) > 20) {
                    if (mDragOffset > 0.5f) {
                        finish();
                    } else {
                        smoothSlideTo(0.5f);
                        mStatusBar.setVisibility(View.INVISIBLE);
                    }
                } else {
                    if (v.getBottom() >= scrollTop) {
                        scrollActive = false;
                    }
                }
            }
    }
    return super.dispatchTouchEvent(ev);
}
 
Example #23
Source File: SetupBigHeaderActivity.java    From revolution-irc with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (mCustomContentViewId != 0)
        setContentView(mCustomContentViewId);
    else
        setContentView(R.layout.activity_setup_big_header);

    AppBarLayout appBar = findViewById(R.id.appbar);

    CollapsingToolbarLayout toolbarLayout = findViewById(R.id.toolbar_layout);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mLayout = findViewById(R.id.layout);
    mLayout.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
        int height = mLayout.getHeight();
        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams)
                appBar.getLayoutParams();
        params.height = height / 3;
        appBar.setLayoutParams(params);

        int childHeight = (mContentView != null ? mContentView.getHeight() : 0);
        if (mContentView instanceof NestedScrollView)
            childHeight = ((NestedScrollView) mContentView).getChildAt(0).getHeight();
        boolean needsScroll = (mContentView != null && childHeight > height - params.height);

        AppBarLayout.LayoutParams paramsToolbar = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams();
        paramsToolbar.setScrollFlags(needsScroll
                ? (AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED)
                : 0);
        toolbarLayout.setLayoutParams(paramsToolbar);
    });
}
 
Example #24
Source File: KeyboardMenuWidget.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onScrollChange(NestedScrollView view, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    if (scrollY == 0) {
        mCanScroll = false;
    } else {
        mCanScroll = true;
    }
}
 
Example #25
Source File: BaseModalBottomSheet.java    From CommonUtils with Apache License 2.0 5 votes vote down vote up
@Override
public final View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (payload == null) {
        dismissAllowingStateLoss();
        return null;
    }

    LayoutInflater themedInflater = createLayoutInflater(requireContext(), payload);
    if (themedInflater != null) inflater = themedInflater;

    layout = (CoordinatorLayout) inflater.inflate(R.layout.modal_bottom_sheet, container, false);
    layout.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
        if ((oldTop != top || oldBottom != bottom) && behavior != null) heightChanged();
    });

    header = layout.findViewById(R.id.modalBottomSheet_header);
    body = layout.findViewById(R.id.modalBottomSheet_body);
    loading = layout.findViewById(R.id.modalBottomSheet_loading);
    action = layout.findViewById(R.id.modalBottomSheet_action);

    onCreateHeader(inflater, header, payload);
    onCreateBody(inflater, body, payload);

    NestedScrollView scrollable = layout.findViewById(R.id.modalBottomSheet_scrollable);
    scrollable.setVisibility(hasBody ? View.VISIBLE : View.GONE);

    FrameLayout bodyNoScroll = layout.findViewById(R.id.modalBottomSheet_bodyNoScroll);
    hasNoScroll = onCreateNoScrollBody(inflater, bodyNoScroll, payload);
    bodyNoScroll.setVisibility(hasNoScroll ? View.VISIBLE : View.GONE);

    if (!hasBody && !hasNoScroll)
        throw new IllegalStateException();

    invalidateAction();
    header.setCloseOnClickListener(v -> dismiss());

    return layout;
}
 
Example #26
Source File: ListViewUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 滚动到指定位置 ( 有滚动过程 ) - 相对于初始位置移动
 * @param view {@link View}
 * @param x    X 轴开始坐标
 * @param y    Y 轴开始坐标
 * @param <T>  泛型
 * @return {@link View}
 */
public static <T extends View> T smoothScrollTo(final T view, final int x, final int y) {
    if (view != null) {
        if (view instanceof NestedScrollView) {
            ((NestedScrollView) view).smoothScrollTo(x, y);
        } else if (view instanceof ScrollView) {
            ((ScrollView) view).smoothScrollTo(x, y);
        } else if (view instanceof HorizontalScrollView) {
            ((HorizontalScrollView) view).smoothScrollTo(x, y);
        }
    }
    return view;
}
 
Example #27
Source File: ListViewUtils.java    From DevUtils with Apache License 2.0 5 votes vote down vote up
/**
 * 滚动方向 ( 有滚动过程 )
 * @param view      {@link View}
 * @param direction 滚动方向 如: View.FOCUS_UP、View.FOCUS_DOWN
 * @param <T>       泛型
 * @return {@link View}
 */
public static <T extends View> T fullScroll(final T view, final int direction) {
    if (view != null) {
        if (view instanceof NestedScrollView) {
            ((NestedScrollView) view).fullScroll(direction);
        } else if (view instanceof ScrollView) {
            ((ScrollView) view).fullScroll(direction);
        } else if (view instanceof HorizontalScrollView) {
            ((HorizontalScrollView) view).fullScroll(direction);
        }
    }
    return view;
}
 
Example #28
Source File: DynamicScrollUtils.java    From dynamic-support with Apache License 2.0 5 votes vote down vote up
/**
 * Set edge effect or glow color for nested scroll view.
 *
 * @param nestedScrollView The nested scroll view to set the edge effect color.
 * @param color The edge effect color to be set.
 */
public static void setEdgeEffectColor(
        @NonNull NestedScrollView nestedScrollView, @ColorInt int color) {
    initializeNestedScrollViewFields();

    try {
        Object edgeEffect =
                F_NESTED_SCROLL_VIEW_EDGE_GLOW_TOP.get(nestedScrollView);
        setEdgeEffectColor(edgeEffect, color);
        edgeEffect =
                F_NESTED_SCROLL_VIEW_EDGE_GLOW_BOTTOM.get(nestedScrollView);
        setEdgeEffectColor(edgeEffect, color);
    } catch (Exception ignored) {
    }
}
 
Example #29
Source File: WebDetailActivity.java    From GSYVideoPlayer with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_detail);
    ButterKnife.bind(this);

    backupRendType = GSYVideoType.getRenderType();

    //设置为Surface播放模式,注意此设置是全局的
    GSYVideoType.setRenderType(GSYVideoType.SUFRACE);

    resolveNormalVideoUI();

    initVideoBuilderMode();


    webPlayer.setLockClickListener(new LockClickListener() {
        @Override
        public void onClick(View view, boolean lock) {
            if (orientationUtils != null) {
                //配合下方的onConfigurationChanged
                orientationUtils.setEnable(!lock);
                webPlayer.getCurrentPlayer().setRotateViewAuto(!lock);
            }
        }
    });


    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    webView.loadUrl("https://www.baidu.com");


    orientationUtils.setRotateWithSystem(false);

    webTopLayout.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            if (!webPlayer.isIfCurrentIsFullscreen() && scrollY >= 0 && isPlay) {
                if (scrollY > webPlayer.getHeight()) {
                    //如果是小窗口就不需要处理
                    if (!isSmall) {
                        isSmall = true;
                        int size = CommonUtil.dip2px(WebDetailActivity.this, 150);
                        webPlayer.showSmallVideo(new Point(size, size), true, true);
                        orientationUtils.setEnable(false);
                    }
                } else {
                    if (isSmall) {
                        isSmall = false;
                        orientationUtils.setEnable(true);
                        //必须
                        webTopLayoutVideo.postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                webPlayer.hideSmallVideo();
                            }
                        }, 50);
                    }
                }
                webTopLayoutVideo.setTranslationY((scrollY <= webTopLayoutVideo.getHeight()) ? -scrollY : -webTopLayoutVideo.getHeight());
            }
        }
    });

}
 
Example #30
Source File: FlingingNestedScrollView.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
void onScrollChanged(NestedScrollView who, int l, int t, int oldl,
int oldt);