mirror of https://github.com/tasks/tasks
Add ActionViewHolder for navigation drawer
parent
085dfbb7b4
commit
9b724ad2c5
@ -0,0 +1,41 @@
|
|||||||
|
package com.todoroo.astrid.adapter
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import butterknife.BindView
|
||||||
|
import butterknife.ButterKnife
|
||||||
|
import com.todoroo.astrid.api.FilterListItem
|
||||||
|
import org.tasks.R
|
||||||
|
import org.tasks.themes.DrawableUtil
|
||||||
|
|
||||||
|
class ActionViewHolder internal constructor(
|
||||||
|
private val activity: Activity,
|
||||||
|
itemView: View,
|
||||||
|
private val onClick: ((FilterListItem?) -> Unit)?) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
|
||||||
|
@BindView(R.id.row)
|
||||||
|
lateinit var row: View
|
||||||
|
|
||||||
|
@BindView(R.id.text)
|
||||||
|
lateinit var text: TextView
|
||||||
|
|
||||||
|
@BindView(R.id.icon)
|
||||||
|
lateinit var icon: ImageView
|
||||||
|
|
||||||
|
init {
|
||||||
|
ButterKnife.bind(this, itemView)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bind(filter: FilterListItem) {
|
||||||
|
text.text = filter.listingTitle
|
||||||
|
icon.setImageDrawable(DrawableUtil.getWrapped(activity, filter.icon))
|
||||||
|
if (onClick != null) {
|
||||||
|
row.setOnClickListener {
|
||||||
|
onClick.invoke(filter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/row"
|
||||||
|
android:background="@drawable/drawer_background_selector"
|
||||||
|
android:foreground="?attr/selectableItemBackground"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="12dp"
|
||||||
|
android:paddingBottom="12dp"
|
||||||
|
android:paddingStart="@dimen/keyline_first"
|
||||||
|
android:paddingEnd="0dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:src="@drawable/ic_outline_add_24px"
|
||||||
|
android:tint="@color/text_primary"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:background="@null"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:alpha="@dimen/alpha_secondary"
|
||||||
|
android:scaleType="center"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toEndOf="@id/icon"
|
||||||
|
android:background="@null"
|
||||||
|
android:paddingStart="@dimen/keyline_second"
|
||||||
|
android:paddingEnd="@dimen/keyline_first"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:fontFamily="@string/font_fontFamily_medium"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:lines="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/text_primary"
|
||||||
|
tools:ignore="UnusedAttribute"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
Loading…
Reference in New Issue