You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am going to refine a bit the library with some deprecations and refactoring. Please add a your comment if you are against a modification, explain why you would like to keep it and in which use case you are using it.
Also, you can propose a modification to the existent methods, always explain your reasons and the use case application.
Note: All deprecated methods are going to be removed by the publishing of the final release 5.0.0.
Refactoring
FlexibleAdapter.java
// Just a better nameinitializeListeners(@NullableObjectlistener); toaddListener(@NullableObjectlistener);
// Just a better namegetRelativePosition(@NonNullTchild); togetSubPositionOf(@NonNullTchild);
// Just a better name (dual of the setter)// This method could be completely deprecated, with the new automatic configuration// for sticky headers. The "set" might still have a reason to exists, under evaluation.getStickySectionHeadersHolder(); togetStickyHeaderContainer();
// I decided to not refactor this method anymore: The boolean parameter might// become useful to set value from user configuration at run time.// Normally, we should not call this method to hide headers startup by setting// false, because they already hidden by default!// I will just remove the dependency from the "animation on scrolling".setDisplayHeadersAtStartUp(booleandisplayHeaders);
// Let's remove these 2 wrappers, easier to manage:// usually we have a boolean to check, after the refactoring we can avoid// the if statement and set directly this boolean + custom sticky layout containerenableStickyHeaders(); tosetStickyHeaders(true); + setStickyHeaders(true, ViewGroup);
disableStickyHeaders(); tosetStickyHeaders(false);
AnimatorAdapter.java
// Name is more coherent with the othersbooleanisAnimationOnReverseScrolling(); toisAnimationOnReverseScrollingEnabled();
// Can't be supported anymore due to the new internal condition of non-animationssetAnimationStartPosition(intstart);
// Use of parameter Holder instead of ItemView is more convenient// Anyway, this method is automatically called by FlexibleAdapter only in case// automap is active.finalvoidanimateView(finalViewitemView, intposition);
// tofinalvoidanimateView(finalViewHolderholder, intposition);
SelectableAdapter.java
// It's an utility method, to move in Utils.javastaticintgetSpanCount(RecyclerView.LayoutManagerlayoutManager);
// The call is handled internallypublicvoidresetActionModeFlags(); toprivate
Utils.java
// Deprecate defColor to color? We change the meaning of the parameter.// And so, also Context becomes deprecated. I add also an overloaded method without// color, but you must have the accentColor configured. Practical usages will be:// from highlightText(@NonNullContextcontext, @NonNullTextViewtextView,
StringoriginalText, Stringconstraint, @ColorIntintdefColor);
// tointcolor = fetchAccentColor(Contextcontext, @ColorIntintdefColor);
highlightText(@NonNullTextViewtextView,
StringoriginalText, Stringconstraint, @ColorIntintcolor);
// to 2nd overloaded method with the default accentColorhighlightText(@NonNullTextViewtextView, StringoriginalText, Stringconstraint);
// Use of LayoutManager as parameter is more convenientintgetOrientation(RecyclerViewrecyclerView);
// tointgetOrientation(RecyclerView.LayoutManager)
DrawableUtils.java
// Just a better namesetBackground(Viewview, Drawabledrawable);
setBackground(Viewview, @DrawableResintdrawableRes);
// tosetBackgroundCompat(Viewview, Drawabledrawable);
setBackgroundCompat(Viewview, @DrawableResintdrawableRes);
// Changed name and return valueintgetSelectableBackground(Contextcontext);
// toDrawablegetSelectableItemBackground(Contextcontext);
// Changed return value from (int) resourceId to (int) colorintgetColorControlHighlight(Contextcontext);
// RippleColor becomes the 3rd parameterDrawablegetSelectableBackgroundCompat(@ColorIntintnormalColor,
@ColorIntintpressedColor,
@ColorIntintrippleColor)
// It's now publicColorDrawablegetColorDrawable(@ColorIntintcolor);
Deprecation
FlexibleAdapter.java
// I don't see any useful application intgetItemCountOfTypesUntil(@IntRange(from = 0) intposition, Integer... viewTypes);
// Orphan headers methods series: I don't see any advantages to keep in the adapter,// most of the time the user has the control on the items to remove.booleanisRemoveOrphanHeaders();
FlexibleAdaptersetRemoveOrphanHeaders(booleanremoveOrphanHeaders);
List<IHeader> getOrphanHeaders();
// Private methods (linked to OrphanHeaders methods)voidaddToOrphanListIfNeeded(IHeaderheader, intpositionStart, intitemCount);
voidremoveFromOrphanList(IHeaderheader);
booleanisHeaderShared(IHeaderheader, intpositionStart, intitemCount);
// We simply can use item.setHeader(header) or item.setHeader(null).// Also, it's not obvious that the 2 methods also show or hide header,// we should use add/remove items.FlexibleAdapterlinkHeaderTo(@NonNullTitem, @NonNullIHeaderheader);
IHeaderunlinkHeaderFrom(@NonNullTitem);
// The library doesn't use the concept of "Section index": we don't add sections// using "Section index"intgetSectionIndex(@NonNullIHeaderheader);
intgetSectionIndex(@IntRange(from = 0) intposition);
// This is like a command to expand an expandable, it is unusedintaddAllSubItemsFrom(...)
Support for DiffUtil
// DiffUtil is slower than the internal implementation, it will be released in rc1 with// deprecated status, to be completely removed in the final versionbooleanisAnimateChangesWithDiffUtil();
FlexibleAdaptersetAnimateChangesWithDiffUtil(booleanuseDiffUtil);
FlexibleAdaptersetDiffUtilCallback(DiffUtilCallbackdiffUtilCallback);
synchronizedvoidanimateDiff(@NullableList<T> newItems, PayloadpayloadChange)
publicstaticclassDiffUtilCallback<T> extendsDiffUtil.Callback
FlexibleViewHolder.java
/*-------------------*//* TOUCHABLE METHODS *//*-------------------*/// Because Headers and Footers cannot be draggable, we can't deprecate anymore the touchable// methods in IFlexible, instead, we forbid to override the 2 methods in FlexibleViewHolder// that will be final.// To disallow the touch of a specific item at runtime, users should change the flags in// IFlexible only, those will be taken into account in ItemTouchHelperCallback and ViewHolder.publicbooleanisDraggable(); willbefinalpublicbooleanisSwipeable(); willbefinal
OnUpdateListener
// The "size" now represents ONLY the main items:// Scrollable Headers and Footers are not counted.onUpdateEmptyView(intsize);
EndlessScrollListener
// New callbacksnoMoreLoad(intnewItemsSize);
onLoadMore(intlastPosition, intcurrentPage);
// Already removed!onLoadMore();
The text was updated successfully, but these errors were encountered:
I am going to refine a bit the library with some deprecations and refactoring. Please add a your comment if you are against a modification, explain why you would like to keep it and in which use case you are using it.
Also, you can propose a modification to the existent methods, always explain your reasons and the use case application.
Note: All deprecated methods are going to be removed by the publishing of the final release 5.0.0.
Refactoring
Deprecation
The text was updated successfully, but these errors were encountered: