Skip to content

Instantly share code, notes, and snippets.

@cbedoy
Created May 20, 2021 22:44
Show Gist options
  • Save cbedoy/43866108220462fb277d4d72173bbb81 to your computer and use it in GitHub Desktop.
Save cbedoy/43866108220462fb277d4d72173bbb81 to your computer and use it in GitHub Desktop.
MessageRepresentationDialog
@Parcelize
data class MessageRepresentation(
val title : String = "",
val description: String = "",
val boldDescriptionComponents: List<String> = emptyList(),
val backgroundResource: Int = 0,
val imageResource: Int = 0,
val progressBar: MessageRepresentationProgress = MessageRepresentationProgress(),
.....
) : Parcelable
@Parcelize
data class MessageRepresentationProgress(
val hasProgressBar: Boolean = false,
val progressBarState: Int = 0,
): Parcelable
@Parcelize
data class MessageRepresentationAction(
val title: String = ""
): Parcelable
@Parcelize
data class MessageRepresentationGridItems(
val showGrid: Boolean = false,
val leftTitle: String = "",
val leftDescription: String = "",
val rightTitle: String = "",
val rightDescription: String = ""
): Parcelable
@Parcelize
data class MessageRepresentationTankGridItems(
val showGrid: Boolean = false,
val leftDescription: String = "",
val rightDescription: String = ""
): Parcelable
@Parcelize
data class MessageRepresentationCoupon(
val codeName: String = ""
): Parcelable
class MessageRepresentationDialog : BaseDialog(), KoinComponent {
private val typefaceUtil by inject<TypefaceUtil>()
companion object {
fun newInstance(
messageRepresentation: MessageRepresentation
): MessageRepresentationDialog {
return MessageRepresentationDialog().apply {
arguments = Bundle().apply {
putParcelable(DIALOG_MESSAGE_REPRESENTATION, messageRepresentation)
}
}
}
private const val DIALOG_MESSAGE_REPRESENTATION = "message-representation"
}
var listener: Listener? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
arguments?.let {
it.getParcelable<MessageRepresentation>(DIALOG_MESSAGE_REPRESENTATION)?.let { representation ->
with(representation){
dialogImage.setImageResource(imageResource)
dialogImageBackground.setBackgroundResource(backgroundResource)
dialogTitle.text = representation.title
val descriptionText = SpannableString(representation.description)
.....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment