eu.davidea.flexibleadapter.FlexibleAdapter Java Examples
The following examples show how to use
eu.davidea.flexibleadapter.FlexibleAdapter.
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: ExpandableItem.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
ParentViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter); this.mContext = view.getContext(); this.mTitle = view.findViewById(R.id.title); this.mSubtitle = view.findViewById(R.id.subtitle); this.mFlipView = view.findViewById(R.id.image); this.mFlipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAdapter.mItemLongClickListener != null) { mAdapter.mItemLongClickListener.onItemLongClick(getAdapterPosition()); Toast.makeText(mContext, "ImageClick on " + mTitle.getText() + " position " + getAdapterPosition(), Toast.LENGTH_SHORT).show(); toggleActivation(); } } }); this.mHandleView = view.findViewById(R.id.row_handle); setDragHandleView(mHandleView); this.frontView = view.findViewById(R.id.front_view); this.rearLeftView = view.findViewById(R.id.rear_left_view); this.rearRightView = view.findViewById(R.id.rear_right_view); }
Example #2
Source File: FragmentViewPager.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
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); mRecyclerView.setHasFixedSize(true); //Size of RV will not change // 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); }
Example #3
Source File: ScrollableFooterItem.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
FooterViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter); mTitle = view.findViewById(R.id.title); mSubtitle = view.findViewById(R.id.subtitle); mDismissIcon = view.findViewById(R.id.dismiss_icon); mDismissIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Don't need anymore to set permanent deletion for Scrollable Headers and Footers //mAdapter.setPermanentDelete(true); //noinspection unchecked mAdapter.removeScrollableFooter(ScrollableFooterItem.this); //mAdapter.setPermanentDelete(false); } }); // Support for StaggeredGridLayoutManager setFullSpan(true); }
Example #4
Source File: SimpleItem.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
SimpleViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter); this.mContext = view.getContext(); this.mTitle = view.findViewById(R.id.title); this.mSubtitle = view.findViewById(R.id.subtitle); this.mFlipView = view.findViewById(R.id.image); this.mFlipView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAdapter.mItemLongClickListener != null) { mAdapter.mItemLongClickListener.onItemLongClick(getAdapterPosition()); Toast.makeText(mContext, "ImageClick on " + mTitle.getText() + " position " + getAdapterPosition(), Toast.LENGTH_SHORT).show(); toggleActivation(); } } }); this.mHandleView = view.findViewById(R.id.row_handle); setDragHandleView(mHandleView); this.frontView = view.findViewById(R.id.front_view); this.rearLeftView = view.findViewById(R.id.rear_left_view); this.rearRightView = view.findViewById(R.id.rear_right_view); }
Example #5
Source File: InstagramItem.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
@Override public void bindViewHolder(final FlexibleAdapter adapter, ViewHolder holder, int position, List payloads) { Context context = holder.itemView.getContext(); holder.mQuantityLikes.setText(context.getResources().getString(R.string.likes, getLikes())); holder.mImageFavourite.flipSilently(getStarred()); // Load image via Glide RequestOptions options = new RequestOptions() .optionalFitCenter(); Glide.with(context.getApplicationContext()) .asBitmap() .apply(options) .transition(withCrossFade(200)) .load(url) .into(holder.mImage); }
Example #6
Source File: HeaderItem.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
HeaderViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter, true);//True for sticky mTitle = view.findViewById(R.id.title); mSubtitle = view.findViewById(R.id.subtitle); mTitle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d("HeaderTitle", "Registered internal click on Header TitleTextView! " + mTitle.getText() + " position=" + getFlexibleAdapterPosition()); } }); this.mHandleView = view.findViewById(R.id.row_handle); if (adapter.isHandleDragEnabled()) { this.mHandleView.setVisibility(View.VISIBLE); setDragHandleView(mHandleView); } else { this.mHandleView.setVisibility(View.GONE); } // Support for StaggeredGridLayoutManager setFullSpan(true); }
Example #7
Source File: MainActivity.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { if (Utils.hasLollipop()) requestWindowFeature(Window.FEATURE_CONTENT_TRANSITIONS); super.onCreate(savedInstanceState); if (Utils.hasLollipop()) { getWindow().setEnterTransition(new Fade()); } setContentView(R.layout.activity_main); if (BuildConfig.DEBUG) { FlexibleAdapter.enableLogs(Level.VERBOSE); } else { FlexibleAdapter.enableLogs(Level.SUPPRESS); } Log.v("onCreate"); // Initialize Toolbar, Drawer & FAB initializeToolbar(); initializeDrawer(); initializeFab(); // Initialize Fragment containing Adapter & RecyclerView initializeFragment(savedInstanceState); }
Example #8
Source File: ScrollableULSItem.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
ULSViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter); mTitle = view.findViewById(R.id.title); mSubtitle = view.findViewById(R.id.subtitle); mImageView = view.findViewById(R.id.image); mDismissIcon = view.findViewById(R.id.dismiss_icon); mDismissIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatabaseConfiguration.userLearnedSelection = true; //Don't need anymore to set permanent deletion for Scrollable Headers and Footers //mAdapter.setPermanentDelete(true); //noinspection unchecked mAdapter.removeScrollableHeader(ScrollableULSItem.this); //mAdapter.setPermanentDelete(false); } }); // Support for StaggeredGridLayoutManager setFullSpan(true); }
Example #9
Source File: ScrollableUseCaseItem.java From FlexibleAdapter with Apache License 2.0 | 6 votes |
public UCViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter); mTitle = view.findViewById(R.id.title); mSubtitle = view.findViewById(R.id.subtitle); mDismissIcon = view.findViewById(R.id.dismiss_icon); mDismissIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //Don't need anymore to set permanent deletion for Scrollable Headers and Footers //mAdapter.setPermanentDelete(true); //noinspection unchecked, ConstantConditions mAdapter.removeScrollableHeader(mAdapter.getItem(getAdapterPosition())); //mAdapter.setPermanentDelete(false); } }); // Support for StaggeredGridLayoutManager setFullSpan(true); }
Example #10
Source File: ExpandableHeaderItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
ExpandableHeaderViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter, true);//True for sticky mTitle = view.findViewById(R.id.title); mSubtitle = view.findViewById(R.id.subtitle); this.mHandleView = view.findViewById(R.id.row_handle); if (adapter.isHandleDragEnabled()) { this.mHandleView.setVisibility(View.VISIBLE); setDragHandleView(mHandleView); } else { this.mHandleView.setVisibility(View.GONE); } // Support for StaggeredGridLayoutManager setFullSpan(true); }
Example #11
Source File: FragmentDataBinding.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@SuppressWarnings({"ConstantConditions", "NullableProblems"}) private void initializeRecyclerView(Bundle savedInstanceState) { // Initialize Adapter and RecyclerView FlexibleAdapter.useTag("DataBindingAdapter"); mAdapter = new BindingFlexibleAdapter<>(getActivity(), true); mAdapter.setAnimationOnForwardScrolling(DatabaseConfiguration.animateOnForwardScrolling); mRecyclerView = getView().findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(createNewLinearLayoutManager()); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setHasFixedSize(true); //Size of RV will not change // NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if // a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange. mRecyclerView.setItemAnimator(new GarageDoorItemAnimator()); // Add FastScroll to the RecyclerView, after the Adapter has been attached the RecyclerView!!! FastScroller fastScroller = getView().findViewById(R.id.fast_scroller); 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)); mAdapter.setLongPressDragEnabled(true) .setHandleDragEnabled(true) .setSwipeEnabled(true) .setDisplayHeadersAtStartUp(true) .setStickyHeaders(true); SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setEnabled(true); mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE); mAdapter.addScrollableHeaderWithDelay(new ScrollableUseCaseItem( getString(R.string.databinding_use_case_title), getString(R.string.databinding_use_case_description)), 500L, false); }
Example #12
Source File: FragmentStaggeredLayout.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@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("StaggeredLayoutAdapter"); mAdapter = new FlexibleAdapter<>(DatabaseService.getInstance().getDatabaseList(), getActivity()); mRecyclerView = getView().findViewById(R.id.recycler_view); // Customize the speed of the smooth scroll. // NOTE: Every time you change this value you MUST recreate the LayoutManager instance // and to assign it again to the RecyclerView! TopSnappedSmoothScroller.MILLISECONDS_PER_INCH = 33f; //Make faster the smooth scroll mRecyclerView.setLayoutManager(createNewStaggeredGridLayoutManager()); // This value is restored to 100f (default) right here, because it is used in the // constructor by Android. If we don't change it now, others LayoutManager will be // impacted too by the above modification! TopSnappedSmoothScroller.MILLISECONDS_PER_INCH = 100f; mRecyclerView.setAdapter(mAdapter); mRecyclerView.setHasFixedSize(true); //Size of RV will not change // NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if // a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange. mRecyclerView.setItemAnimator(new DefaultItemAnimator()); mRecyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity()) .addItemViewType(R.layout.recycler_staggered_item, 8) .withEdge(true)); mAdapter.setDisplayHeadersAtStartUp(true) //Show Headers at startUp! .setNotifyMoveOfFilteredItems(true) .setPermanentDelete(true) //Default=true .setOnlyEntryAnimation(true); SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setEnabled(true); mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE); // Add 1 Scrollable Header mAdapter.addScrollableHeader(new ScrollableUseCaseItem( getString(R.string.staggered_use_case_title), getString(R.string.staggered_use_case_description))); }
Example #13
Source File: SubItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
public ChildViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter); this.mTitle = view.findViewById(R.id.title); this.mHandleView = view.findViewById(R.id.row_handle); if (adapter.isHandleDragEnabled()) { this.mHandleView.setVisibility(View.VISIBLE); setDragHandleView(mHandleView); } else { this.mHandleView.setVisibility(View.GONE); } }
Example #14
Source File: ExpandableLevel1Item.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override public void bindViewHolder(final FlexibleAdapter adapter, ExpandableItem.ParentViewHolder holder, int position, List payloads) { Context context = holder.itemView.getContext(); setSubtitle(adapter.getCurrentChildren(this).size() + " subItems"); holder.mSubtitle.setText(getSubtitle()); // Background, when bound the first time if (payloads.size() == 0) { holder.mTitle.setText(getTitle()); Drawable drawable = DrawableUtils.getSelectableBackgroundCompat( Color.WHITE, Color.parseColor("#dddddd"), // Same color of divider DrawableUtils.getColorControlHighlight(context)); DrawableUtils.setBackgroundCompat(holder.itemView, drawable); DrawableUtils.setBackgroundCompat(holder.frontView, drawable); } else { Log.d(this.getClass().getSimpleName(), "ExpandableHeaderItem Payload " + payloads); } // ANIMATION EXAMPLE!! ImageView - Handle Flip Animation on Select ALL and Deselect ALL if (adapter.isSelectAll() || adapter.isLastItemInActionMode()) { // Consume the Animation holder.mFlipView.flip(adapter.isSelected(position), 200L); } else { // Display the current flip status holder.mFlipView.flipSilently(adapter.isSelected(position)); } }
Example #15
Source File: StaggeredHeaderItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void bindViewHolder(FlexibleAdapter adapter, HeaderViewHolder holder, int position, List payloads) { if (payloads.size() > 0) { Log.d(this.getClass().getSimpleName(), "StaggeredHeaderItem Payload " + payloads); } else { String title = this.title + " (" + adapter.getSectionItems(this).size() + ")"; holder.title.setText(title); } }
Example #16
Source File: ScrollableULSItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override public void bindViewHolder(FlexibleAdapter adapter, ULSViewHolder holder, int position, List payloads) { Context context = holder.itemView.getContext(); DrawableUtils.setBackgroundCompat(holder.itemView, DrawableUtils.getRippleDrawable( DrawableUtils.getColorDrawable(context.getResources().getColor(R.color.material_color_purple_50)), DrawableUtils.getColorControlHighlight(context)) ); holder.mImageView.setImageResource(R.drawable.ic_account_circle_white_24dp); holder.itemView.setActivated(true); holder.mTitle.setSelected(true);//For marquee!! holder.mTitle.setText(Utils.fromHtmlCompat(getTitle())); holder.mSubtitle.setText(Utils.fromHtmlCompat(getSubtitle())); }
Example #17
Source File: ScrollableUseCaseItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override public void bindViewHolder(FlexibleAdapter adapter, UCViewHolder holder, int position, List payloads) { Context context = holder.itemView.getContext(); DrawableUtils.setBackgroundCompat(holder.itemView, DrawableUtils.getRippleDrawable( DrawableUtils.getColorDrawable(context.getResources().getColor(R.color.material_color_deep_purple_50)), DrawableUtils.getColorControlHighlight(context)) ); holder.mTitle.setText(Utils.fromHtmlCompat(getTitle())); holder.mSubtitle.setText(Utils.fromHtmlCompat(getSubtitle())); holder.setFullSpan(true); }
Example #18
Source File: AnimatorExpandableItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override public void bindViewHolder(FlexibleAdapter adapter, AnimatorExpandableViewHolder holder, int position, List payloads) { if (payloads.size() > 0) { Log.d(this.getClass().getSimpleName(), "AnimatorExpandableItem Payload " + payloads); } else { holder.mTitle.setText(getTitle()); } setSubtitle(String.valueOf(adapter.getCurrentChildren(this).size()) + " subItems (" + (isExpanded() ? "expanded" : "collapsed") + ")"); holder.mSubtitle.setText(getSubtitle()); }
Example #19
Source File: SubItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, ChildViewHolder holder, int position, List<Object> payloads) { //In case of searchText matches with Title or with an SimpleItem's field // this will be highlighted if (adapter.hasFilter()) { Context context = holder.itemView.getContext(); String filter = adapter.getFilter(String.class); FlexibleUtils.highlightText(holder.mTitle, getTitle(), filter, context.getResources().getColor(R.color.colorAccent_light)); } else { holder.mTitle.setText(getTitle()); } }
Example #20
Source File: ViewUtils.java From HgLauncher with GNU General Public License v3.0 | 5 votes |
/** * Launches an app based on RecyclerView scroll state. * * @param activity The activity for context reference. * @param recyclerView The RecyclerView itself. * @param adapter A FlexibleAdapter with App items. */ public static void keyboardLaunchApp(Activity activity, RecyclerView recyclerView, FlexibleAdapter<App> adapter) { if (recyclerView.canScrollVertically(RecyclerView.FOCUS_UP)) { AppUtils.launchApp(activity, Utils.requireNonNull( adapter.getItem(0))); } else if (!recyclerView.canScrollVertically(RecyclerView.FOCUS_DOWN)) { AppUtils.launchApp(activity, Utils.requireNonNull( adapter.getItem(adapter.getItemCount() - 1))); } }
Example #21
Source File: FragmentAnimators.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@SuppressWarnings({"ConstantConditions", "NullableProblems"}) private void initializeRecyclerView(Bundle savedInstanceState) { FlexibleAdapter.useTag("AnimatorsAdapter"); mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity()); mAdapter.expandItemsAtStartUp() .setAutoCollapseOnExpand(false) .setAutoScrollOnExpand(true) .setOnlyEntryAnimation(false) .setAnimationEntryStep(true) //In Overall, watch the effect at initial loading when Grid Layout is set .setAnimationOnForwardScrolling(DatabaseConfiguration.animateOnForwardScrolling) .setAnimationOnReverseScrolling(true) .setAnimationInterpolator(new DecelerateInterpolator()) .setAnimationDuration(300L); mRecyclerView = getView().findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(createNewLinearLayoutManager()); mRecyclerView.setAdapter(mAdapter); //mRecyclerView.setHasFixedSize(true); //Size of RV will not change // NOTE: Custom item animators inherit 'canReuseUpdatedViewHolder()' from Default Item // Animator. It will return true if a Payload is provided. FlexibleAdapter is actually // sending Payloads onItemChange notifications. mRecyclerView.setItemAnimator(new FlexibleItemAnimator()); initializeSpinnerItemAnimators(); initializeSpinnerScrollAnimators(); mAdapter.setSwipeEnabled(true) .getItemTouchHelperCallback() .setSwipeFlags(ItemTouchHelper.RIGHT); //Enable swipe SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setEnabled(false); mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE); // Add 1 Scrollable Header mAdapter.addScrollableHeader(new ScrollableUseCaseItem( getString(R.string.animator_use_case_title), getString(R.string.animator_use_case_description))); }
Example #22
Source File: FragmentHolderSections.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@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("HolderSectionsAdapter"); mAdapter = new ExampleAdapter(DatabaseService.getInstance().getDatabaseList(), getActivity()); mRecyclerView = getView().findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(createNewLinearLayoutManager()); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setHasFixedSize(true); //Size of RV will not change // 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); mAdapter.setDisplayHeadersAtStartUp(true) .setStickyHeaders(true) .setOnlyEntryAnimation(true); SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setEnabled(true); mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE); // Add 1 Scrollable Header mAdapter.addScrollableHeader(new ScrollableUseCaseItem( getString(R.string.model_holders_use_case_title), getString(R.string.model_holders_use_case_description))); }
Example #23
Source File: AnimatorExpandableItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
public AnimatorExpandableViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter, true);//True for sticky mTitle = view.findViewById(R.id.title); mSubtitle = view.findViewById(R.id.subtitle); // Support for StaggeredGridLayoutManager setFullSpan(true); }
Example #24
Source File: FragmentInstagramHeaders.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@SuppressWarnings({"unchecked", "ConstantConditions"}) private void initializeRecyclerView() { // Initialize Adapter and RecyclerView // true = it makes use of stableIds, I strongly suggest to implement 'item.hashCode()' FlexibleAdapter.useTag("InstagramHeadersAdapter"); mAdapter = new FlexibleAdapter<>(null, getActivity(), true); mAdapter.addListener(getActivity()) .setAnimationOnForwardScrolling(true) .setAnimationOnReverseScrolling(true); mRecyclerView = getView().findViewById(R.id.recycler_view); mRecyclerView.setLayoutManager(createNewLinearLayoutManager()); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setHasFixedSize(true); //Size of RV will not change // NOTE: Use default item animator 'canReuseUpdatedViewHolder()' will return true if // a Payload is provided. FlexibleAdapter is actually sending Payloads onItemChange. mRecyclerView.setItemAnimator(new DefaultItemAnimator()); // 24dpi as empty space between sections (each post) mRecyclerView.addItemDecoration(new FlexibleItemDecoration(getActivity()) .withSectionGapOffset(24)); // New empty views handling EmptyViewHelper.create(mAdapter, getView().findViewById(R.id.empty_view)); mAdapter.setDisplayHeadersAtStartUp(true) //Show Headers at startUp! .setStickyHeaders(true) //Make headers sticky // Endless scroll with 1 item threshold .setLoadingMoreAtStartUp(true) .setEndlessScrollListener(this, new ProgressItem()) .setEndlessScrollThreshold(1); //Default=1 SwipeRefreshLayout swipeRefreshLayout = getView().findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout.setEnabled(true); mListener.onFragmentChange(swipeRefreshLayout, mRecyclerView, Mode.IDLE); }
Example #25
Source File: BindingAdapters.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @BindingAdapter(value = "items") public static <T extends IFlexible> void setAdapter(RecyclerView recyclerView, List<T> items) { RecyclerView.Adapter adapter = recyclerView.getAdapter(); if (adapter != null && adapter instanceof FlexibleAdapter) { ((FlexibleAdapter<T>) adapter).updateDataSet(items); } else { throw new IllegalStateException("Binding works only with FlexibleAdapter"); } }
Example #26
Source File: FlexibleItemDecoration.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void applySectionGap(Rect outRect, RecyclerView.Adapter adapter, int position, int orientation) { // Section Gap Offset if (mSectionOffset > 0 && adapter instanceof FlexibleAdapter) { FlexibleAdapter flexibleAdapter = (FlexibleAdapter) adapter; IFlexible nextItem = flexibleAdapter.getItem(position + 1); // IMPORTANT: the check must be done on the BOTTOM of the section, // otherwise the sticky header will jump! if (flexibleAdapter.isHeader(nextItem)) { //Log.v("applySectionGap position=%s", position); if (orientation == RecyclerView.VERTICAL) { outRect.bottom += mSectionOffset; } else { outRect.right += mSectionOffset; } } if (position >= adapter.getItemCount() - mSectionGapOnLastItem) { //Log.v("applySectionGapOnLastPosition position=%s", position); if (orientation == RecyclerView.VERTICAL) { outRect.bottom += mSectionOffset; } else { outRect.right += mSectionOffset; } } } }
Example #27
Source File: ScrollableExpandableItem.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
ScrollableExpandableViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter, true); mTitle = view.findViewById(R.id.title); mSubtitle = view.findViewById(R.id.subtitle); // Support for StaggeredGridLayoutManager setFullSpan(true); }
Example #28
Source File: MainActivity.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override public void onFragmentChange(SwipeRefreshLayout swipeRefreshLayout, RecyclerView recyclerView, int mode) { mRecyclerView = recyclerView; mAdapter = (FlexibleAdapter) recyclerView.getAdapter(); mSwipeRefreshLayout = swipeRefreshLayout; initializeSwipeToRefresh(); initializeActionModeHelper(mode); }
Example #29
Source File: ConfigurationItem.java From FlexibleAdapter with Apache License 2.0 | 4 votes |
@Override public ViewHolder createViewHolder(View view, FlexibleAdapter adapter) { return new ViewHolder(view, adapter); }
Example #30
Source File: AnimatorSubItem.java From FlexibleAdapter with Apache License 2.0 | 4 votes |
ChildViewHolder(View view, FlexibleAdapter adapter) { super(view, adapter); this.mTitle = view.findViewById(R.id.title); }