Java 类android.support.v4.widget.NestedScrollView 实例源码

项目:pracler    文件:PlayListActivity.java   
public void viewInitialize()
{
    mainListView = (ListView) findViewById(R.id.listview);
    scrollview = (NestedScrollView) findViewById(R.id.scrollview);
    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Log.e("PlayListFragment", i+"/"+l);
            global.playMusic(Integer.parseInt(playList.get(i)));
        }
    });
    mainListView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event)
        {
            scrollview.requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });

}
项目:GitHub    文件:Utils.java   
public static void scrollTo(Object scroll, float yOffset) {
    if (scroll instanceof RecyclerView) {
        //RecyclerView.scrollTo : UnsupportedOperationException
        //Moved to the RecyclerView.LayoutManager.scrollToPositionWithOffset
        //Have to be instanceOf RecyclerView.LayoutManager to work (so work with RecyclerView.GridLayoutManager)
        final RecyclerView.LayoutManager layoutManager = ((RecyclerView) scroll).getLayoutManager();
        if (layoutManager instanceof LinearLayoutManager) {
            LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
            linearLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
        } else if (layoutManager instanceof StaggeredGridLayoutManager) {
            StaggeredGridLayoutManager staggeredGridLayoutManager = (StaggeredGridLayoutManager) layoutManager;
            staggeredGridLayoutManager.scrollToPositionWithOffset(0, (int) -yOffset);
        }
    } else if (scroll instanceof NestedScrollView) {
        ((NestedScrollView) scroll).scrollTo(0, (int) yOffset);
    }
}
项目:Rxjava2.0Demo    文件:RefreshContentWrapper.java   
@Override
public boolean fling(int velocity) {
    if (mScrollableView instanceof ScrollView) {
        ((ScrollView) mScrollableView).fling(velocity);
    } else if (mScrollableView instanceof AbsListView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ((AbsListView) mScrollableView).fling(velocity);
        }
    } else if (mScrollableView instanceof WebView) {
        ((WebView) mScrollableView).flingScroll(0, velocity);
    } else if (mScrollableView instanceof RecyclerView) {
        ((RecyclerView) mScrollableView).fling(0, velocity);
    } else if (mScrollableView instanceof NestedScrollView) {
        ((NestedScrollView) mScrollableView).fling(velocity);
    } else {
        return false;
    }
    return true;
}
项目:ScrimInsetsLayout    文件:ScrollAndNavigationActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
                    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    );
    setContentView(R.layout.activity_scroll_and_navigation);

    final NestedScrollView nestedScrollView = findViewById(R.id.scrollview);

    final AppBarLayout appBarLayout = findViewById(R.id.appbar);

    final Toolbar toolbar = findViewById(R.id.toolbar);
    toolbar.setTitle("Wow");

    ScrimInsetsFrameLayout scrimInsetsFrameLayout = findViewById(R.id.root_insets);
    scrimInsetsFrameLayout.setOnInsetsCallback(new OnInsetsCallback() {
        @Override
        public void onInsetsChanged(Rect insets) {
            appBarLayout.setPadding(0, insets.top, 0, 0);
            nestedScrollView.setPadding(0, 0, 0, insets.bottom);
        }
    });
}
项目:SmoothRefreshLayout    文件:ScrollCompat.java   
public static void flingCompat(View view, int velocityY) {
    if (view instanceof ScrollView) {
        ((ScrollView) view).fling(velocityY);
    } else if (view instanceof WebView) {
        ((WebView) view).flingScroll(0, velocityY);
    } else if (view instanceof RecyclerView) {
        ((RecyclerView) view).fling(0, velocityY);
    } else if (view instanceof NestedScrollView) {
        ((NestedScrollView) view).fling(velocityY);
    } else if (view instanceof AbsListView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ((AbsListView) view).fling(velocityY);
        } else {
            SRReflectUtil.compatOlderAbsListViewFling((AbsListView) view, velocityY);
        }
    }
}
项目:Selector    文件:GoodsDetailActivity.java   
@Override public void onScrollChange(NestedScrollView v, int x, int y, int oldx, int oldy) {
  if (y <= 0) {   //设置标题的背景颜色
    llGoodDetail.setBackgroundColor(Color.argb(0, 255, 255, 255));
    line.setVisibility(View.GONE);
    tvGoodDetailTitleGood.setTextColor(Color.TRANSPARENT);
  } else if (y > 0 && y <= height) { //滑动距离小于banner图的高度时,设置背景和字体颜色颜色透明度渐变
    float scale = (float) y / height;
    float alpha = (255 * scale);
    tvGoodDetailTitleGood.setTextColor(Color.argb((int) alpha, 1, 24, 28));
    llGoodDetail.setBackgroundColor(Color.argb((int) alpha, 255, 255, 255));
    line.setVisibility(View.GONE);
  } else {    //滑动到banner下面设置普通颜色
    llGoodDetail.setBackgroundColor(Color.argb(255, 255, 255, 255));
    line.setVisibility(View.VISIBLE);
  }
}
项目:betterHotels    文件:FlingBehavior.java   
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
                             float velocityX, float velocityY, boolean consumed) {

    if (target instanceof RecyclerView && velocityY < 0) {
        Log.d(TAG, "onNestedFling: target is recyclerView");
        final RecyclerView recyclerView = (RecyclerView) target;
        final View firstChild = recyclerView.getChildAt(0);
        final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
        consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
    }

    // prevent fling flickering when going up
    if (target instanceof NestedScrollView && velocityY > 0) {
        consumed = true;
    }

    if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
        velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
    }
    Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);

    return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
项目:ZhaZhaShop    文件:MovieStarActivity.java   
private void initDynamicTitle() {
    mRlTopContainer.measure(0, 0);
    mLlTitle.measure(0, 0);
    final int topHeight = mRlTopContainer.getMeasuredHeight() - mLlTitle.getMeasuredHeight();

    mScStarDetail.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            float scale = (float) v.getScrollY() / topHeight;

            //变化范围0-255 表示从透明到纯色背景
            float alpha = scale * 255 >= 255 ? 255 : scale * 255;

            mLlTitle.setBackgroundColor(Color.argb((int) alpha, 0, 153, 204));
            mTvTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
            mTvSubTitle.setTextColor(Color.argb((int) alpha, 255, 255, 255));
        }
    });
}
项目:qvod    文件:MovieDetailsPresenter.java   
private void initListener() {
    //finish
    getView().toolBar.setNavigationOnClickListener(view -> getView().onBackPressed());
    //
    getView().nsvTitle.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
            scrollChangeHeader(scrollY);
        }
    });
    getView().llLoading.setOnReloadListener(v -> {
        if (JUtils.isNetWorkAvilable())
            //onClick
            initData();
    });
    getView().toolBar.setOnMenuItemClickListener(item -> {
        if (item.getItemId() == R.id.actionbar_more) {
            WebViewActivity.startAction(getView(), positionData.getAlt());
        }
        return false;
    });
}
项目:GeekZone    文件:ThemeListActivity.java   
@Override
protected void initData() {
    mId = getIntent().getIntExtra(EXTRA_THEME_ID, 0);
    final String name = getIntent().getStringExtra(EXTRA_THEME_NAME);

    mToolbar.setTitle(name);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mZhihuListRecyclerView.setLayoutParams(new NestedScrollView.LayoutParams(
            NestedScrollView.LayoutParams.MATCH_PARENT,
            NestedScrollView.LayoutParams.MATCH_PARENT));
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mZhihuListRecyclerView.setLayoutManager(layoutManager);
    mZhihuListRecyclerView.setAdapter(mThemeListAdapter);
    mPresenter.loadThemesList(mId);
}
项目:GeekZone    文件:ColumnListActivity.java   
@Override
protected void initData() {
    mColumnAuthorHref = getIntent().getStringExtra(EXTRA_AUTHOR_NAME);
    mToolbar.setTitle(null);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mColumnListRecyclerView.setLayoutParams(new NestedScrollView.LayoutParams(
            NestedScrollView.LayoutParams.MATCH_PARENT,
            NestedScrollView.LayoutParams.MATCH_PARENT));
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mColumnListRecyclerView.setLayoutManager(layoutManager);
    mColumnListRecyclerView.setAdapter(mColumnListAdapter);
    mPresenter.loadColumnAuthorInfo(mColumnAuthorHref);
    mPresenter.loadColumnList(mColumnAuthorHref);
    mIsLiked = mPresenter.isZhiHuColumnAuthorLiked(mColumnAuthorHref);
    mLikeAuthor.setText(getString(mIsLiked ? R.string.zhihu_followed : R.string.zhihu_follow));
}
项目:Tribe    文件:FlingBehavior.java   
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
                             float velocityX, float velocityY, boolean consumed) {
    if (target instanceof RecyclerView && velocityY < 0) {
        Log.d(TAG, "onNestedFling: target is recyclerView");
        final RecyclerView recyclerView = (RecyclerView) target;
        final View firstChild = recyclerView.getChildAt(0);
        final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
        consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
    }

    // prevent fling flickering when going up
    if (target instanceof NestedScrollView && velocityY > 0) {
        consumed = true;
    }

    if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
        velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
    }
    Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);

    return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
项目:iSPY    文件:RegisterActivity.java   
/**
 * This method is to initialize views
 */
private void initViews() {
    nestedScrollView = (NestedScrollView) findViewById(R.id.nestedScrollView);

    textInputLayoutName = (TextInputLayout) findViewById(R.id.textInputLayoutName);
    textInputLayoutEmail = (TextInputLayout) findViewById(R.id.textInputLayoutEmail);
    textInputLayoutPassword = (TextInputLayout) findViewById(R.id.textInputLayoutPassword);
    textInputLayoutConfirmPassword = (TextInputLayout) findViewById(R.id.textInputLayoutConfirmPassword);

    textInputEditTextName = (TextInputEditText) findViewById(R.id.textInputEditTextName);
    textInputEditTextEmail = (TextInputEditText) findViewById(R.id.textInputEditTextEmail);
    textInputEditTextPassword = (TextInputEditText) findViewById(R.id.textInputEditTextPassword);
    textInputEditTextConfirmPassword = (TextInputEditText) findViewById(R.id.textInputEditTextConfirmPassword);

    appCompatButtonRegister = (AppCompatButton) findViewById(R.id.appCompatButtonRegister);

    appCompatTextViewLoginLink = (AppCompatTextView) findViewById(R.id.appCompatTextViewLoginLink);

}
项目:OSchina_resources_android    文件:TabPickerView.java   
private void initWidgets() {
    View view = LayoutInflater.from(getContext())
            .inflate(R.layout.view_tab_picker, this, false);

    mRecyclerActive = (RecyclerView) view.findViewById(R.id.view_recycler_active);
    mRecyclerInactive = (RecyclerView) view.findViewById(R.id.view_recycler_inactive);
    mViewScroller = (NestedScrollView) view.findViewById(R.id.view_scroller);
    mLayoutTop = (RelativeLayout) view.findViewById(R.id.layout_top);
    mViewWrapper = (LinearLayout) view.findViewById(R.id.view_wrapper);
    mViewDone = (TextView) view.findViewById(R.id.tv_done);
    mViewOperator = (TextView) view.findViewById(R.id.tv_operator);
    mLayoutWrapper = (LinearLayout) view.findViewById(R.id.layout_wrapper);
    mViewDone.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mViewDone.getText().toString().equals("排序删除")) {
                mActiveAdapter.startEditMode();
            } else {
                mActiveAdapter.cancelEditMode();
            }
        }
    });

    addView(view);
}
项目:LiuAGeAndroid    文件:PhotoDetailActivity.java   
/**
 * 准备UI
 */
private void prepareUI() {
    mViewPager = (ViewPager) findViewById(R.id.vp_photo_detail_viewPager);
    mTopLayout = findViewById(R.id.ll_photo_detail_top_layout);
    mPageTextView = (TextView) findViewById(R.id.tv_photo_detail_page);
    mReportTextView = (TextView) findViewById(R.id.tv_photo_detail_report);
    mProgressBar = (ProgressBar) findViewById(R.id.pb_photo_detail_progressbar);
    mBottomLayout = findViewById(R.id.ll_photo_detail_bottom_layout);
    mCaptionScriollView = (NestedScrollView) findViewById(R.id.nsv_photo_detail_caption_scrollview);
    mCaptionTextView = (TextView) findViewById(R.id.tv_photo_detail_caption);
    mBackButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_back);
    mEditButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_edit);
    mCommentButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_comment);
    mCollectionButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_collection);
    mShareButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_share);
    mPlnumTextView = (TextView) findViewById(R.id.tv_photo_detail_plnum);

    // 监听点击事件
    mReportTextView.setOnClickListener(this);
    mBackButton.setOnClickListener(this);
    mEditButton.setOnClickListener(this);
    mCommentButton.setOnClickListener(this);
    mCollectionButton.setOnClickListener(this);
    mShareButton.setOnClickListener(this);

}
项目:ApplicationCollention    文件:FlingBehavior.java   
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
                             float velocityX, float velocityY, boolean consumed) {

    if (target instanceof RecyclerView && velocityY < 0) {
        Log.d(TAG, "onNestedFling: target is recyclerView");
        final RecyclerView recyclerView = (RecyclerView) target;
        final View firstChild = recyclerView.getChildAt(0);
        final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
        consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
    }

    // prevent fling flickering when going up
    if (target instanceof NestedScrollView && velocityY > 0) {
        consumed = true;
    }

    if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
        velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
    }
    Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);

    return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
项目:Expert-Android-Programming    文件:Utils.java   
public static boolean syncOffset(SmoothAppBarLayout smoothAppBarLayout, View target, int verticalOffset, View scroll) {
  boolean isSelected = target == scroll;
  if (scroll instanceof NestedScrollView) {
    NestedScrollView nestedScrollView = (NestedScrollView) scroll;
    if (nestedScrollView.getScrollY() < verticalOffset || (!isSelected && isScrollToTop(target))) {
      nestedScrollView.scrollTo(0, verticalOffset);
    }
    if (isSelected && (nestedScrollView.getScrollY() < verticalOffset || verticalOffset == 0)) {
      nestedScrollView.scrollTo(0, 0);
      smoothAppBarLayout.syncOffset(0);
    }
  } else if (scroll instanceof RecyclerView) {
    RecyclerView recyclerView = (RecyclerView) scroll;
    boolean isAccuracy = recyclerView.getLayoutManager().findViewByPosition(ObservableRecyclerView.HEADER_VIEW_POSITION) != null;
    if (isAccuracy && recyclerView.computeVerticalScrollOffset() < verticalOffset) {
      recyclerView.scrollBy(0, verticalOffset - recyclerView.computeVerticalScrollOffset());
    } else if (!isSelected && isScrollToTop(target)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
    }
    if (isAccuracy && isSelected && (recyclerView.computeVerticalScrollOffset() < verticalOffset || verticalOffset == 0)) {
      recyclerView.scrollToPosition(ObservableRecyclerView.HEADER_VIEW_POSITION);
      smoothAppBarLayout.syncOffset(0);
    }
  }
  return true;
}
项目:Expert-Android-Programming    文件:Utils.java   
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
  int currentOffset = 0;
  if (!mDone) {
    if (v instanceof NestedScrollView) {
      currentOffset = v.getScrollY();
    } else if (v instanceof RecyclerView) {
      currentOffset = ((RecyclerView) v).computeVerticalScrollOffset();
    }
    if (currentOffset < mOffset) {
      vTarget.scrollBy(0, mOffset - currentOffset);
    } else {
      vSmoothAppBarLayout.syncOffset(mOffset);
      mDone = true;
    }
  }
}
项目:Expert-Android-Programming    文件:BaseBehavior.java   
private void initScrollTarget(final CoordinatorLayout coordinatorLayout, final AppBarLayout child) {
  Utils.log("initScrollTarget | %b", vScrollTarget != null);
  if (vScrollTarget != null) {
    long tag = getViewTag(vScrollTarget, true);
    if (!mScrollTargets.contains(tag)) {
      mScrollTargets.add(tag);
      OnScrollListener listener = new OnScrollListener() {

        @Override
        public void onScrollChanged(View view, int x, int y, int dx, int dy, boolean accuracy) {
          if (view == vScrollTarget) {
            BaseBehavior.this.onScrollChanged(coordinatorLayout, child, view, y, dy, accuracy);
          }
        }
      };
      if (vScrollTarget instanceof NestedScrollView) {
        ObservableNestedScrollView.newInstance((NestedScrollView) vScrollTarget, mOverrideOnScrollListener, listener);
      } else if (vScrollTarget instanceof RecyclerView) {
        ObservableRecyclerView.newInstance((RecyclerView) vScrollTarget, listener);
      }
    }
  }
}
项目:boohee_v5.6    文件:AlertController.java   
private void setupContent(ViewGroup contentPanel) {
    this.mScrollView = (NestedScrollView) this.mWindow.findViewById(R.id.scrollView);
    this.mScrollView.setFocusable(false);
    this.mScrollView.setNestedScrollingEnabled(false);
    this.mMessageView = (TextView) contentPanel.findViewById(16908299);
    if (this.mMessageView != null) {
        if (this.mMessage != null) {
            this.mMessageView.setText(this.mMessage);
            return;
        }
        this.mMessageView.setVisibility(8);
        this.mScrollView.removeView(this.mMessageView);
        if (this.mListView != null) {
            ViewGroup scrollParent = (ViewGroup) this.mScrollView.getParent();
            int childIndex = scrollParent.indexOfChild(this.mScrollView);
            scrollParent.removeViewAt(childIndex);
            scrollParent.addView(this.mListView, childIndex, new LayoutParams(-1, -1));
            return;
        }
        contentPanel.setVisibility(8);
    }
}
项目:starcraft-2-build-player    文件:OnScrollDirectionChangedListener.java   
@Override
public final void onScrollChange(NestedScrollView v,
                                 int scrollX,
                                 int scrollY,
                                 int oldScrollX,
                                 int oldScrollY) {
    int yDelta = scrollY - oldScrollY;

    if (yDelta > 0 && oldYDelta <= 0) {
        onStartScrollingDown();
    } else if (yDelta < 0 && oldYDelta >= 0) {
        onStartScrollingUp();
    }

    oldYDelta = yDelta;
}
项目:SmartRefreshLayout    文件:RefreshContentWrapper.java   
@Override
public void fling(int velocity) {
    if (mScrollableView instanceof ScrollView) {
        ((ScrollView) mScrollableView).fling(velocity);
    } else if (mScrollableView instanceof AbsListView) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ((AbsListView) mScrollableView).fling(velocity);
        }
    } else if (mScrollableView instanceof WebView) {
        ((WebView) mScrollableView).flingScroll(0, velocity);
    } else if (mScrollableView instanceof RecyclerView) {
        ((RecyclerView) mScrollableView).fling(0, velocity);
    } else if (mScrollableView instanceof NestedScrollView) {
        ((NestedScrollView) mScrollableView).fling(velocity);
    }
}
项目:Nibo    文件:ScrollAwareFABBehavior.java   
/**
 * 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){}
        }
    }
}
项目:Multi-SwipeBackLayout    文件:SwipeBackLayout.java   
/**
 * Find out the scrollable child view
 * 这里添加了常用的一些可滑动类,特殊类需要添加
 *
 * @param target targetView
 */
private void findScrollView(ViewGroup target) {
    final int count = target.getChildCount();
    if (count > 0) {
        for (int i = 0; i < count; i++) {
            final View child = target.getChildAt(i);
            if (child instanceof AbsListView
                    || isInstanceOfClass(child, ScrollView.class.getName())
                    || isInstanceOfClass(child, NestedScrollView.class.getName())
                    || isInstanceOfClass(child, RecyclerView.class.getName())
                    || child instanceof HorizontalScrollView
                    || child instanceof ViewPager
                    || child instanceof WebView) {
                mScrollChild = child;
                break;
            } else if (child instanceof ViewGroup) {
                findScrollView((ViewGroup) child);
            }
        }
    }
    if (mScrollChild == null) mScrollChild = target;
}
项目:Mybilibili    文件:NewsDetailActivity.java   
private void initView() {
    mToolbar = (Toolbar) findViewById(R.id.toolbar_news_detail);
    setSupportActionBar(mToolbar);
    mToolbar.setNavigationIcon(R.mipmap.back);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            onBackPressed();
        }
    });
    mNestedScrollView = (NestedScrollView) findViewById(R.id.nest);
    mLayout = (LinearLayout)findViewById(R.id.ll_news_detail);
    mImageViewone = (ImageView)findViewById(R.id.iv_news_detail_one);
    mImageViewtwo = (ImageView) findViewById(R.id.iv_news_detail_two);
    mImageViewthree = (ImageView) findViewById(R.id.iv_news_detail_three);

}
项目:DereHelper    文件:BeatMapActivity.java   
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_beat_map);
        String noteData = umi.getIntentString("data");
//        String name = umi.getIntentString("name");
        scrollView = (NestedScrollView)findViewById(R.id.scrollView);
        VerticalSeekBar seekBar = (VerticalSeekBar)findViewById(R.id.seekBar);
        ScrollBindHelper.bind(seekBar, scrollView);
        BeatMapView beatMapView = (BeatMapView)findViewById(R.id.beat_map);
        beatMapView.setData(noteData);
        setActionBarTitle(R.string.beat_map_view);
        setActionBarTxt(String.format("%d Notes", beatMapView.getData().get(0).status));
        initActionBar(ACTIONBAR_TYPE_TXT);
        TextView abTxt = (TextView)findViewById(R.id.actionBar_txtBtn);
        abTxt.setTextSize(14);
        anchor = beatMapView.getFistNoteY() - 450;
    }
项目:BaoKanAndroid    文件:PhotoDetailActivity.java   
/**
 * 准备UI
 */
private void prepareUI() {
    mViewPager = (ViewPager) findViewById(R.id.vp_photo_detail_viewPager);
    mTopLayout = findViewById(R.id.ll_photo_detail_top_layout);
    mPageTextView = (TextView) findViewById(R.id.tv_photo_detail_page);
    mReportTextView = (TextView) findViewById(R.id.tv_photo_detail_report);
    mProgressBar = (ProgressBar) findViewById(R.id.pb_photo_detail_progressbar);
    mBottomLayout = findViewById(R.id.ll_photo_detail_bottom_layout);
    mCaptionScriollView = (NestedScrollView) findViewById(R.id.nsv_photo_detail_caption_scrollview);
    mCaptionTextView = (TextView) findViewById(R.id.tv_photo_detail_caption);
    mBackButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_back);
    mEditButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_edit);
    mCommentButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_comment);
    mCollectionButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_collection);
    mShareButton = (ImageButton) findViewById(R.id.ib_photo_detail_bottom_bar_share);
    mPlnumTextView = (TextView) findViewById(R.id.tv_photo_detail_plnum);

    // 监听点击事件
    mReportTextView.setOnClickListener(this);
    mBackButton.setOnClickListener(this);
    mEditButton.setOnClickListener(this);
    mCommentButton.setOnClickListener(this);
    mCollectionButton.setOnClickListener(this);
    mShareButton.setOnClickListener(this);

}
项目:solved-hacking-problem    文件:C0215e.java   
private void m1932c(ViewGroup viewGroup) {
    this.f770w = (NestedScrollView) this.f750c.findViewById(C0238g.scrollView);
    this.f770w.setFocusable(false);
    this.f770w.setNestedScrollingEnabled(false);
    this.f735B = (TextView) viewGroup.findViewById(16908299);
    if (this.f735B != null) {
        if (this.f752e != null) {
            this.f735B.setText(this.f752e);
            return;
        }
        this.f735B.setVisibility(8);
        this.f770w.removeView(this.f735B);
        if (this.f753f != null) {
            ViewGroup viewGroup2 = (ViewGroup) this.f770w.getParent();
            int indexOfChild = viewGroup2.indexOfChild(this.f770w);
            viewGroup2.removeViewAt(indexOfChild);
            viewGroup2.addView(this.f753f, indexOfChild, new LayoutParams(-1, -1));
            return;
        }
        viewGroup.setVisibility(8);
    }
}
项目:solved-hacking-problem    文件:C0215e.java   
private void m1932c(ViewGroup viewGroup) {
    this.f770w = (NestedScrollView) this.f750c.findViewById(C0238g.scrollView);
    this.f770w.setFocusable(false);
    this.f770w.setNestedScrollingEnabled(false);
    this.f735B = (TextView) viewGroup.findViewById(16908299);
    if (this.f735B != null) {
        if (this.f752e != null) {
            this.f735B.setText(this.f752e);
            return;
        }
        this.f735B.setVisibility(8);
        this.f770w.removeView(this.f735B);
        if (this.f753f != null) {
            ViewGroup viewGroup2 = (ViewGroup) this.f770w.getParent();
            int indexOfChild = viewGroup2.indexOfChild(this.f770w);
            viewGroup2.removeViewAt(indexOfChild);
            viewGroup2.addView(this.f753f, indexOfChild, new LayoutParams(-1, -1));
            return;
        }
        viewGroup.setVisibility(8);
    }
}
项目:px-android    文件:ReviewAndConfirmActivity.java   
private void initializeControls() {
    mScrollView = (NestedScrollView) findViewById(R.id.mpsdkReviewScrollView);
    mCollapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.mpsdkCollapsingToolbar);
    mAppBar = (AppBarLayout) findViewById(R.id.mpsdkCheckoutAppBar);
    mToolbar = (Toolbar) findViewById(R.id.mpsdkRegularToolbar);
    mFloatingConfirmButton = (FrameLayout) findViewById(R.id.mpsdkCheckoutFloatingConfirmButton);
    mFloatingConfirmTextButton = (MPTextView) findViewById(R.id.mpsdkFloatingConfirmText);
    mFloatingConfirmView = (FrameLayout) findViewById(R.id.mpsdkCheckoutFloatingConfirmView);
    mConfirmButton = (FrameLayout) findViewById(R.id.mpsdkCheckoutConfirmButton);
    mConfirmTextButton = (MPTextView) findViewById(R.id.mpsdkConfirmText);
    mCancelButton = (FrameLayout) findViewById(R.id.mpsdkReviewCancelButton);
    mCancelTextView = (MPTextView) findViewById(R.id.mpsdkCancelText);
    mTermsAndConditionsButton = (LinearLayout) findViewById(R.id.mpsdkCheckoutTermsAndConditions);
    mTermsAndConditionsTextView = (MPTextView) findViewById(R.id.mpsdkReviewTermsAndConditions);
    mTimerTextView = (MPTextView) findViewById(R.id.mpsdkTimerTextView);
    mReviewables = (RecyclerView) findViewById(R.id.mpsdkReviewablesRecyclerView);
    mSeparatorView = findViewById(R.id.mpsdkFirstSeparator);

    initializeToolbar();
    decorateButtons();
}
项目:GpCollapsingToolbar    文件:ScrollController.java   
private void calculateDistance(View view, int scrollY, int oldScrollY) {
    if (mAppBarScrollRange == null || mNestedScrollRange == null) {
        return;
    }

    int totalScrollRange = mAppBarScrollRange + mNestedScrollRange;

    if (view instanceof AppBarLayout) {
        mAppBarScrollPosition = Math.abs(-scrollY);
    } else if (view instanceof NestedScrollView) {
        mNestedScrollPosition = view.getScrollY();
    }

    int scrollPosition = mAppBarScrollPosition + mNestedScrollPosition;
    mScrollPositionMultiplier = (double) (scrollPosition / totalScrollRange);
    if (mOnTotalScrollChangeListener != null) {
        mOnTotalScrollChangeListener.onTotalScrollChanged(view, scrollPosition, mOldScrollPosition, totalScrollRange);
    }
    mOldScrollPosition = scrollPosition;
}
项目:GpCollapsingToolbar    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ac_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    ImageView imageView = (ImageView) findViewById(R.id.image);
    mNestedScroll = (NestedScrollView) findViewById(R.id.nestedScroll);
    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
    mParallaxView = (ScrollView) findViewById(R.id.parallax);
    mFab = (FloatingActionButton) findViewById(R.id.fab);
    setSupportActionBar(toolbar);

    setupToolbarAndStatusBar();
    Picasso.with(this).load("https://i.ytimg.com/vi/Un5SEJ8MyPc/maxresdefault.jpg")
            .into(imageView);
    mScrollController.onCreate(savedInstanceState);
}
项目:grooo    文件:FabBottomSheetBehavior.java   
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {

    if (offset == 0)
        setOffsetValue(parent);

    if (child.getY() <= (offset + child.getHeight()) && child.getVisibility() == View.VISIBLE)
        child.hide();
    else if (child.getY() > offset && child.getVisibility() != View.VISIBLE)
        child.show();

    if (dependency instanceof NestedScrollView) {
        maybeInitProperties(child, dependency);

        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
            //toolbar被移走的距离与本身高度的比值
            float ty = dependency.getY() - startDependencyY;
            if (ty > 0) {
                float ratio = ty / (float) bottomSheetPeekHeight;
                //toolbar被移走几分之几,fab就向下滑几分之几
                child.setTranslationY(distanceToScroll * ratio);
            }
        }
    }
    return true;
}
项目:bigbang    文件:OnDemandRecyclerViewScrollListener.java   
/**
 * Called when the scroll position of the nested scroll view changes.
 *
 * @param nestedScrollView The view whose scroll position has changed.
 * @param scrollX          Current horizontal scroll origin.
 * @param scrollY          Current vertical scroll origin.
 * @param oldScrollX       Previous horizontal scroll origin.
 * @param oldScrollY       Previous vertical scroll origin.
 */
@Override
public void onScrollChange(@NonNull NestedScrollView nestedScrollView, int scrollX, int scrollY,
                           int oldScrollX, int oldScrollY) {
  if (previousRecyclerViewHeight < recyclerView.getMeasuredHeight()) {
    loading = false;
    page++;
    previousRecyclerViewHeight = recyclerView.getMeasuredHeight();
  }

  if ((scrollY + visibleThreshold >= (recyclerView.getMeasuredHeight() - nestedScrollView.getMeasuredHeight())) &&
      scrollY > oldScrollY && !loading && enabled) {
    loading = true;
    loadNextPage(page);
  }
}
项目:PullToLoadView    文件:ScrollViewActivity.java   
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scrollview);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    setTitle(R.string.demo_4_title);

    mPTLNestedScrollView = (PTLNestedScrollView) findViewById(R.id.scrollview);

    if(mPTLNestedScrollView != null){
        mPTLNestedScrollView.setOnPullToLoadListener(this);
        mPTLNestedScrollView.getContentView().setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                final int height = mPTLNestedScrollView.getBarHeight() * 2;
                if (scrollY >= height) {
                    toolbar.setAlpha(0.8f);
                } else {
                    toolbar.setAlpha(1 - 0.2f * scrollY / height);
                }
            }
        });
    }
}
项目:betterHotels    文件:FlingBehavior.java   
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target,
                             float velocityX, float velocityY, boolean consumed) {

    if (target instanceof RecyclerView && velocityY < 0) {
        Log.d(TAG, "onNestedFling: target is recyclerView");
        final RecyclerView recyclerView = (RecyclerView) target;
        final View firstChild = recyclerView.getChildAt(0);
        final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
        consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
    }

    // prevent fling flickering when going up
    if (target instanceof NestedScrollView && velocityY > 0) {
        consumed = true;
    }

    if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
        velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
    }
    Log.d(TAG, "onNestedFling: velocityY - " + velocityY + ", consumed - " + consumed);

    return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
项目:GeometricWeather    文件:MainActivity.java   
@Override
public void onScrollChange(NestedScrollView v,
                           int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    weatherView.onScroll(scrollY);

    // set translation y of toolbar.
    if (scrollY < firstCardMarginTop - appBar.getMeasuredHeight() - realtimeTemp.getMeasuredHeight()) {
        appBar.setTranslationY(0);
    } else if (scrollY > firstCardMarginTop - appBar.getY()) {
        appBar.setTranslationY(-appBar.getMeasuredHeight());
    } else {
        appBar.setTranslationY(
                firstCardMarginTop - realtimeTemp.getMeasuredHeight() - scrollY
                        - appBar.getMeasuredHeight());
    }

    // set status bar style.
    if (oldScrollY < overlapTriggerDistance && overlapTriggerDistance <= scrollY) {
        DisplayUtils.setStatusBarStyleWithScrolling(getWindow(), statusBar, true);
    } else if (oldScrollY >= overlapTriggerDistance && overlapTriggerDistance > scrollY) {
        DisplayUtils.setStatusBarStyleWithScrolling(getWindow(), statusBar, false);
    }
}
项目:MifareClassicTool    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setIcon(R.mipmap.ic_launcher);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    sConsoleWnd = getWindow();
    sConsoleOutput = (TextView)findViewById(R.id.consoleOutput);
    sConsoleScrollHorizontal = (HorizontalScrollView)findViewById(R.id.consoleScrollHorizontal);
    sConsoleScrollVertical = (NestedScrollView)findViewById(R.id.consoleScrollVertical);
    mConsoleTextColorDefault = ContextCompat.getColor(this, R.color.colorConsoleTextDefault);
    mConsoleTextColorWarn = ContextCompat.getColor(this, R.color.colorConsoleTextWarning);
    mConsoleTextColorNotice = ContextCompat.getColor(this, R.color.colorConsoleTextNotice);

}
项目:ExtraWebView    文件:BaseWebFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = getLayoutInflater(savedInstanceState)
            .inflate(R.layout.fragment_web, container, false);
    mFullscreenView = (ViewGroup) view.findViewById(R.id.fullscreen);
    mScrollViewContent = (ViewGroup) view.findViewById(R.id.scroll_view_content);
    mScrollView = (NestedScrollView) view.findViewById(R.id.nested_scroll_view);
    mControls = (ViewSwitcher) view.findViewById(R.id.control_switcher);
    mWebView = (WebView) view.findViewById(R.id.web_view);
    mButtonRefresh = (ImageButton) view.findViewById(R.id.button_refresh);
    mButtonNext = view.findViewById(R.id.button_next);
    mButtonNext.setEnabled(false);
    mEditText = (EditText) view.findViewById(R.id.edittext);
    setUpWebControls(view);
    setUpWebView(view);
    return view;
}
项目:react-native-bottom-sheet-behavior    文件:BackdropBottomSheetBehavior.java   
/**
 * Look into the CoordiantorLayout for the {@link RNBottomSheetBehavior}
 * @param coordinatorLayout with app:layout_behavior= {@link RNBottomSheetBehavior}
 */
private void getBottomSheetBehavior(@NonNull CoordinatorLayout coordinatorLayout) {

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

    if (child instanceof NestedScrollView) {

      try {
        RNBottomSheetBehavior temp = RNBottomSheetBehavior.from(child);
        mBottomSheetBehaviorRef = new WeakReference<>(temp);
        break;
      }
      catch (IllegalArgumentException e){}
    }
  }
}