Class NewsfeedDetailsAdapter


  • public class NewsfeedDetailsAdapter
    extends com.cheetahdigital.uikit.widget.list.EndlessListAdapter<com.cheetahdigital.corekit.models.data.BaseData,​androidx.recyclerview.widget.RecyclerView.ViewHolder>
    The adapter for NewsfeedDetailsActivity
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.cheetahdigital.uikit.widget.list.EndlessListAdapter

        com.cheetahdigital.uikit.widget.list.EndlessListAdapter.ProgressViewHolder, com.cheetahdigital.uikit.widget.list.EndlessListAdapter.ReloadViewHolder
      • Nested classes/interfaces inherited from class com.cheetahdigital.uikit.widget.list.ListAdapter

        com.cheetahdigital.uikit.widget.list.ListAdapter.EmptyViewHolder
    • Field Summary

      • Fields inherited from class com.cheetahdigital.uikit.widget.list.EndlessListAdapter

        VIEW_TYPE_PROGRESS, VIEW_TYPE_RELOAD
      • Fields inherited from class com.cheetahdigital.uikit.widget.list.ListAdapter

        VIEW_TYPE_HEADER, VIEW_TYPE_NORMAL
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void bindNormalViewHolder​(androidx.recyclerview.widget.RecyclerView.ViewHolder holder, int position)
      Abstract method to bind the normal view holder.
      protected androidx.recyclerview.widget.RecyclerView.ViewHolder createNormalViewHolder​(android.view.ViewGroup parent, int viewType)
      Abstract method to create normal view holder.
      int getItemViewType​(int position)
      Checker if item type is VIEW_TYPE_HEADER or VIEW_TYPE_NORMAL
      void removeComment​(int commentId)
      Removes comment from the list
      void revertCommentChanges​(int commentId)
      Revert changes made in the comment
      void revertPostChanges()
      Revert changes made in the post
      void setFlags​(java.util.List<Flag> flags)
      Set the list of flags displayed when using Flag view in SocialWidget
      void setIsProfileClickable​(boolean isProfileClickable)
      Allows clicking of member avatar/name to show their profile
      void setIsUserAllowedToComment​(boolean isUserAllowedToComment)
      Set the visibility of comment view in SocialWidget
      void setIsUserAllowedToPost​(boolean isUserAllowedToPost)
      Set the visibility of flag view in SocialWidget
      void updateComment​(Comment updatedComment)
      Updates the Comment by calling ListAdapter.replaceItemAt(int, BaseData)
      void updatePost​(Post post)
      Updates Post by calling replaceItemAt position 0.
      • Methods inherited from class com.cheetahdigital.uikit.widget.list.EndlessListAdapter

        getItemCount, getReload, isAppending, onBindViewHolder, onCreateViewHolder, setIsAppending, setReload
      • Methods inherited from class com.cheetahdigital.uikit.widget.list.ListAdapter

        addAll, addItem, addItem, clear, getDataList, getItemAt, getPlaceHolderResource, insertItems, isListEmpty, removeItem, replaceItemAt, setCustomEmptyMessageResource, setPlaceHolderResource, sort
      • Methods inherited from class androidx.recyclerview.widget.RecyclerView.Adapter

        bindViewHolder, createViewHolder, getItemId, hasObservers, hasStableIds, notifyDataSetChanged, notifyItemChanged, notifyItemChanged, notifyItemInserted, notifyItemMoved, notifyItemRangeChanged, notifyItemRangeChanged, notifyItemRangeInserted, notifyItemRangeRemoved, notifyItemRemoved, onAttachedToRecyclerView, onBindViewHolder, onDetachedFromRecyclerView, onFailedToRecycleView, onViewAttachedToWindow, onViewDetachedFromWindow, onViewRecycled, registerAdapterDataObserver, setHasStableIds, unregisterAdapterDataObserver
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NewsfeedDetailsAdapter

        public NewsfeedDetailsAdapter​(@NonNull
                                      java.util.List<com.cheetahdigital.corekit.models.data.BaseData> dataList)
        Constructor of adapter that accepts list of BaseData
        Parameters:
        dataList - list used for this adapter instance
      • NewsfeedDetailsAdapter

        public NewsfeedDetailsAdapter​(@NonNull
                                      java.util.List<com.cheetahdigital.corekit.models.data.BaseData> dataList,
                                      @NonNull
                                      PostDetailsClickListener postClickListener,
                                      @NonNull
                                      CommentClickListener commentClickListener)
        Constructor of the Adapter that accepts list of BaseData and post and comment click listeners
        Parameters:
        dataList - the list of BaseData which includes Post object and list of Comment
        postClickListener - the PostDetailsClickListener for handling clicks on the post
        commentClickListener - the CommentClickListener for handling clicks on the comments
      • NewsfeedDetailsAdapter

        public NewsfeedDetailsAdapter​(@NonNull
                                      java.util.List<com.cheetahdigital.corekit.models.data.BaseData> dataList,
                                      @NonNull
                                      PostDetailsClickListener postClickListener,
                                      @NonNull
                                      CommentClickListener commentClickListener,
                                      @NonNull
                                      OnAttachmentClickListener attachmentClickListener)
        Constructor of the Adapter that accepts list of BaseData and post, comment, and attachment click listeners
        Parameters:
        dataList - the list of BaseData which includes Post object and list of Comment
        postClickListener - the PostDetailsClickListener for handling clicks on the post
        commentClickListener - the CommentClickListener for handling clicks on the comments
        attachmentClickListener - this OnAttachmentClickListener for handling clicks on the attachments (image or video) in a Post
    • Method Detail

      • setIsUserAllowedToComment

        public void setIsUserAllowedToComment​(boolean isUserAllowedToComment)
        Set the visibility of comment view in SocialWidget
        Parameters:
        isUserAllowedToComment - true to show comment, false to hide comment
      • setIsUserAllowedToPost

        public void setIsUserAllowedToPost​(boolean isUserAllowedToPost)
        Set the visibility of flag view in SocialWidget
        Parameters:
        isUserAllowedToPost - true to show flag, false to hide flag
      • setFlags

        public void setFlags​(java.util.List<Flag> flags)
        Set the list of flags displayed when using Flag view in SocialWidget
        Parameters:
        flags - list of flags used for display
      • setIsProfileClickable

        public void setIsProfileClickable​(boolean isProfileClickable)
        Allows clicking of member avatar/name to show their profile
        Parameters:
        isProfileClickable - true - to allow clicking and showing of profile, false - to disable clicking and showing of profile
      • getItemViewType

        public int getItemViewType​(int position)
        Description copied from class: com.cheetahdigital.uikit.widget.list.ListAdapter
        Checker if item type is VIEW_TYPE_HEADER or VIEW_TYPE_NORMAL
        Overrides:
        getItemViewType in class com.cheetahdigital.uikit.widget.list.EndlessListAdapter<com.cheetahdigital.corekit.models.data.BaseData,​androidx.recyclerview.widget.RecyclerView.ViewHolder>
        Parameters:
        position - index of the item
        Returns:
        view type in integer format
      • createNormalViewHolder

        protected androidx.recyclerview.widget.RecyclerView.ViewHolder createNormalViewHolder​(android.view.ViewGroup parent,
                                                                                              int viewType)
        Description copied from class: com.cheetahdigital.uikit.widget.list.ListAdapter
        Abstract method to create normal view holder.
        Specified by:
        createNormalViewHolder in class com.cheetahdigital.uikit.widget.list.ListAdapter<com.cheetahdigital.corekit.models.data.BaseData,​androidx.recyclerview.widget.RecyclerView.ViewHolder>
        Parameters:
        parent - used to get resource
        viewType - type of view
        Returns:
        view holder for non special items
      • bindNormalViewHolder

        protected void bindNormalViewHolder​(androidx.recyclerview.widget.RecyclerView.ViewHolder holder,
                                            int position)
        Description copied from class: com.cheetahdigital.uikit.widget.list.ListAdapter
        Abstract method to bind the normal view holder.
        Specified by:
        bindNormalViewHolder in class com.cheetahdigital.uikit.widget.list.ListAdapter<com.cheetahdigital.corekit.models.data.BaseData,​androidx.recyclerview.widget.RecyclerView.ViewHolder>
        Parameters:
        holder - view holder to vindS
        position - index of the item
      • removeComment

        public void removeComment​(int commentId)
        Removes comment from the list
        Parameters:
        commentId - id of comment
      • revertCommentChanges

        public void revertCommentChanges​(int commentId)
        Revert changes made in the comment
        Parameters:
        commentId - id of comment
      • updateComment

        public void updateComment​(Comment updatedComment)
        Updates the Comment by calling ListAdapter.replaceItemAt(int, BaseData)
        Parameters:
        updatedComment - Updated Comment
      • updatePost

        public void updatePost​(Post post)
        Updates Post by calling replaceItemAt position 0. First item in the list is always Post
        Parameters:
        post - Updated Post
      • revertPostChanges

        public void revertPostChanges()
        Revert changes made in the post