Java Code Examples for androidx.recyclerview.widget.RecyclerView#getItemAnimator()
The following examples show how to use
androidx.recyclerview.widget.RecyclerView#getItemAnimator() .
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: PresetPickerView.java From ColorPickerDialog with Apache License 2.0 | 6 votes |
@Override protected void init() { inflate(getContext(), R.layout.colorpicker_layout_preset_picker, this); adapter = new PresetColorAdapter(DEFAULT_PRESETS).withListener(this); RecyclerView recycler = findViewById(R.id.recycler); recycler.setHasFixedSize(true); RecyclerView.ItemAnimator animator = recycler.getItemAnimator(); if (animator instanceof SimpleItemAnimator) ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); recycler.setLayoutManager(new GridLayoutManager(getContext(), 4)); recycler.setAdapter(adapter); }
Example 2
Source File: MaterialAboutFragment.java From material-about-library with Apache License 2.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.mal_material_about_content, container, false); recyclerView = (RecyclerView) rootView.findViewById(R.id.mal_recyclerview); adapter = new MaterialAboutListAdapter(getViewTypeManager()); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setAdapter(adapter); RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator(); if (animator instanceof SimpleItemAnimator) { ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); } recyclerView.setAlpha(0f); recyclerView.setTranslationY(20); new ListTask(this).execute(); return rootView; }
Example 3
Source File: EpoxyVisibilityTracker.java From epoxy with Apache License 2.0 | 6 votes |
/** * Process a change event. * @param debug: string for debug usually the source of the call * @param checkItemAnimator: true if it need to check if ItemAnimator is running */ private void processChangeEvent(String debug, boolean checkItemAnimator) { final RecyclerView recyclerView = attachedRecyclerView; if (recyclerView != null) { final ItemAnimator itemAnimator = recyclerView.getItemAnimator(); if (checkItemAnimator && itemAnimator != null) { // `itemAnimatorFinishedListener.onAnimationsFinished` will process visibility check // - If the animations are running `onAnimationsFinished` will be invoked on animations end. // - If the animations are not running `onAnimationsFinished` will be invoked right away. if (itemAnimator.isRunning(itemAnimatorFinishedListener)) { // If running process visibility now as `onAnimationsFinished` was not yet called processChangeEventWithDetachedView(null, debug); } } else { processChangeEventWithDetachedView(null, debug); } } }
Example 4
Source File: ScannerActivity.java From Android-nRF-Blinky with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scanner); ButterKnife.bind(this); final MaterialToolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(R.string.app_name); setSupportActionBar(toolbar); // Create view model containing utility methods for scanning scannerViewModel = new ViewModelProvider(this).get(ScannerViewModel.class); scannerViewModel.getScannerState().observe(this, this::startScan); // Configure the recycler view final RecyclerView recyclerView = findViewById(R.id.recycler_view_ble_devices); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL)); final RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator(); if (animator instanceof SimpleItemAnimator) { ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false); } final DevicesAdapter adapter = new DevicesAdapter(this, scannerViewModel.getDevices()); adapter.setOnItemClickListener(this); recyclerView.setAdapter(adapter); }
Example 5
Source File: Utils.java From bottomsheets with Apache License 2.0 | 5 votes |
/** * Disables all the {@link RecyclerView} animations. */ public static void disableAnimations(@NonNull RecyclerView recyclerView) { Preconditions.nonNull(recyclerView); if(recyclerView.getItemAnimator() != null) { recyclerView.setItemAnimator(null); } }
Example 6
Source File: ScannerActivity.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void onCreate(@Nullable final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scanner); ButterKnife.bind(this); // Create view model containing utility methods for scanning mViewModel = new ViewModelProvider(this, mViewModelFactory).get(ScannerViewModel.class); final Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(R.string.title_scanner); setSupportActionBar(toolbar); //noinspection ConstantConditions getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (getIntent() != null) { mScanWithProxyService = getIntent().getBooleanExtra(Utils.EXTRA_DATA_PROVISIONING_SERVICE, true); if (mScanWithProxyService) { getSupportActionBar().setSubtitle(R.string.sub_title_scanning_nodes); } else { getSupportActionBar().setSubtitle(R.string.sub_title_scanning_proxy_node); } } // Configure the recycler view final RecyclerView recyclerViewDevices = findViewById(R.id.recycler_view_ble_devices); recyclerViewDevices.setLayoutManager(new LinearLayoutManager(this)); final DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerViewDevices.getContext(), DividerItemDecoration.VERTICAL); recyclerViewDevices.addItemDecoration(dividerItemDecoration); final SimpleItemAnimator itemAnimator = (SimpleItemAnimator) recyclerViewDevices.getItemAnimator(); if (itemAnimator != null) itemAnimator.setSupportsChangeAnimations(false); final DevicesAdapter adapter = new DevicesAdapter(this, mViewModel.getScannerRepository().getScannerResults()); adapter.setOnItemClickListener(this); recyclerViewDevices.setAdapter(adapter); mViewModel.getScannerRepository().getScannerState().observe(this, this::startScan); }
Example 7
Source File: SwipeOpenItemTouchHelper.java From SwipeOpenItemTouchHelper with Apache License 2.0 | 5 votes |
public long getAnimationDuration(@NonNull RecyclerView recyclerView, int animationType, float animateDx, float animateDy) { final RecyclerView.ItemAnimator itemAnimator = recyclerView.getItemAnimator(); if (itemAnimator == null) { return DEFAULT_SWIPE_ANIMATION_DURATION; } else { return itemAnimator.getMoveDuration(); } }
Example 8
Source File: BoxBrowseFragment.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
protected void initRecyclerView(RecyclerView view){ view.addItemDecoration(new BoxItemDividerDecoration(getResources())); view.addItemDecoration(new FooterDecoration(getResources())); view.setLayoutManager(new LinearLayoutManager(getActivity())); if (view.getItemAnimator() instanceof SimpleItemAnimator) { ((SimpleItemAnimator) view.getItemAnimator()).setSupportsChangeAnimations(false); } }
Example 9
Source File: BoxBrowseFolderGridFragment.java From box-android-browse-sdk with Apache License 2.0 | 5 votes |
protected void initRecyclerView(RecyclerView view){ int numColumns = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) ? 5 : 3; view.setLayoutManager(new GridLayoutManager(getActivity(),numColumns)); view.addItemDecoration(new SpacesItemDecoration(8)); if (view.getItemAnimator() instanceof SimpleItemAnimator) { ((SimpleItemAnimator) view.getItemAnimator()).setSupportsChangeAnimations(false); } }
Example 10
Source File: Utils.java From persistentsearchview with Apache License 2.0 | 4 votes |
/** * Disables the animations of the specified {@link RecyclerView}. * * @param recyclerView The recycler view to disable animations of */ public static void disableRecyclerViewAnimations(RecyclerView recyclerView) { if((recyclerView != null) && (recyclerView.getItemAnimator() != null)) { recyclerView.setItemAnimator(null); } }
Example 11
Source File: WeSwipeHelper.java From monero-wallet-android-app with MIT License | 3 votes |
/** * Called by the WeSwipeHelper when user action finished on a ViewHolder and now the View * will be animated to its final position. * <p> * Default implementation uses ItemAnimator's duration values. If * <code>animationType</code> is {@link #ANIMATION_TYPE_DRAG}, it returns * {@link RecyclerView.ItemAnimator#getMoveDuration()}, otherwise, it returns * {@link RecyclerView.ItemAnimator#getRemoveDuration()}. If RecyclerView does not have * any {@link RecyclerView.ItemAnimator} attached, this method returns * {@code DEFAULT_DRAG_ANIMATION_DURATION} or {@code DEFAULT_SWIPE_ANIMATION_DURATION} * depending on the animation type. * * @param recyclerView The RecyclerView to which the WeSwipeHelper is attached to. * @param animationType The type of animation. Is one of {@link #ANIMATION_TYPE_DRAG}, * {@link #ANIMATION_TYPE_SWIPE_CANCEL} or * {@link #ANIMATION_TYPE_SWIPE_SUCCESS}. * @param animateDx The horizontal distance that the animation will offset * @param animateDy The vertical distance that the animation will offset * @return The duration for the animation */ public long getAnimationDuration(RecyclerView recyclerView, int animationType, float animateDx, float animateDy) { final RecyclerView.ItemAnimator itemAnimator = recyclerView.getItemAnimator(); if (itemAnimator == null) { return animationType == ANIMATION_TYPE_DRAG ? DEFAULT_DRAG_ANIMATION_DURATION : DEFAULT_SWIPE_ANIMATION_DURATION; } else { return animationType == ANIMATION_TYPE_DRAG ? itemAnimator.getMoveDuration() : itemAnimator.getRemoveDuration(); } }
Example 12
Source File: ItemTouchHelperExtension.java From CrazyDaily with Apache License 2.0 | 3 votes |
/** * Called by the ItemTouchHelper when user action finished on a ViewHolder and now the View * will be animated to its final position. * <p> * Default implementation uses ItemAnimator's duration values. If * <code>animationType</code> is {@link #ANIMATION_TYPE_DRAG}, it returns * {@link RecyclerView.ItemAnimator#getMoveDuration()}, otherwise, it returns * {@link RecyclerView.ItemAnimator#getRemoveDuration()}. If RecyclerView does not have * any {@link RecyclerView.ItemAnimator} attached, this method returns * {@code DEFAULT_DRAG_ANIMATION_DURATION} or {@code DEFAULT_SWIPE_ANIMATION_DURATION} * depending on the animation type. * * @param recyclerView The RecyclerView to which the ItemTouchHelper is attached to. * @param animationType The type of animation. Is one of {@link #ANIMATION_TYPE_DRAG}, * {@link #ANIMATION_TYPE_SWIPE_CANCEL} or * {@link #ANIMATION_TYPE_SWIPE_SUCCESS}. * @param animateDx The horizontal distance that the animation will offset * @param animateDy The vertical distance that the animation will offset * @return The duration for the animation */ public long getAnimationDuration(RecyclerView recyclerView, int animationType, float animateDx, float animateDy) { final RecyclerView.ItemAnimator itemAnimator = recyclerView.getItemAnimator(); if (itemAnimator == null) { return animationType == ANIMATION_TYPE_DRAG ? DEFAULT_DRAG_ANIMATION_DURATION : DEFAULT_SWIPE_ANIMATION_DURATION; } else { return animationType == ANIMATION_TYPE_DRAG ? itemAnimator.getMoveDuration() : itemAnimator.getRemoveDuration(); } }
Example 13
Source File: ItemTouchHelper.java From Carbon with Apache License 2.0 | 3 votes |
/** * Called by the ItemTouchHelper when user action finished on a ViewHolder and now the View * will be animated to its final position. * <p> * Default implementation uses ItemAnimator's duration values. If * <code>animationType</code> is {@link #ANIMATION_TYPE_DRAG}, it returns * {@link RecyclerView.ItemAnimator#getMoveDuration()}, otherwise, it returns {@link * RecyclerView.ItemAnimator#getRemoveDuration()}. If RecyclerView does not have any {@link * RecyclerView.ItemAnimator} attached, this method returns {@code * DEFAULT_DRAG_ANIMATION_DURATION} or {@code DEFAULT_SWIPE_ANIMATION_DURATION} depending on * the animation type. * * @param recyclerView The RecyclerView to which the ItemTouchHelper is attached to. * @param animationType The type of animation. Is one of {@link #ANIMATION_TYPE_DRAG}, * {@link #ANIMATION_TYPE_SWIPE_CANCEL} or {@link * #ANIMATION_TYPE_SWIPE_SUCCESS}. * @param animateDx The horizontal distance that the animation will offset * @param animateDy The vertical distance that the animation will offset * @return The duration for the animation */ public long getAnimationDuration(RecyclerView recyclerView, int animationType, float animateDx, float animateDy) { final RecyclerView.ItemAnimator itemAnimator = recyclerView.getItemAnimator(); if (itemAnimator == null) { return animationType == ANIMATION_TYPE_DRAG ? DEFAULT_DRAG_ANIMATION_DURATION : DEFAULT_SWIPE_ANIMATION_DURATION; } else { return animationType == ANIMATION_TYPE_DRAG ? itemAnimator.getMoveDuration() : itemAnimator.getRemoveDuration(); } }