Search in sources :

Example 6 with DefaultItemAnimator

use of androidx.recyclerview.widget.DefaultItemAnimator in project FlexibleAdapter by davideas.

the class FragmentExpandableMultiLevel method initializeRecyclerView.

@SuppressWarnings({ "ConstantConditions", "NullableProblems" })
private void initializeRecyclerView(Bundle savedInstanceState) {
    // Initialize Adapter and RecyclerView
    // ExampleAdapter makes use of stableIds, I strongly suggest to implement 'item.hashCode()'
    FlexibleAdapter.useTag("ExpandableMultiLevelAdapter");
    mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity());
    mAdapter.expandItemsAtStartUp().setNotifyMoveOfFilteredItems(true).setAutoCollapseOnExpand(false).setMinCollapsibleLevel(// Auto-collapse only items with level >= 1 (avoid to collapse also sections!)
    1).setAutoScrollOnExpand(true);
    mRecyclerView = getView().findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(createNewLinearLayoutManager());
    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);
    fastScroller.addOnScrollStateChangeListener((MainActivity) getActivity());
    mAdapter.setFastScroller(fastScroller);
    // New empty views handling, to set after FastScroller
    EmptyViewHelper.create(mAdapter, getView().findViewById(R.id.empty_view), getView().findViewById(R.id.filter_view));
    // Enable long press to drag items
    mAdapter.setLongPressDragEnabled(true).setHandleDragEnabled(// Enable handle drag
    true).setSwipeEnabled(// Enable swipe items
    true);
    // .setDisplayHeadersAtStartUp(true); //Show Headers at startUp: not necessary if Headers are also Expandable!
    mRecyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity()).withSectionGapOffset(24));
    SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout);
    swipeRefreshLayout.setEnabled(true);
    mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE);
    // Add 1 Scrollable Header
    mAdapter.addUserLearnedSelection(savedInstanceState == null);
}
Also used : FlexibleItemDecoration(eu.davidea.flexibleadapter.common.FlexibleItemDecoration) FastScroller(eu.davidea.fastscroller.FastScroller) ExampleAdapter(eu.davidea.samples.flexibleadapter.ExampleAdapter) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Example 7 with DefaultItemAnimator

use of androidx.recyclerview.widget.DefaultItemAnimator in project UltimateRecyclerView by cymcsg.

the class GridLayoutRVTest method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getMainLayout());
    mToolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    listuv = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
    mGridAdapter = new GridJRAdapter(getJRList());
    mGridAdapter.setSpanColumns(columns);
    mGridLayoutManager = new BasicGridLayoutManager(this, columns, mGridAdapter);
    listuv.setLayoutManager(mGridLayoutManager);
    listuv.setHasFixedSize(true);
    listuv.setSaveEnabled(true);
    listuv.setClipToPadding(false);
    // mGridAdapter.setCustomLoadMoreView(LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
    listuv.setNormalHeader(setupHeaderView());
    final Handler f = new Handler();
    listuv.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {

        @Override
        public void loadMore(int itemsCount, int maxLastVisiblePosition) {
            // Log.d(TAG, itemsCount + " :: " + itemsCount);
            f.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mGridAdapter.insert(SampleDataboxset.genJRList(5));
                    afterAdd();
                }
            }, 2000);
        }
    });
    // listuv.enableLoadmore();
    // listuv.disableLoadmore();
    listuv.setLoadMoreView(R.layout.custom_bottom_progressbar);
    listuv.setAdapter(mGridAdapter);
    listuv.setItemAnimator(new DefaultItemAnimator());
    harness_control();
}
Also used : BasicGridLayoutManager(com.marshalchen.ultimaterecyclerview.grid.BasicGridLayoutManager) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) Handler(android.os.Handler) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Example 8 with DefaultItemAnimator

use of androidx.recyclerview.widget.DefaultItemAnimator in project collect by opendatakit.

the class AppListFragment method setupBottomSheet.

private void setupBottomSheet() {
    CollectAbstractActivity activity = (CollectAbstractActivity) getActivity();
    if (activity == null) {
        Timber.e("Activity is null");
        return;
    }
    bottomSheetDialog = new BottomSheetDialog(activity);
    View sheetView = getActivity().getLayoutInflater().inflate(R.layout.bottom_sheet, null);
    final RecyclerView recyclerView = sheetView.findViewById(R.id.recyclerView);
    final SortDialogAdapter adapter = new SortDialogAdapter(getActivity(), recyclerView, sortingOptions, getSelectedSortingOrder(), new RecyclerViewClickListener() {

        @Override
        public void onItemClicked(SortDialogAdapter.ViewHolder holder, int position) {
            holder.updateItemColor(selectedSortingOrder);
            performSelectedSearch(position);
            bottomSheetDialog.dismiss();
        }
    });
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    bottomSheetDialog.setContentView(sheetView);
}
Also used : CollectAbstractActivity(org.odk.collect.android.activities.CollectAbstractActivity) BottomSheetDialog(com.google.android.material.bottomsheet.BottomSheetDialog) SortDialogAdapter(org.odk.collect.android.adapters.SortDialogAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) SearchView(androidx.appcompat.widget.SearchView) ListView(android.widget.ListView) RecyclerViewClickListener(org.odk.collect.android.listeners.RecyclerViewClickListener) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Example 9 with DefaultItemAnimator

use of androidx.recyclerview.widget.DefaultItemAnimator in project collect by opendatakit.

the class AppListActivity method showBottomSheetDialog.

private void showBottomSheetDialog() {
    bottomSheetDialog = new BottomSheetDialog(this);
    final View sheetView = getLayoutInflater().inflate(R.layout.bottom_sheet, null);
    final RecyclerView recyclerView = sheetView.findViewById(R.id.recyclerView);
    final SortDialogAdapter adapter = new SortDialogAdapter(this, recyclerView, sortingOptions, getSelectedSortingOrder(), new RecyclerViewClickListener() {

        @Override
        public void onItemClicked(SortDialogAdapter.ViewHolder holder, int position) {
            holder.updateItemColor(selectedSortingOrder);
            performSelectedSearch(position);
            bottomSheetDialog.dismiss();
        }
    });
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    bottomSheetDialog.setContentView(sheetView);
    bottomSheetDialog.show();
}
Also used : BottomSheetDialog(com.google.android.material.bottomsheet.BottomSheetDialog) SortDialogAdapter(org.odk.collect.android.adapters.SortDialogAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) SearchView(androidx.appcompat.widget.SearchView) ListView(android.widget.ListView) RecyclerViewClickListener(org.odk.collect.android.listeners.RecyclerViewClickListener) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator)

Example 10 with DefaultItemAnimator

use of androidx.recyclerview.widget.DefaultItemAnimator in project collect by opendatakit.

the class AboutActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about_layout);
    DaggerUtils.getComponent(this).inject(this);
    initToolbar();
    int[][] items = { { R.drawable.ic_outline_website_24, R.string.odk_website, R.string.odk_website_summary }, { R.drawable.ic_outline_forum_24, R.string.odk_forum, R.string.odk_forum_summary }, { R.drawable.ic_outline_share_24, R.string.tell_your_friends, R.string.tell_your_friends_msg }, { R.drawable.ic_outline_rate_review_24, R.string.leave_a_review, R.string.leave_a_review_msg }, { R.drawable.ic_outline_stars_24, R.string.all_open_source_licenses, R.string.all_open_source_licenses_msg } };
    RecyclerView recyclerView = findViewById(R.id.recyclerView);
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(new AboutListAdapter(items, this, this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    websiteTabHelper = new ExternalWebPageHelper();
    forumTabHelper = new ExternalWebPageHelper();
    websiteUri = Uri.parse(getString(R.string.app_url));
    forumUri = Uri.parse(getString(R.string.forum_url));
}
Also used : AboutListAdapter(org.odk.collect.android.adapters.AboutListAdapter) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DefaultItemAnimator(androidx.recyclerview.widget.DefaultItemAnimator) ExternalWebPageHelper(org.odk.collect.android.utilities.ExternalWebPageHelper)

Aggregations

DefaultItemAnimator (androidx.recyclerview.widget.DefaultItemAnimator)19 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)8 RecyclerView (androidx.recyclerview.widget.RecyclerView)7 View (android.view.View)6 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)6 FastScroller (eu.davidea.fastscroller.FastScroller)6 FlexibleItemDecoration (eu.davidea.flexibleadapter.common.FlexibleItemDecoration)6 ExampleAdapter (eu.davidea.samples.flexibleadapter.ExampleAdapter)5 ScrollableUseCaseItem (eu.davidea.samples.flexibleadapter.items.ScrollableUseCaseItem)4 SuppressLint (android.annotation.SuppressLint)3 TextView (android.widget.TextView)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 HorizontalScrollView (android.widget.HorizontalScrollView)2 ListView (android.widget.ListView)2 SearchView (androidx.appcompat.widget.SearchView)2 BottomSheetDialog (com.google.android.material.bottomsheet.BottomSheetDialog)2 SortDialogAdapter (org.odk.collect.android.adapters.SortDialogAdapter)2 RecyclerViewClickListener (org.odk.collect.android.listeners.RecyclerViewClickListener)2 ToolbarShadowAnimationHelper (org.thoughtcrime.securesms.components.recyclerview.ToolbarShadowAnimationHelper)2