Skip to content

Commit 323de1d

Browse files
committed
Fixes some lint errors
1 parent cd3bb2a commit 323de1d

File tree

6 files changed

+21
-31
lines changed

6 files changed

+21
-31
lines changed

app/src/androidTest/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksActivityTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ class TasksActivityTest {
127127

128128
// Add active task
129129
onView(withId(R.id.add_task_fab)).perform(click())
130-
onView(withId(R.id.add_task_title_edit_text)).perform(typeText("TITLE1"), closeSoftKeyboard())
130+
onView(withId(R.id.add_task_title_edit_text))
131+
.perform(typeText("TITLE1"), closeSoftKeyboard())
131132
onView(withId(R.id.add_task_description_edit_text)).perform(typeText("DESCRIPTION"))
132133
onView(withId(R.id.save_task_fab)).perform(click())
133134

@@ -284,7 +285,8 @@ class TasksActivityTest {
284285

285286
// Click on the "+" button, add details, and save
286287
onView(withId(R.id.add_task_fab)).perform(click())
287-
onView(withId(R.id.add_task_title_edit_text)).perform(typeText("title"), closeSoftKeyboard())
288+
onView(withId(R.id.add_task_title_edit_text))
289+
.perform(typeText("title"), closeSoftKeyboard())
288290
onView(withId(R.id.add_task_description_edit_text)).perform(typeText("description"))
289291
onView(withId(R.id.save_task_fab)).perform(click())
290292

app/src/main/java/com/example/android/architecture/blueprints/todoapp/Event.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.lifecycle.Observer
2222
*/
2323
open class Event<out T>(private val content: T) {
2424

25+
@Suppress("MemberVisibilityCanBePrivate")
2526
var hasBeenHandled = false
2627
private set // Allow external read but not write
2728

app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/source/remote/TasksRemoteDataSource.kt

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,14 @@ object TasksRemoteDataSource : TasksDataSource {
3636
addTask("Finish bridge in Tacoma", "Found awesome girders at half the cost!")
3737
}
3838

39-
/**
40-
* Note: [LoadTasksCallback.onDataNotAvailable] is never fired. In a real remote data
41-
* source implementation, this would be fired if the server can't be contacted or the server
42-
* returns an error.
43-
*/
4439
override suspend fun getTasks(): Result<List<Task>> {
4540
// Simulate network by delaying the execution.
4641
val tasks = TASKS_SERVICE_DATA.values.toList()
4742
delay(SERVICE_LATENCY_IN_MILLIS)
4843
return Success(tasks)
4944
}
5045

51-
/**
52-
* Note: [GetTaskCallback.onDataNotAvailable] is never fired. In a real remote data
53-
* source implementation, this would be fired if the server can't be contacted or the server
54-
* returns an error.
55-
*/
5646
override suspend fun getTask(taskId: String): Result<Task> {
57-
5847
// Simulate network by delaying the execution.
5948
delay(SERVICE_LATENCY_IN_MILLIS)
6049
TASKS_SERVICE_DATA[taskId]?.let {
@@ -65,31 +54,29 @@ object TasksRemoteDataSource : TasksDataSource {
6554

6655
private fun addTask(title: String, description: String) {
6756
val newTask = Task(title, description)
68-
TASKS_SERVICE_DATA.put(newTask.id, newTask)
57+
TASKS_SERVICE_DATA[newTask.id] = newTask
6958
}
7059

7160
override suspend fun saveTask(task: Task) {
72-
TASKS_SERVICE_DATA.put(task.id, task)
61+
TASKS_SERVICE_DATA[task.id] = task
7362
}
7463

7564
override suspend fun completeTask(task: Task) {
7665
val completedTask = Task(task.title, task.description, true, task.id)
77-
TASKS_SERVICE_DATA.put(task.id, completedTask)
66+
TASKS_SERVICE_DATA[task.id] = completedTask
7867
}
7968

8069
override suspend fun completeTask(taskId: String) {
81-
// Not required for the remote data source because the {@link DefaultTasksRepository} handles
82-
// converting from a {@code taskId} to a {@link task} using its cached data.
70+
// Not required for the remote data source
8371
}
8472

8573
override suspend fun activateTask(task: Task) {
8674
val activeTask = Task(task.title, task.description, false, task.id)
87-
TASKS_SERVICE_DATA.put(task.id, activeTask)
75+
TASKS_SERVICE_DATA[task.id] = activeTask
8876
}
8977

9078
override suspend fun activateTask(taskId: String) {
91-
// Not required for the remote data source because the {@link DefaultTasksRepository} handles
92-
// converting from a {@code taskId} to a {@link task} using its cached data.
79+
// Not required for the remote data source
9380
}
9481

9582
override suspend fun clearCompletedTasks() {

app/src/mock/java/com/example/android/architecture/blueprints/todoapp/data/FakeTasksRemoteDataSource.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ object FakeTasksRemoteDataSource : TasksDataSource {
3939
}
4040

4141
override suspend fun saveTask(task: Task) {
42-
TASKS_SERVICE_DATA.put(task.id, task)
42+
TASKS_SERVICE_DATA[task.id] = task
4343
}
4444

4545
override suspend fun completeTask(task: Task) {
4646
val completedTask = Task(task.title, task.description, true, task.id)
47-
TASKS_SERVICE_DATA.put(task.id, completedTask)
47+
TASKS_SERVICE_DATA[task.id] = completedTask
4848
}
4949

5050
override suspend fun completeTask(taskId: String) {
@@ -53,7 +53,7 @@ object FakeTasksRemoteDataSource : TasksDataSource {
5353

5454
override suspend fun activateTask(task: Task) {
5555
val activeTask = Task(task.title, task.description, false, task.id)
56-
TASKS_SERVICE_DATA.put(task.id, activeTask)
56+
TASKS_SERVICE_DATA[task.id] = activeTask
5757
}
5858

5959
override suspend fun activateTask(taskId: String) {

app/src/sharedTest/java/com/example/android/architecture/blueprints/todoapp/data/source/local/TasksLocalDataSourceTest.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import androidx.test.core.app.ApplicationProvider
2121
import androidx.test.ext.junit.runners.AndroidJUnit4
2222
import androidx.test.filters.MediumTest
2323
import com.example.android.architecture.blueprints.todoapp.MainCoroutineRule
24-
import com.example.android.architecture.blueprints.todoapp.data.Result
2524
import com.example.android.architecture.blueprints.todoapp.data.Result.Success
2625
import com.example.android.architecture.blueprints.todoapp.data.Task
2726
import com.example.android.architecture.blueprints.todoapp.data.source.TasksDataSource
@@ -105,7 +104,7 @@ class TasksLocalDataSourceTest {
105104

106105
// Then the task can be retrieved from the persistent repository and is complete
107106
assertThat(result.succeeded, `is`(true))
108-
result as Result.Success
107+
result as Success
109108
assertThat(result.data.title, `is`(newTask.title))
110109
assertThat(result.data.isCompleted, `is`(true))
111110
}
@@ -122,7 +121,7 @@ class TasksLocalDataSourceTest {
122121
val result = localDataSource.getTask(newTask.id)
123122

124123
assertThat(result.succeeded, `is`(true))
125-
result as Result.Success
124+
result as Success
126125

127126
assertThat(result.data.title, `is`("Some title"))
128127
assertThat(result.data.isCompleted, `is`(false))
@@ -149,7 +148,7 @@ class TasksLocalDataSourceTest {
149148
val result3 = localDataSource.getTask(newTask3.id)
150149

151150
assertThat(result3.succeeded, `is`(true))
152-
result3 as Result.Success
151+
result3 as Success
153152

154153
assertThat(result3.data, `is`(newTask3))
155154
}
@@ -165,7 +164,7 @@ class TasksLocalDataSourceTest {
165164
localDataSource.deleteAllTasks()
166165

167166
// Then the retrieved tasks is an empty list
168-
val result = localDataSource.getTasks() as Result.Success
167+
val result = localDataSource.getTasks() as Success
169168
assertThat(result.data.isEmpty(), `is`(true))
170169

171170
}
@@ -179,7 +178,7 @@ class TasksLocalDataSourceTest {
179178
localDataSource.saveTask(newTask1)
180179
localDataSource.saveTask(newTask2)
181180
// Then the tasks can be retrieved from the persistent repository
182-
val results = localDataSource.getTasks() as Result.Success<List<Task>>
181+
val results = localDataSource.getTasks() as Success<List<Task>>
183182
val tasks = results.data
184183
assertThat(tasks.size, `is`(2))
185184
}

app/src/sharedTest/java/com/example/android/architecture/blueprints/todoapp/statistics/StatisticsFragmentTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class StatisticsFragmentTest {
101101
onView(withId(R.id.stats_active_text)).check(matches(isDisplayed()))
102102
onView(withId(R.id.stats_active_text)).check(matches(withText(expectedActiveTaskText)))
103103
onView(withId(R.id.stats_completed_text)).check(matches(isDisplayed()))
104-
onView(withId(R.id.stats_completed_text)).check(matches(withText(expectedCompletedTaskText)))
104+
onView(withId(R.id.stats_completed_text))
105+
.check(matches(withText(expectedCompletedTaskText)))
105106
}
106107
}

0 commit comments

Comments
 (0)