Skip to main content

Screen: LMFeedActivityFeedFragment

The LMFeedActivityFeedFragment is a core component of the LikeMinds feed system, responsible for displaying activity feeds within the app. It enables users to view and interact with activity feed items while supporting customization and interaction handling.

GitHub File: LMFeedActivityFeedFragment.kt


View Style: LMFeedActivityFeedFragmentViewStyle

The LMFeedActivityFeedFragmentViewStyle defines the visual style and structure of the LMFeedActivityFeedFragment, including headers, activity views, and layout styling.

GitHub File: LMFeedActivityFeedFragmentViewStyle.kt

FieldDescriptionType
headerViewStyleStyle attributes for the header view.LMFeedHeaderViewStyle
activityViewStyleDefines the style for activity views.LMFeedActivityViewStyle
noActivityLayoutViewStyleStyle for the "No Activity" layout.LMFeedNoEntityLayoutViewStyle
backgroundColorBackground color for the fragment.Int (in format of ColorRes)

Customization Available in LMFeedActivityFeedFragment

The fragment provides the following customization methods:

Header Customizations

  • customizeActivityFeedHeaderView(headerView: LMFeedHeaderView) - Customize the appearance and functionality of the header view in the activity feed.

Activity View Customizations

  • customizeActivityListView(activityListView: LMFeedActivityFeedListView) -Customize the appearance and functionality of the activity view in the activity feed.

Layout Customizations

  • customizeNoTopicsLayout(layoutNoTopics: LMFeedNoEntityLayoutView) - Customize the layout displayed when there are no topics available in the activity feed.

Interactions Available in LMFeedActivityFeedFragment

The fragment supports the following interaction methods:

Item Click Interactions

  • onActivityFeedItemClicked(position: Int, activityFeedItem: LMFeedActivityViewData) Handles click events for individual activity feed items, allowing developers to respond to user interactions.

Usage Example

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

  • Header View Appearance: Change the title.
  • Click Listeners: Override behavior for activity feed item click.
  • Activity Feed View Customizations: Customize the read activity background.

Steps to customize

Step 1: Create CustomActivityFeedFragment

Start by extending LMFeedActivityFeedFragment and create a custom class, say CustomActivityFeedFragment.

class CustomActivityFeedFragment : LMFeedActivityFeedFragment() {
// We will override methods in the next step
}

Step 2: Override and Customize Methods

You can customize various aspects of the activity feed 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 CustomActivityFeedFragment : LMFeedActivityFeedFragment() {

override fun customizeActivityFeedHeaderView(headerViewActivityFeed: LMFeedHeaderView) {
super.customizeActivityFeedHeaderView(headerViewActivityFeed)

headerViewActivityFeed.setTitleText("Custom Title")
}

override fun customizeActivityListView(activityListView: LMFeedActivityFeedListView) {
val activityFragmentViewStyle = LMFeedStyleTransformer.activityFeedFragmentViewStyle
val activityViewStyle = activityFragmentViewStyle.activityViewStyle
val updatedActivityViewStyle = activityViewStyle.toBuilder()
.readActivityBackgroundColor(R.color.lm_feed_black)
.build()
val updatedActivityFragmentViewStyle = activityFragmentViewStyle.toBuilder()
.activityViewStyle(updatedActivityViewStyle)
.build()
LMFeedStyleTransformer.activityFeedFragmentViewStyle = updatedActivityFragmentViewStyle
}

override fun onActivityFeedItemClicked(position: Int, activityViewData: LMFeedActivityViewData) {
super.onActivityFeedItemClicked(position, activityViewData)

// Write your logic
}
}

Step 3: Pass CustomActivityFeedFragment for Navigation

You now need to ensure that your fragment is returned wherever the activity feed 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 activity feed fragment here
LMFeedCore.setActivityFeedFragment(CustomActivityFeedFragment())