Search in sources :

Example 1 with SmoothScrollLinearLayoutManager

use of eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager in project talk-android by nextcloud.

the class CallsListController method prepareViews.

private void prepareViews() {
    SmoothScrollLinearLayoutManager layoutManager = new SmoothScrollLinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), layoutManager.getOrientation()));
    swipeRefreshLayout.setOnRefreshListener(() -> fetchData(false));
    swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
    fastScroller.addOnScrollStateChangeListener(this);
    adapter.setFastScroller(fastScroller);
    fastScroller.setBubbleTextCreator(position -> {
        String displayName = adapter.getItem(position).getModel().getDisplayName();
        if (displayName.length() > 8) {
            displayName = displayName.substring(0, 4) + "...";
        }
        return displayName;
    });
}
Also used : SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration)

Example 2 with SmoothScrollLinearLayoutManager

use of eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager in project talk-android by nextcloud.

the class SwitchAccountController method prepareViews.

private void prepareViews() {
    LinearLayoutManager layoutManager = new SmoothScrollLinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), layoutManager.getOrientation()));
    swipeRefreshLayout.setEnabled(false);
}
Also used : SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration)

Example 3 with SmoothScrollLinearLayoutManager

use of eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager in project talk-android by nextcloud.

the class CallMenuController method prepareViews.

private void prepareViews() {
    LinearLayoutManager layoutManager = new SmoothScrollLinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    prepareMenu();
    if (adapter == null) {
        adapter = new FlexibleAdapter<>(menuItems, getActivity(), false);
    }
    adapter.addListener(this);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), layoutManager.getOrientation()));
}
Also used : SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration)

Example 4 with SmoothScrollLinearLayoutManager

use of eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager in project talk-android by nextcloud.

the class ContactsController method prepareViews.

private void prepareViews() {
    layoutManager = new SmoothScrollLinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), layoutManager.getOrientation()));
    swipeRefreshLayout.setOnRefreshListener(this::fetchData);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
    fastScroller.addOnScrollStateChangeListener(this);
    adapter.setFastScroller(fastScroller);
    fastScroller.setBubbleTextCreator(position -> {
        IFlexible abstractFlexibleItem = adapter.getItem(position);
        if (abstractFlexibleItem instanceof UserItem) {
            return ((UserItem) adapter.getItem(position)).getHeader().getModel();
        } else {
            return ((UserHeaderItem) adapter.getItem(position)).getModel();
        }
    });
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) bottomButtonsLinearLayout.getLayoutParams();
    layoutParams.setBehavior(new ViewHidingBehaviourAnimation());
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) UserHeaderItem(com.nextcloud.talk.adapters.items.UserHeaderItem) ViewHidingBehaviourAnimation(com.nextcloud.talk.utils.animations.ViewHidingBehaviourAnimation) IFlexible(eu.davidea.flexibleadapter.items.IFlexible) SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) UserItem(com.nextcloud.talk.adapters.items.UserItem)

Example 5 with SmoothScrollLinearLayoutManager

use of eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager in project FlexibleAdapter by davideas.

the class FragmentViewPager method initializeRecyclerView.

private void initializeRecyclerView() {
    // Initialize Adapter and RecyclerView
    // Use of stableIds, I strongly suggest to implement 'item.hashCode()'
    FlexibleAdapter.useTag("ViewPagerAdapter");
    mAdapter = new FlexibleAdapter<>(createList(50, 5), getActivity(), true);
    mAdapter.setAnimationOnForwardScrolling(DatabaseConfiguration.animateOnForwardScrolling);
    RecyclerView mRecyclerView = getView().findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new SmoothScrollLinearLayoutManager(getActivity()));
    mRecyclerView.setAdapter(mAdapter);
    // Size of RV will not change
    mRecyclerView.setHasFixedSize(true);
    // NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if
    // a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange.
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    // Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!!
    FastScroller fastScroller = getView().findViewById(R.id.fast_scroller);
    mAdapter.setFastScroller(fastScroller);
    // Sticky Headers
    mAdapter.setDisplayHeadersAtStartUp(true).setStickyHeaders(true);
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) FastScroller(eu.davidea.fastscroller.FastScroller) SmoothScrollLinearLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Aggregations

SmoothScrollLinearLayoutManager (eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager)5 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 UserHeaderItem (com.nextcloud.talk.adapters.items.UserHeaderItem)1 UserItem (com.nextcloud.talk.adapters.items.UserItem)1 ViewHidingBehaviourAnimation (com.nextcloud.talk.utils.animations.ViewHidingBehaviourAnimation)1 FastScroller (eu.davidea.fastscroller.FastScroller)1 IFlexible (eu.davidea.flexibleadapter.items.IFlexible)1