Screen: LMFeedQnAFeedFragment
The LMFeedQnAFeedFragment
displays a Q&A feed within the LikeMinds feed system. It allows users to interact with posts, view top responses, and participate in discussions. Key features include creating new posts, filtering topics, and exploring detailed post content.
GitHub Link to LMFeedQnAFeedFragment
View Style: LMFeedQnAFeedFragmentViewStyle
The LMFeedQnAFeedFragmentViewStyle
defines the visual style and layout of the fragment. Below are the customizable fields:
Field Name | Description | Type |
---|---|---|
headerViewStyle | Style for the header of the Q&A feed screen. | LMFeedHeaderViewStyle |
createNewPostButtonViewStyle | Style for the "Create New Post" button. | LMFeedButtonViewStyle |
noPostLayoutViewStyle | Style for the "no posts available" layout. | LMFeedNoEntityLayoutViewStyle |
postingViewStyle | Style for the "posting in progress" layout. | LMFeedPostingViewStyle |
topicSelectorBarStyle | Style for the topic selector bar. | LMFeedTopicSelectorBarViewStyle |
GitHub Link to LMFeedQnAFeedFragmentViewStyle
Customization Available in LMFeedQnAFeedFragment
Header and Button Customizations
- customizeCreateNewPostButton(fabNewPost: LMFeedFAB)
Customizes the "Create New Post" button. - customizeQnAFeedHeaderView(headerViewQnA: LMFeedHeaderView)
Customizes the header of the Q&A feed.
Post Customizations
- customizePostHeaderView()
Customizes the header for individual posts. - customizePostContentView()
Customizes the content view for posts. - customizePostHeadingView()
Customizes the heading view for posts. - customizePostTopResponseView()
Customizes the top response section in posts. - customizePostActionView()
Customizes the action bar (likes, comments, shares). - customizePostAnswerPrompt()
Customizes the answer prompt for Q&A posts.
Layout Customizations
- customizeNoPostLayout(layoutNoPost: LMFeedNoEntityLayoutView)
Customizes the layout shown when no posts are available. - customizePostingLayout(layoutPosting: LMFeedPostingView)
Customizes the layout shown during posting. - customizeTopicSelectorBar(topicSelectorBar: LMFeedTopicSelectorBarView)
Customizes the topic selector bar.
Interactions Available in LMFeedQnAFeedFragment
General Interactions
- onRetryUploadClicked(temporaryId: Long?, attachmentCount: Int)
Retry a failed post upload. - onUserProfileClicked(userViewData: LMFeedUserViewData)
Open a user's profile. - onNotificationIconClicked()
Open notifications. - onSearchIconClicked()
Open the search interface. - onAllTopicsClicked()
Display all available topics.
Post Interactions
- onPostContentClicked(position: Int, postViewData: LMFeedPostViewData)
Open a post's content. - onPostLikeClicked(position: Int, postViewData: LMFeedPostViewData)
Like a post. - onPostLikesCountClicked(position: Int, postViewData: LMFeedPostViewData)
Show the likes count for a post. - onPostCommentsCountClicked(position: Int, postViewData: LMFeedPostViewData)
Show the comments count for a post. - onPostSaveClicked(position: Int, postViewData: LMFeedPostViewData)
Save a post. - onPostShareClicked(position: Int, postViewData: LMFeedPostViewData)
Share a post. - onPostContentSeeMoreClicked(position: Int, postViewData: LMFeedPostViewData)
Expand the post's content. - onPostContentLinkClicked(url: String)
Handles clicks on links within the post content.
Media Interactions
- onPostImageMediaClicked(position: Int, postViewData: LMFeedPostViewData)
View image media. - onPostVideoMediaClicked(position: Int, postViewData: LMFeedPostViewData)
View video media. - onPostLinkMediaClicked(position: Int, postViewData: LMFeedPostViewData)
View linked media.
Poll Interactions
- onPostPollTitleClicked(position: Int, postViewData: LMFeedPostViewData)
Open poll details. - onPostAddPollOptionClicked(position: Int, postViewData: LMFeedPostViewData)
Add a new poll option. - onPostMemberVotedCountClicked(position: Int, postViewData: LMFeedPostViewData)
Show members who voted. - onPostSubmitPollVoteClicked(position: Int, postViewData: LMFeedPostViewData)
Submit a poll vote. - onPostEditPollVoteClicked(position: Int, postViewData: LMFeedPostViewData)
Edit a submitted poll vote.
Top Response Interactions
- onPostTopResponseClicked(position: Int, postViewData: LMFeedPostViewData)
Open the top response for a post. - onPostTopResponseSeeMoreClicked(position: Int, postViewData: LMFeedPostViewData)
Expand the top response content. - onPostTopResponseTaggedMemberClicked(position: Int, uuid: String)
Handle clicks on tagged members in the top response. - onPostTopResponseContentClicked(position: Int, postViewData: LMFeedPostViewData)
Open the full content of the top response.
Additional Interactions
- onPostAuthorHeaderClicked(position: Int, postViewData: LMFeedPostViewData)
Open the post author's profile. - onPostHeadingClicked(position: Int, postViewData: LMFeedPostViewData)
Interact with the post heading. - onPostHeadingSeeMoreClicked(position: Int, postViewData: LMFeedPostViewData)
Expand the post heading content. - onPostAnswerPromptClicked(position: Int, postViewData: LMFeedPostViewData)
Interact with the answer prompt for a post.
Usage Example
In this example, we're customizing the following elements of the QnA Feed screen:
- Header View Appearance: Change the title.
- Click Listeners: Override behavior for create post button click.
Steps to customize
Step 1: Create CustomQnAFeedFragment
Start by extending LMFeedQnAFeedFragment
and create a custom class, say CustomQnAFeedFragment
.
class CustomQnAFeedFragment : LMFeedQnAFeedFragment() {
// We will override methods in the next step
}
Step 2: Override and Customize Methods
You can customize various aspects of the QnA feed screen by overriding specific functions.
If you're providing your own custom layout or binding, you must override all lifecycle functions, especially:
onCreateView
onViewCreated
onResume
onPause
onDestroyView
class CustomQnAFeedFragment : LMFeedQnAFeedFragment() {
override fun customizeQnAFeedHeaderView(headerViewQna: LMFeedHeaderView) {
super.customizeQnAFeedHeaderView(headerViewQna)
headerViewQna.setTitleText("Custom Title")
}
override fun onCreateNewPostClick(hasCreatePostRights: Boolean) {
super.onCreateNewPostClick(hasCreatePostRights)
// Write your logic
}
}
Step 3: Use CustomQnAFeedFragment
You can now use the custom fragment to start QnA Feed Fragment as explained in Getting Started.