當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearSmoothScroller.SNAP_TO_START屬性代碼示例

本文整理匯總了Java中android.support.v7.widget.LinearSmoothScroller.SNAP_TO_START屬性的典型用法代碼示例。如果您正苦於以下問題:Java LinearSmoothScroller.SNAP_TO_START屬性的具體用法?Java LinearSmoothScroller.SNAP_TO_START怎麽用?Java LinearSmoothScroller.SNAP_TO_START使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.support.v7.widget.LinearSmoothScroller的用法示例。


在下文中一共展示了LinearSmoothScroller.SNAP_TO_START屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onMarkerClick

@Override
public boolean onMarkerClick(Marker marker) {
    if (marker.getTag() instanceof BusRouteStop) {
        BusRouteStop stop = (BusRouteStop) marker.getTag();
        if (stop != null) {
            if (recyclerView != null) {
                RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(getContext()) {
                    @Override protected int getVerticalSnapPreference() {
                        return LinearSmoothScroller.SNAP_TO_START;
                    }
                };
                smoothScroller.setTargetPosition(Integer.parseInt(stop.sequence));
                recyclerView.getLayoutManager().startSmoothScroll(smoothScroller);
            }
            map.animateCamera(CameraUpdateFactory.newLatLngZoom(
                    new LatLng(Double.parseDouble(stop.latitude), Double.parseDouble(stop.longitude)), 16));
            Intent intent = new Intent(getContext(), EtaService.class);
            intent.putExtra(C.EXTRA.STOP_OBJECT, stop);
            getContext().startService(intent);
        }
    }
    return true;
}
 
開發者ID:alvinhkh,項目名稱:buseta,代碼行數:23,代碼來源:LwbStopListFragment.java

示例2: onCreateView

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_read, container, false);
    RecyclerView mRecyclerView = view.findViewById(R.id.versesRecyclerView);
    mAdapter = new VersesAdapter();
    mLayoutManager = mRecyclerView.getLayoutManager();
    mRecyclerView.setAdapter(mAdapter);

    //preload the versions
    //new DBTRetriever().getBooks(getContext());
    //new DBTRetriever().getVersions(getContext());

    Activity activity = getActivity();
    if (activity == null) {
        return view;
    }

    mSmoothScroller = new LinearSmoothScroller(activity) {
        @Override protected int getVerticalSnapPreference() {
            return LinearSmoothScroller.SNAP_TO_START;
        }
    };

    mBookChapterView = activity.findViewById(R.id.selected_book);
    mTranslationView = activity.findViewById(R.id.selected_translation);

    setAppBarDisplay();

    return view;
}
 
開發者ID:barnhill,項目名稱:SimpleBible,代碼行數:31,代碼來源:ReadFragment.java

示例3: smoothScrollToPosition

public void smoothScrollToPosition(int position, final ScrollOptions options) {
    final RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(this.getContext()) {
        @Override
        protected int getVerticalSnapPreference() {
            return LinearSmoothScroller.SNAP_TO_START;
        }

        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            return ((LinearLayoutManager) this.getLayoutManager()).computeScrollVectorForPosition(targetPosition);
        }

        @Override
        protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
            if (options.millisecondsPerInch != null) {
                return options.millisecondsPerInch / displayMetrics.densityDpi;
            } else {
                return super.calculateSpeedPerPixel(displayMetrics);
            }
        }

        @Override
        public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference) {
            int calc = super.calculateDtToFit(viewStart, viewEnd, boxStart, boxEnd, snapPreference);
            if (options.viewPosition != null) {
                int viewHeight = viewEnd - viewStart;
                int boxHeight = boxEnd - boxStart;
                float viewOffset = options.viewOffset != null ? PixelUtil.toPixelFromDIP(options.viewOffset) : 0;
                float target = boxStart + (boxHeight - viewHeight) * options.viewPosition + viewOffset;
                return (int) (target - viewStart);
            } else {
                return super.calculateDtToFit(viewStart, viewEnd, boxStart, boxEnd, snapPreference);
            }
        }
    };

    smoothScroller.setTargetPosition(position);
    this.getLayoutManager().startSmoothScroll(smoothScroller);
}
 
開發者ID:godness84,項目名稱:react-native-recyclerview-list,代碼行數:39,代碼來源:RecyclerViewBackedScrollView.java

示例4: smoothScrollToPosition

@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, final int position) {

    LinearSmoothScroller smoothScroller = new LinearSmoothScroller(mContext) {

        //This controls the direction in which smoothScroll looks
        //for your view
        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            return CustomLayoutManager.this.computeScrollVectorForPosition(targetPosition);
        }

        @Override
        protected int getVerticalSnapPreference() {
            return LinearSmoothScroller.SNAP_TO_START;
        }

        //This returns the milliseconds it takes to
        //scroll one pixel.
        @Override
        protected float calculateSpeedPerPixel
        (DisplayMetrics displayMetrics) {
            return MILLISECONDS_PER_INCH / displayMetrics.densityDpi;
        }
    };

    smoothScroller.setTargetPosition(position);
    startSmoothScroll(smoothScroller);
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:29,代碼來源:CustomLayoutManager.java

示例5: smoothScrollToPosition

@Override
public void smoothScrollToPosition(RecyclerView recyclerView, State state, int position) {
    final LinearSmoothScroller scroller = new LinearSmoothScroller(recyclerView.getContext()) {
        @Override
        public PointF computeScrollVectorForPosition(int targetPosition) {
            if (getChildCount() == 0) {
                return null;
            }

            final int direction = targetPosition < getFirstVisiblePosition() ? -1 : 1;
            if (mIsVertical) {
                return new PointF(0, direction);
            } else {
                return new PointF(direction, 0);
            }
        }

        @Override
        protected int getVerticalSnapPreference() {
            return LinearSmoothScroller.SNAP_TO_START;
        }

        @Override
        protected int getHorizontalSnapPreference() {
            return LinearSmoothScroller.SNAP_TO_START;
        }
    };

    scroller.setTargetPosition(position);
    startSmoothScroll(scroller);
}
 
開發者ID:lucastanziano,項目名稱:Blockbuster,代碼行數:31,代碼來源:TwoWayLayoutManager.java

示例6: scrollToPosition

public void scrollToPosition(int position) {
    RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(getActivity()) {
        @Override protected int getVerticalSnapPreference() {
            return LinearSmoothScroller.SNAP_TO_START;
        }
    };
    smoothScroller.setTargetPosition(position);
    nodeListView.getLayoutManager().startSmoothScroll(smoothScroller);
}
 
開發者ID:openforis,項目名稱:collect-mobile,代碼行數:9,代碼來源:SimpleNodeListFragment.java

示例7: SnappingLinearLayoutManager

public SnappingLinearLayoutManager(Context context) {
    this(context, LinearSmoothScroller.SNAP_TO_START);
}
 
開發者ID:kingwang666,項目名稱:BaseAdapterNoDataBinding,代碼行數:3,代碼來源:SnappingLinearLayoutManager.java


注:本文中的android.support.v7.widget.LinearSmoothScroller.SNAP_TO_START屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。