File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
java/com/example/android/architecture/blueprints/todoapp/tasks Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package com.example.android.architecture.blueprints.todoapp.tasks
17
17
18
+ import android.graphics.Paint
19
+ import android.widget.TextView
18
20
import androidx.databinding.BindingAdapter
19
21
import androidx.recyclerview.widget.RecyclerView
20
22
import com.example.android.architecture.blueprints.todoapp.data.Task
@@ -26,3 +28,12 @@ import com.example.android.architecture.blueprints.todoapp.data.Task
26
28
fun setItems (listView : RecyclerView , items : List <Task >) {
27
29
(listView.adapter as TasksAdapter ).submitList(items)
28
30
}
31
+
32
+ @BindingAdapter(" app:completedTask" )
33
+ fun setStyle (textView : TextView , enabled : Boolean ) {
34
+ if (enabled) {
35
+ textView.paintFlags = textView.paintFlags or Paint .STRIKE_THRU_TEXT_FLAG
36
+ } else {
37
+ textView.paintFlags = textView.paintFlags and Paint .STRIKE_THRU_TEXT_FLAG .inv ()
38
+ }
39
+ }
Original file line number Diff line number Diff line change 13
13
~ See the License for the specific language governing permissions and
14
14
~ limitations under the License.
15
15
-->
16
- <layout xmlns : android =" http://schemas.android.com/apk/res/android" >
16
+ <layout xmlns : android =" http://schemas.android.com/apk/res/android"
17
+ xmlns : app =" http://schemas.android.com/apk/res-auto" >
17
18
18
19
<data >
19
20
31
32
<LinearLayout
32
33
android : layout_width =" match_parent"
33
34
android : layout_height =" ?android:attr/listPreferredItemHeight"
34
- android : background =" @{task.completed ? @drawable/list_completed_touch_feedback : @drawable/touch_feedback}"
35
35
android : orientation =" horizontal"
36
36
android : paddingLeft =" @dimen/activity_horizontal_margin"
37
37
android : paddingRight =" @dimen/activity_horizontal_margin"
53
53
android : layout_height =" wrap_content"
54
54
android : layout_gravity =" center_vertical"
55
55
android : layout_marginLeft =" @dimen/activity_horizontal_margin"
56
+ android : layout_marginStart =" @dimen/activity_horizontal_margin"
56
57
android : textAppearance =" @style/TextAppearance.AppCompat.Title"
57
- android : text =" @{task.titleForList}" />
58
+ android : text =" @{task.titleForList}"
59
+ app : completedTask =" @{task.completed}" />
58
60
</LinearLayout >
59
61
</layout >
You can’t perform that action at this time.
0 commit comments