Skip to main content

Screen: LMFeedCreatePollFragment

LMFeedCreatePollFragment allows users to create polls within the LikeMinds feed system. It provides an interface for adding poll questions, options, and configuring advanced settings like expiration time and anonymous voting.
GitHub Link to LMFeedCreatePollFragment


View Style: LMFeedCreatePollFragmentViewStyle

LMFeedCreatePollFragmentViewStyle defines the visual style and structure of the LMFeedCreatePollFragment. The following fields are available for customization:

Field NameDescriptionType
headerViewStyleStyle for the header of the create poll screen.LMFeedHeaderViewStyle
authorViewStyleDefines the style for the author view.LMFeedPostHeaderViewStyle
pollQuestionTitleViewStyleStyle for the poll question title.LMFeedTextStyle
pollQuestionViewStyleStyle for the poll question input field.LMFeedEditTextStyle
pollOptionsTitleViewStyleStyle for the poll options title.LMFeedTextStyle
pollAddOptionViewStyleStyle for the "add poll option" button.LMFeedTextStyle
pollExpiryTimeTitleViewStyleStyle for the poll expiry time title.LMFeedTextStyle
pollExpiryTimeViewStyleStyle for the poll expiry time selector.LMFeedTextStyle
pollAdvanceOptionViewStyleStyle for advanced options section.LMFeedTextStyle
pollAdvanceOptionSwitchViewStyleStyle for the advanced option toggle switches.LMFeedSwitchStyle
pollOptionsViewStyleStyle for the list of poll options.LMFeedCreatePollOptionViewStyle
pollDropdownViewStyleStyle for dropdown menus in the poll creation screen.LMFeedTextStyle

GitHub Link to LMFeedCreatePollFragmentViewStyle


Customization available in LMFeedCreatePollFragment

Header Customizations

  • customizeCreatePollHeader(headerView: LMFeedHeaderView): Allows customization of the poll creation header.

Author View Customizations

  • customizeAuthorView(authorView: LMFeedPostHeaderView): Customizes the appearance of the author view.

Poll Content Customizations

Advanced Options Customizations

  • customizeAdvancedOptionTitle(tvAdvancedOptions: LMFeedTextView): Customizes the title for advanced options.
  • customizeAdvanceOptionSwitchOptions(switchAnonymousPoll: LMFeedSwitch, switchLiveResults: LMFeedSwitch, switchAddNewOptions: LMFeedSwitch): Customizes the toggle switches for advanced options.

Interactions available in LMFeedCreatePollFragment

  • onNavigationIconClicked(): Handles clicks on the navigation icon.

Poll Option Interactions

  • onAddPollOptionClicked(): Handles adding a new poll option.

Poll Settings Interactions

  • onPollExpiryTimeClicked(): Handles the selection of poll expiry time.
  • onAdvancedSettingsClicked(): Handles clicks on the advanced settings button.

Submission Interactions

  • onPollSubmitClicked(): Handles the submission of the created poll.

Usage Example

In this example, we're customizing the following elememts of the create poll fragment:

  • Header View Appearance: Change the title
  • Click Listeners: Override behavior for poll expiry time clicked

Steps to customize

Step 1: Create CustomCreatePollFragment

Start by extending LMFeedCreatePollFragment and create a custom class, say CustomCreatePollFragment.

class CustomCreatePollFragment : LMFeedCreatePollFragment() {
// We will override methods in the next step
}

Step 2: Override and Customize Methods

You can customize various aspects of the edit post 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 CustomCreatePollFragment : LMFeedCreatePollFragment() {

override fun customizeCreatePollHeader(headerView: LMFeedHeaderView) {
super.customizeCreatePollHeader(headerView)

headerView.setTitleText("Custom Title")
}

override fun onPollExpiryTimeClicked() {
super.onPollExpiryTimeClicked()

// Write your logic
}
}

Step 3: Pass CustomCreatePollFragment for Navigation

You now need to ensure that your fragment is returned wherever the edit post 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 edit post fragment here
LMFeedCore.setCreatePollFragment(CustomCreatePollFragment())