Skip to content

Commit

Permalink
feat(health-sdk): Code fix for FAQ localization
Browse files Browse the repository at this point in the history
  • Loading branch information
llevente committed Jul 18, 2024
1 parent fcbc4ae commit a4f8715
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ import android.view.ViewGroup
import android.widget.BaseExpandableListAdapter
import net.gini.android.health.sdk.databinding.GhsItemFaqAnswerBinding
import net.gini.android.health.sdk.databinding.GhsItemFaqLabelBinding
import net.gini.android.health.sdk.paymentcomponent.PaymentComponent
import net.gini.android.health.sdk.util.getLayoutInflaterWithGiniHealthThemeAndLocale
import java.util.Locale

/**
* Created by dani on 26/02/2024.
*/

internal class FaqExpandableListAdapter(val dataSet: List<Pair<String, CharSequence>>) : BaseExpandableListAdapter() {
internal class FaqExpandableListAdapter(
val dataSet: List<Pair<String, CharSequence>>,
private val paymentComponent: PaymentComponent?
) : BaseExpandableListAdapter() {
override fun getGroupCount(): Int = dataSet.size
override fun getChildrenCount(listPosition: Int): Int = 1
override fun getGroup(listPosition: Int): Any = dataSet[listPosition].first
Expand All @@ -27,13 +32,13 @@ internal class FaqExpandableListAdapter(val dataSet: List<Pair<String, CharSeque
override fun hasStableIds(): Boolean = true

override fun getGroupView(position: Int, isExpanded: Boolean, p2: View?, parent: ViewGroup): View {
val groupView = GhsItemFaqLabelBinding.inflate(parent.getLayoutInflaterWithGiniHealthThemeAndLocale(), parent, false)
val groupView = GhsItemFaqLabelBinding.inflate(parent.getLayoutInflaterWithGiniHealthThemeAndLocale(Locale("en")), parent, false)
groupView.ghsFaqLabel.text = dataSet[position].first
return groupView.root
}

override fun getChildView(p0: Int, p1: Int, isLastChild: Boolean, convertView: View?, parent: ViewGroup): View {
val groupView = GhsItemFaqAnswerBinding.inflate(parent.getLayoutInflaterWithGiniHealthThemeAndLocale(), parent, false)
val groupView = GhsItemFaqAnswerBinding.inflate(parent.getLayoutInflaterWithGiniHealthThemeAndLocale(Locale("en")), parent, false)
val text = getChild(p0, p1)
if (text is SpannedString) {
groupView.ghsFaqAnswerLabel.movementMethod = LinkMovementMethod.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MoreInformationFragment private constructor(private val paymentComponent:
binding.ghsMoreInformationDetails.movementMethod = LinkMovementMethod.getInstance()
binding.ghsPaymentProvidersIconsList.adapter = PaymentProvidersIconsAdapter(listOf(), paymentComponent)
binding.ghsFaqList.apply {
setAdapter(FaqExpandableListAdapter(faqList))
setAdapter(FaqExpandableListAdapter(faqList, paymentComponent))
setOnGroupClickListener { expandableListView, _, group, _ ->
setListViewHeight(listView = expandableListView, group = group, isReload = false)
return@setOnGroupClickListener false
Expand Down

0 comments on commit a4f8715

Please sign in to comment.