Skip to content

Commit ab1e1a2

Browse files
committed
address more PR comments
1 parent 35b88ac commit ab1e1a2

File tree

4 files changed

+36
-38
lines changed

4 files changed

+36
-38
lines changed

examples/todos/android/src/main/java/org/reduxkotlin/example/todos/MainActivity.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package org.reduxkotlin.example.todos
22

33
import android.os.Bundle
44
import androidx.appcompat.app.AppCompatActivity
5-
import androidx.recyclerview.widget.LinearLayoutManager
65
import kotlinx.android.synthetic.main.activity_main.*
76
import org.reduxkotlin.StoreSubscription
87
import org.reduxkotlin.createStore
@@ -24,16 +23,16 @@ class MainActivity: AppCompatActivity() {
2423
super.onCreate(savedInstanceState)
2524
setContentView(R.layout.activity_main)
2625
storeSubscription = store.subscribe { render(store.state) }
27-
btn_add_todo.setOnClickListener {
28-
val todoText = et_todo.text.toString()
29-
et_todo.text.clear()
26+
btnAddTodo.setOnClickListener {
27+
val todoText = etTodo.text.toString()
28+
etTodo.text.clear()
3029
store.dispatch(AddTodo(todoText))
3130
}
32-
btn_select_all.setOnClickListener { store.dispatch(SetVisibilityFilter(VisibilityFilter.SHOW_ALL)) }
33-
btn_active.setOnClickListener { store.dispatch(SetVisibilityFilter(VisibilityFilter.SHOW_ACTIVE)) }
34-
btn_completed.setOnClickListener { store.dispatch(SetVisibilityFilter(VisibilityFilter.SHOW_COMPLETED)) }
31+
btnSelectAll.setOnClickListener { store.dispatch(SetVisibilityFilter(VisibilityFilter.SHOW_ALL)) }
32+
btnActive.setOnClickListener { store.dispatch(SetVisibilityFilter(VisibilityFilter.SHOW_ACTIVE)) }
33+
btnCompleted.setOnClickListener { store.dispatch(SetVisibilityFilter(VisibilityFilter.SHOW_COMPLETED)) }
3534

36-
recycler_view.adapter = adapter
35+
recyclerView.adapter = adapter
3736

3837
render(store.state)
3938
}
@@ -46,19 +45,19 @@ class MainActivity: AppCompatActivity() {
4645
private fun setFilterButtons(visibilityFilter: VisibilityFilter) =
4746
when (visibilityFilter) {
4847
VisibilityFilter.SHOW_ALL -> {
49-
btn_select_all.isSelected = true
50-
btn_active.isSelected = false
51-
btn_completed.isSelected = false
48+
btnSelectAll.isSelected = true
49+
btnActive.isSelected = false
50+
btnCompleted.isSelected = false
5251
}
5352
VisibilityFilter.SHOW_ACTIVE -> {
54-
btn_active.isSelected = true
55-
btn_select_all.isSelected = false
56-
btn_completed.isSelected = false
53+
btnActive.isSelected = true
54+
btnSelectAll.isSelected = false
55+
btnCompleted.isSelected = false
5756
}
5857
VisibilityFilter.SHOW_COMPLETED -> {
59-
btn_completed.isSelected = true
60-
btn_select_all.isSelected = false
61-
btn_active.isSelected = false
58+
btnCompleted.isSelected = true
59+
btnSelectAll.isSelected = false
60+
btnActive.isSelected = false
6261
}
6362
}
6463
}

examples/todos/android/src/main/java/org/reduxkotlin/example/todos/TodoAdapter.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class TodoAdapter : ListAdapter<Todo, TodoViewHolder>(DiffCallback()) {
2626
class TodoViewHolder(view: View) : RecyclerView.ViewHolder(view) {
2727
fun bind(todo: Todo) {
2828
if (todo.completed) {
29-
itemView.tv_todo.paintFlags = itemView.tv_todo.paintFlags or STRIKE_THRU_TEXT_FLAG
29+
itemView.tvTodo.paintFlags = itemView.tvTodo.paintFlags or STRIKE_THRU_TEXT_FLAG
3030
} else {
31-
itemView.tv_todo.paintFlags =
32-
itemView.tv_todo.paintFlags and STRIKE_THRU_TEXT_FLAG.inv()
31+
itemView.tvTodo.paintFlags =
32+
itemView.tvTodo.paintFlags and STRIKE_THRU_TEXT_FLAG.inv()
3333
}
3434

35-
itemView.tv_todo.text = "${todo.text}"
35+
itemView.tvTodo.text = "${todo.text}"
3636
itemView.setOnClickListener { store.dispatch(ToggleTodo(adapterPosition))}
3737
}
3838
}

examples/todos/android/src/main/res/layout/activity_main.xml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
android:layout_height="match_parent">
1010

1111
<EditText
12-
android:id="@+id/et_todo"
12+
android:id="@+id/etTodo"
1313
android:layout_width="0dp"
1414
android:layout_height="wrap_content"
1515
android:ems="10"
1616
android:inputType="textShortMessage"
17-
app:layout_constraintEnd_toStartOf="@+id/btn_add_todo"
17+
app:layout_constraintEnd_toStartOf="@+id/btnAddTodo"
1818
app:layout_constraintStart_toStartOf="parent"
1919
app:layout_constraintTop_toTopOf="parent"
2020
tools:text="Read docs" />
2121

2222
<Button
23-
android:id="@+id/btn_add_todo"
23+
android:id="@+id/btnAddTodo"
2424
android:layout_width="wrap_content"
2525
android:layout_height="wrap_content"
2626
android:text="Add Todo"
@@ -33,44 +33,44 @@
3333
android:layout_height="wrap_content"
3434
android:text="Show:"
3535
android:layout_marginEnd="8dp"
36-
app:layout_constraintBottom_toTopOf="@+id/recycler_view"
36+
app:layout_constraintBottom_toTopOf="@+id/recyclerView"
3737
app:layout_constraintStart_toStartOf="parent"
38-
app:layout_constraintTop_toBottomOf="@+id/et_todo" />
38+
app:layout_constraintTop_toBottomOf="@+id/etTodo" />
3939

4040
<Button
41-
android:id="@+id/btn_select_all"
41+
android:id="@+id/btnSelectAll"
4242
android:layout_width="wrap_content"
4343
android:layout_height="wrap_content"
4444
android:layout_marginStart="8dp"
4545
android:text="@android:string/selectAll"
4646
android:background="@drawable/btn_background"
4747
app:layout_constraintStart_toEndOf="@+id/textView"
48-
app:layout_constraintTop_toBottomOf="@+id/et_todo" />
48+
app:layout_constraintTop_toBottomOf="@+id/etTodo" />
4949

5050
<Button
51-
android:id="@+id/btn_active"
51+
android:id="@+id/btnActive"
5252
android:layout_width="wrap_content"
5353
android:layout_height="wrap_content"
5454
android:text="Active"
5555
android:background="@drawable/btn_background"
56-
app:layout_constraintStart_toEndOf="@+id/btn_select_all"
57-
app:layout_constraintTop_toBottomOf="@+id/et_todo" />
56+
app:layout_constraintStart_toEndOf="@+id/btnSelectAll"
57+
app:layout_constraintTop_toBottomOf="@+id/etTodo" />
5858

5959
<Button
60-
android:id="@+id/btn_completed"
60+
android:id="@+id/btnCompleted"
6161
android:layout_width="wrap_content"
6262
android:layout_height="wrap_content"
6363
android:text="Completed"
6464
android:background="@drawable/btn_background"
65-
app:layout_constraintStart_toEndOf="@+id/btn_active"
66-
app:layout_constraintTop_toTopOf="@+id/btn_active" />
65+
app:layout_constraintStart_toEndOf="@+id/btnActive"
66+
app:layout_constraintTop_toTopOf="@+id/btnActive" />
6767

6868
<androidx.recyclerview.widget.RecyclerView
69-
android:id="@+id/recycler_view"
69+
android:id="@+id/recyclerView"
7070
android:layout_width="match_parent"
7171
android:layout_height="0dp"
7272
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
7373
app:layout_constraintBottom_toBottomOf="parent"
7474
app:layout_constraintStart_toStartOf="parent"
75-
app:layout_constraintTop_toBottomOf="@+id/btn_completed" />
75+
app:layout_constraintTop_toBottomOf="@+id/btnCompleted" />
7676
</androidx.constraintlayout.widget.ConstraintLayout>

examples/todos/android/src/main/res/layout/item_todo.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
5-
android:orientation="vertical"
65
android:layout_width="match_parent"
76
android:layout_height="wrap_content">
87

98
<TextView
10-
android:id="@+id/tv_todo"
9+
android:id="@+id/tvTodo"
1110
android:layout_width="match_parent"
1211
android:layout_height="match_parent"
1312
android:layout_marginStart="16dp"

0 commit comments

Comments
 (0)