androidx.recyclerview.widget.LinearSnapHelper Java Examples
The following examples show how to use
androidx.recyclerview.widget.LinearSnapHelper.
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: FavoriteFragment.java From memorize with MIT License | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_favorite, container, false); mRecyclerView = root.findViewById(R.id.fav_recycler_view); mRecyclerView.setHasFixedSize(true); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.setLayoutManager(new LinearLayoutManager(AppMain.getContext(), LinearLayoutManager.VERTICAL, false)); SnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(mRecyclerView); mRecyclerView.setAdapter(mAdapter); swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.fav_swiper); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { presenter.loadWords(false); } }); // animation = AnimationUtils.loadAnimation(AppMain.getContext(), R.anim.card_in); return root; }
Example #2
Source File: LinearSnapMAXActivity.java From DevUtils with Apache License 2.0 | 6 votes |
@Override public void initValues() { super.initValues(); List<ItemBean> lists = new ArrayList<>(); for (int i = 0; i < 10; i++) { lists.add(ItemBean.newItemBean()); } // 初始化布局管理器、适配器 linearSnapAdapter = new LinearSnapMAXAdapter(this, lists); vid_bvr_recy.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)); // vid_bvr_recy.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); vid_bvr_recy.setAdapter(linearSnapAdapter); LinearSnapHelper helper = new LinearSnapHelper(); helper.attachToRecyclerView(vid_bvr_recy); int size = lists.size(); // 滑动到中间 ( 无滑动过程 ) ((LinearLayoutManager) vid_bvr_recy.getLayoutManager()).scrollToPositionWithOffset(size * 100 - 1, 10); // 复位到中间 ListViewUtils.smoothScrollToPosition(vid_bvr_recy, size * 100 + 1); }
Example #3
Source File: LinearSnapActivity.java From DevUtils with Apache License 2.0 | 6 votes |
@Override public void initValues() { super.initValues(); List<ItemBean> lists = new ArrayList<>(); for (int i = 0; i < 10; i++) { lists.add(ItemBean.newItemBean()); } // 初始化布局管理器、适配器 linearSnapAdapter = new LinearSnapAdapter(lists); vid_bvr_recy.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false)); // vid_bvr_recy.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false)); vid_bvr_recy.setAdapter(linearSnapAdapter); LinearSnapHelper helper = new LinearSnapHelper(); helper.attachToRecyclerView(vid_bvr_recy); }
Example #4
Source File: SnapUtil.java From litho with Apache License 2.0 | 6 votes |
@Nullable public static SnapHelper getSnapHelper( @SnapMode int snapMode, int deltaJumpThreshold, int startSnapFlingOffset) { switch (snapMode) { case SNAP_TO_CENTER: return new PagerSnapHelper(); case SNAP_TO_START: return new StartSnapHelper(startSnapFlingOffset); case SNAP_TO_CENTER_CHILD: return new LinearSnapHelper(); case SNAP_TO_CENTER_CHILD_WITH_CUSTOM_SPEED: return new CustomSpeedLinearSnapHelper(deltaJumpThreshold); case SNAP_TO_END: case SNAP_NONE: default: return null; } }
Example #5
Source File: CarouselView.java From CarouselView with MIT License | 5 votes |
public void setCarouselOffset(OffsetType offsetType) { this.offsetType = offsetType; switch (offsetType) { case CENTER: this.snapHelper = new LinearSnapHelper(); break; case START: this.snapHelper = new CarouselSnapHelper(); break; } }
Example #6
Source File: PickerLayoutManager.java From AndroidProject with Apache License 2.0 | 5 votes |
private PickerLayoutManager(Context context, int orientation, boolean reverseLayout, int maxItem, float scale, boolean alpha) { super(context, orientation, reverseLayout); mLinearSnapHelper = new LinearSnapHelper(); mMaxItem = maxItem; mOrientation = orientation; mAlpha = alpha; mScale = scale; }
Example #7
Source File: CarouselTest.java From epoxy with Apache License 2.0 | 5 votes |
@Test public void testOverrideGlobalSnapHelper() { Carousel.setDefaultGlobalSnapHelperFactory(new SnapHelperFactory() { @NonNull @Override public SnapHelper buildSnapHelper(Context context) { return new LinearSnapHelper(); } }); }
Example #8
Source File: DropInActivity.java From braintree-android-drop-in with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.bt_drop_in_activity); mBottomSheet = findViewById(R.id.bt_dropin_bottom_sheet); mLoadingViewSwitcher = findViewById(R.id.bt_loading_view_switcher); mSupportedPaymentMethodsHeader = findViewById(R.id.bt_supported_payment_methods_header); mSupportedPaymentMethodListView = findViewById(R.id.bt_supported_payment_methods); mVaultedPaymentMethodsContainer = findViewById(R.id.bt_vaulted_payment_methods_wrapper); mVaultedPaymentMethodsView = findViewById(R.id.bt_vaulted_payment_methods); mVaultManagerButton = findViewById(R.id.bt_vault_edit_button); mVaultedPaymentMethodsView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)); new LinearSnapHelper().attachToRecyclerView(mVaultedPaymentMethodsView); try { mBraintreeFragment = getBraintreeFragment(); } catch (InvalidArgumentException e) { finish(e); return; } if (savedInstanceState != null) { mSheetSlideUpPerformed = savedInstanceState.getBoolean(EXTRA_SHEET_SLIDE_UP_PERFORMED, false); mDeviceData = savedInstanceState.getString(EXTRA_DEVICE_DATA); } slideUp(); }
Example #9
Source File: CarouselDecorator.java From Hentoid with Apache License 2.0 | 5 votes |
public void decorate(RecyclerView recyclerView) { recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); recyclerView.addOnScrollListener(new CarouselOnScrollListener()); LinearSnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(recyclerView); }
Example #10
Source File: DayPickerView.java From cathode with Apache License 2.0 | 5 votes |
public void init(Context context) { setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); inflate(context, R.layout.day_picker_view, this); recyclerView = (RecyclerView) findViewById(android.R.id.list); layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(mAdapter); SnapHelper snapHelper = new LinearSnapHelper(); snapHelper.attachToRecyclerView(recyclerView); }