Skip to main content

Screen: LMFeedSearchFragment

The LMFeedSearchFragment provides an interface for searching posts within the LikeMinds feed system. It enables users to search for specific content and interact with the search results, such as liking, saving, or sharing posts.

GitHub Link to LMFeedSearchFragment


View Style: LMFeedSearchFragmentViewStyle

The LMFeedSearchFragmentViewStyle defines the visual style and structure of the fragment. Below are the customizable fields:

Field NameDescriptionType
feedSearchBarViewStyleStyle for the search bar in the feed search screen.LMFeedSearchBarViewStyle
noSearchResultLayoutViewStyleStyle for the "no search results" layout.LMFeedNoEntityLayoutViewStyle
backgroundColorBackground color for the search fragment.Int

GitHub Link to LMFeedSearchFragmentViewStyle


Customization Available in LMFeedSearchFragment

Search Bar and Layout Customizations

  • customizeFeedSearchBarView(searchBarView: LMFeedSearchBarView)
    Customizes the search bar in the feed search fragment.
  • customizeNoSearchResultLayout(layoutNoResult: LMFeedNoEntityLayoutView)
    Customizes the layout shown when no search results are found.
  • customizeSearchListView(rvSearchListView: LMFeedSearchListView)
    Customizes the list view displaying search results.

Interactions Available in LMFeedSearchFragment

Post Content Interactions

  • onPostContentClicked(position: Int, postViewData: LMFeedPostViewData)
    Opens the post content.
  • onPostLikeClicked(position: Int, postViewData: LMFeedPostViewData)
    Likes a post.
  • onPostLikesCountClicked(position: Int, postViewData: LMFeedPostViewData)
    Displays the likes count on a post.
  • onPostCommentsCountClicked(position: Int, postViewData: LMFeedPostViewData)
    Displays the comments count on a post.
  • onPostSaveClicked(position: Int, postViewData: LMFeedPostViewData)
    Saves a post.
  • onPostShareClicked(position: Int, postViewData: LMFeedPostViewData)
    Shares a post.
  • onPostContentLinkClicked(url: String)
    Handles clicks on links within the post content.

Media Interactions

  • onPostImageMediaClicked(position: Int, postViewData: LMFeedPostViewData)
    Opens image media in the post.
  • onPostVideoMediaClicked(position: Int, postViewData: LMFeedPostViewData)
    Opens video media in the post.
  • onPostLinkMediaClicked(position: Int, postViewData: LMFeedPostViewData)
    Opens linked media in the post.

Poll Interactions

  • onPostPollTitleClicked(position: Int, postViewData: LMFeedPostViewData)
    Opens the poll title for details.
  • onPostAddPollOptionClicked(position: Int, postViewData: LMFeedPostViewData)
    Adds a new poll option.
  • onPostSubmitPollVoteClicked(position: Int, postViewData: LMFeedPostViewData)
    Submits a poll vote.
  • onPostEditPollVoteClicked(position: Int, postViewData: LMFeedPostViewData)
    Edits a submitted poll vote.
  • onPostAnswerPromptClicked(position: Int, postViewData: LMFeedPostViewData)
    Interacts with the answer prompt for a post.

Post Management Interactions

  • onPostHeadingClicked(position: Int, postViewData: LMFeedPostViewData)
    Opens the post heading for detailed view.
  • onPostHeadingSeeMoreClicked(position: Int, postViewData: LMFeedPostViewData)
    Expands the full heading content.

Usage Example

In this example, we're customizing the following elements of the search screen:

  • Header View Appearance: Change the title.
  • Click Listeners: Override behavior for like item click.

Steps to customize

Step 1: Create CustomSearchFragment

Start by extending LMFeedSearchFragment and create a custom class, say CustomSearchFragment.

class CustomSearchFragment : LMFeedSearchFragment() {
// We will override methods in the next step
}

Step 2: Override and Customize Methods

You can customize various aspects of the search screen by overriding specific functions.

note

If you're providing your own custom layout or binding, you must override all lifecycle functions, especially:

  • onCreateView
  • onViewCreated
  • onResume
  • onPause
  • onDestroyView
class CustomSearchFragment : LMFeedSearchFragment() {

override fun customizeLikesFragmentHeaderView(headerViewLikes: LMFeedHeaderView) {
super.customizeLikesFragmentHeaderView(headerViewLikes)

headerViewLikes.setTitleText("Custom Title")
}

override fun onUserLikeItemClicked(position: Int, likesViewData: LMFeedLikeViewData) {
super.onUserLikeItemClicked(position, likesViewData)

// Write your logic
}
}

Step 3: Pass CustomSearchFragment for Navigation

You now need to ensure that your fragment is returned wherever the search screen is launched.

val application = this
val theme = LMFeedTheme.SOCIAL_FEED
val enablePushNotifications = false
val deviceId = null
val domain = "ENTER YOUR DOMAIN HERE"
val lmFeedCoreCallback = null

LMFeedCore.setup(
application = application,
theme,
enablePushNotifications = enablePushNotifications,
deviceId = deviceId,
domain = domain,
lmFeedCoreCallback = lmFeedCoreCallback
)

// Set your custom search fragment here
LMFeedCore.setSearchFragment(CustomSearchFragment())