Browse Source

Prevent a crash in the DuplicationWarningDialog

merge-requests/2174/head
Nicolas Pomepuy 1 year ago
parent
commit
dfd00321cd
  1. 9
      application/vlc-android/src/org/videolan/vlc/gui/dialogs/DuplicationWarningDialog.kt

9
application/vlc-android/src/org/videolan/vlc/gui/dialogs/DuplicationWarningDialog.kt

@ -7,6 +7,7 @@ import android.text.SpannableString
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.text.style.StyleSpan
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -92,8 +93,12 @@ class DuplicationWarningDialog : VLCBottomSheetDialogFragment(), View.OnClickLis
val styledText = SpannableString.valueOf(secondaryMessage)
val startIndex = styledText.indexOf(searchTitle)
val endIndex = startIndex + searchTitle.length
styledText.setSpan(StyleSpan(Typeface.BOLD), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
styledText.setSpan(ForegroundColorSpan(MaterialColors.getColor(requireContext(), R.attr.font_default, Color.BLACK)), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
try {
styledText.setSpan(StyleSpan(Typeface.BOLD), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
styledText.setSpan(ForegroundColorSpan(MaterialColors.getColor(requireContext(), R.attr.font_default, Color.BLACK)), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
} catch (e: Exception) {
Log.e("DupWarningDialog", "setupSecondaryText: $e")
}
finalMessage = SpannableString.valueOf(finalMessage.toString() + styledText.toString()+"\n")
}

Loading…
Cancel
Save