mirror of https://github.com/tasks/tasks
Convert filter list to recycler view
parent
f3f3b1d8dc
commit
d33fb285c6
@ -0,0 +1,70 @@
|
||||
package com.todoroo.astrid.core
|
||||
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import butterknife.BindView
|
||||
import butterknife.ButterKnife
|
||||
import butterknife.OnClick
|
||||
import org.tasks.Callback
|
||||
import org.tasks.R
|
||||
import org.tasks.locale.Locale
|
||||
|
||||
class CriterionViewHolder(itemView: View, private val locale: Locale, private val onClick: Callback<CriterionInstance>) : RecyclerView.ViewHolder(itemView) {
|
||||
|
||||
@BindView(R.id.divider)
|
||||
lateinit var divider: View
|
||||
|
||||
@BindView(R.id.icon)
|
||||
lateinit var icon: ImageView
|
||||
|
||||
@BindView(R.id.name)
|
||||
lateinit var name: TextView
|
||||
|
||||
@BindView(R.id.filter_count)
|
||||
lateinit var filterCount: TextView
|
||||
|
||||
@BindView(R.id.row)
|
||||
lateinit var row: View
|
||||
|
||||
private lateinit var criterion: CriterionInstance
|
||||
|
||||
init {
|
||||
ButterKnife.bind(this, itemView)
|
||||
}
|
||||
|
||||
fun bind(criterion: CriterionInstance) {
|
||||
this.criterion = criterion
|
||||
val title: String = criterion.titleFromCriterion
|
||||
|
||||
icon.visibility = if (criterion.type == CriterionInstance.TYPE_UNIVERSE) {
|
||||
View.INVISIBLE
|
||||
} else {
|
||||
View.VISIBLE
|
||||
}
|
||||
|
||||
when (criterion.type) {
|
||||
CriterionInstance.TYPE_ADD -> {
|
||||
icon.setImageResource(R.drawable.ic_call_split_24px)
|
||||
divider.visibility = View.VISIBLE
|
||||
}
|
||||
CriterionInstance.TYPE_SUBTRACT -> {
|
||||
icon.setImageResource(R.drawable.ic_outline_not_interested_24px)
|
||||
divider.visibility = View.GONE
|
||||
}
|
||||
CriterionInstance.TYPE_INTERSECT -> {
|
||||
icon.setImageResource(R.drawable.ic_outline_add_24px)
|
||||
divider.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
name.text = title
|
||||
filterCount.text = locale.formatNumber(criterion.end)
|
||||
|
||||
row.isClickable = criterion.type != CriterionInstance.TYPE_UNIVERSE
|
||||
}
|
||||
|
||||
@OnClick(R.id.row)
|
||||
fun onClick() = this.onClick.call(criterion)
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 646 B |
Binary file not shown.
Before Width: | Height: | Size: 407 B |
Binary file not shown.
Before Width: | Height: | Size: 687 B |
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M14,4l2.29,2.29 -2.88,2.88 1.42,1.42 2.88,-2.88L20,10L20,4h-6zM10,4L4,4v6l2.29,-2.29 4.71,4.7L11,20h2v-8.41l-5.29,-5.3L10,4z"/>
|
||||
</vector>
|
@ -1,64 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
** Copyright (c) 2012 Todoroo Inc
|
||||
**
|
||||
** See the file "LICENSE" for the full license governing this code.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/row"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="55dip"
|
||||
android:paddingStart="4dip"
|
||||
android:paddingEnd="6dip"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/filter_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:gravity="center_vertical|end"/>
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
style="@style/horizontal_divider"
|
||||
android:visibility="gone"
|
||||
android:layout_alignParentTop="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_toStartOf="@id/filter_count"
|
||||
android:gravity="center_vertical|start"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<!-- filter intersection type icon -->
|
||||
<ImageView
|
||||
android:id="@+id/type"
|
||||
android:layout_width="32dip"
|
||||
<TextView
|
||||
android:id="@+id/filter_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:scaleType="center"/>
|
||||
android:layout_alignParentEnd="true"
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:gravity="center_vertical|end" />
|
||||
|
||||
<!-- filter icon -->
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="32dip"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:visibility="gone"/>
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:tint="@color/icon_tint_with_alpha"
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:src="@drawable/ic_outline_add_24px"
|
||||
android:scaleType="center" />
|
||||
|
||||
<!-- filter text -->
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
style="@style/TextAppearance"
|
||||
android:layout_toEndOf="@id/icon"
|
||||
android:layout_toStartOf="@id/filter_count"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:paddingStart="@dimen/keyline_first"
|
||||
android:paddingEnd="@dimen/keyline_first"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textAlignment="viewStart"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
android:textSize="18sp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||
android:id="@+id/button_toggle"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/keyline_first"
|
||||
android:orientation="horizontal"
|
||||
app:selectionRequired="true"
|
||||
app:singleSelection="true">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_and"
|
||||
style="@style/OutlineButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/custom_filter_and" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_or"
|
||||
style="@style/OutlineButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/custom_filter_or" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/button_not"
|
||||
style="@style/OutlineButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/custom_filter_not" />
|
||||
|
||||
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reconfigure"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TagSettingsRow"
|
||||
android:text="@string/choose_new_criteria" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/delete"
|
||||
style="@style/TagSettingsRow"
|
||||
android:text="@string/delete" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue