From 9f97579f9dc4c928fd8f95449fde3a10b8f77040 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL <46314705+mnaturel@users.noreply.github.com> Date: Fri, 30 Dec 2022 10:07:50 +0100 Subject: [PATCH] Epoxy model for active poll --- .../polls/active/ActivePollItem.kt | 51 +++++++++++++++++++ .../src/main/res/layout/item_poll_active.xml | 42 +++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/roomprofile/polls/active/ActivePollItem.kt create mode 100644 vector/src/main/res/layout/item_poll_active.xml diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/ActivePollItem.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/ActivePollItem.kt new file mode 100644 index 00000000000..2a927653f1b --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/active/ActivePollItem.kt @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.roomprofile.polls.active + +import android.widget.TextView +import com.airbnb.epoxy.EpoxyAttribute +import com.airbnb.epoxy.EpoxyModelClass +import im.vector.app.R +import im.vector.app.core.epoxy.ClickListener +import im.vector.app.core.epoxy.VectorEpoxyHolder +import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.app.core.epoxy.onClick + +@EpoxyModelClass +abstract class ActivePollItem : VectorEpoxyModel(R.layout.item_poll_active) { + + @EpoxyAttribute + lateinit var formattedDate: String + + @EpoxyAttribute + lateinit var title: String + + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var clickListener: ClickListener? = null + + override fun bind(holder: Holder) { + super.bind(holder) + holder.view.onClick(clickListener) + holder.date.text = formattedDate + holder.title.text = title + } + + class Holder : VectorEpoxyHolder() { + val date by bind(R.id.pollActiveDate) + val title by bind(R.id.pollActiveTitle) + } +} diff --git a/vector/src/main/res/layout/item_poll_active.xml b/vector/src/main/res/layout/item_poll_active.xml new file mode 100644 index 00000000000..8cf6c9e5764 --- /dev/null +++ b/vector/src/main/res/layout/item_poll_active.xml @@ -0,0 +1,42 @@ + + + + + + + + + +