Skip to content
This repository was archived by the owner on Apr 19, 2022. It is now read-only.

Commit 415eddc

Browse files
committed
Removed Guava
1 parent 55294d7 commit 415eddc

File tree

13 files changed

+40
-73
lines changed

13 files changed

+40
-73
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ Compared to TODO-MVP, new classes were added for 1) setting the interfaces to he
158158
-------------------------------------------------------------------------------
159159
Language files blank comment code
160160
-------------------------------------------------------------------------------
161-
Kotlin 75 890 1659 3990 (3639 in MVP-RXJAVA, (4798 in MVI-RXJAVA-KOTLIN))
161+
Kotlin 75 886 1645 3977 (3639 in MVP-RXJAVA, (4798 in MVI-RXJAVA-KOTLIN))
162162
XML 34 97 338 610
163163
-------------------------------------------------------------------------------
164-
SUM: 109 987 1997 4600
164+
SUM: 109 983 1983 4587
165165
-------------------------------------------------------------------------------
166166
```
167167
### Maintainability

app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ dependencies {
8282
implementation "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
8383
implementation "com.android.support:support-v4:$rootProject.supportLibraryVersion"
8484
implementation "com.android.support.test.espresso:espresso-idling-resource:$rootProject.espressoVersion"
85-
implementation "com.google.guava:guava:$rootProject.guavaVersion"
8685
implementation "io.reactivex.rxjava2:rxjava:$rootProject.rxjavaVersion"
8786
implementation "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroidVersion"
8887
implementation "com.squareup.sqlbrite2:sqlbrite:$rootProject.sqlbriteVersion"

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ class AddEditTaskActionProcessorHolder(
6969
private val updateTaskProcessor =
7070
ObservableTransformer<UpdateTaskAction, UpdateTaskResult> { actions ->
7171
actions.flatMap { action ->
72-
tasksRepository.saveTask(Task.invoke(action.title, action.description, action.taskId))
73-
.andThen(Observable.just(UpdateTaskResult))
72+
tasksRepository.saveTask(
73+
Task(title = action.title, description = action.description, id = action.taskId)
74+
).andThen(Observable.just(UpdateTaskResult))
7475
}
7576
}
7677

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.example.android.architecture.blueprints.todoapp.data
22

3-
import com.google.common.base.Strings
3+
import com.example.android.architecture.blueprints.todoapp.util.isNotNullNorEmpty
44
import java.util.UUID
55

66
data class Task(
@@ -9,28 +9,14 @@ data class Task(
99
val description: String?,
1010
val completed: Boolean = false
1111
) {
12-
val titleForList = if (!Strings.isNullOrEmpty(title)) {
13-
title
14-
} else {
15-
description
16-
}
12+
val titleForList =
13+
if (title.isNotNullNorEmpty()) {
14+
title
15+
} else {
16+
description
17+
}
1718

1819
val active = !completed
1920

20-
val empty = Strings.isNullOrEmpty(title) && Strings.isNullOrEmpty(description)
21-
22-
// TODO(benoit) remove those when Java is gone
23-
companion object {
24-
operator fun invoke(title: String, description: String): Task {
25-
return Task(title = title, description = description)
26-
}
27-
28-
operator fun invoke(title: String, description: String, id: String): Task {
29-
return Task(title = title, description = description, id = id)
30-
}
31-
32-
operator fun invoke(title: String, description: String, completed: Boolean): Task {
33-
return Task(title = title, description = description, completed = completed)
34-
}
35-
}
21+
val empty = title.isNullOrEmpty() && description.isNullOrEmpty()
3622
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package com.example.android.architecture.blueprints.todoapp.data.source
1919
import android.support.annotation.VisibleForTesting
2020
import com.example.android.architecture.blueprints.todoapp.data.Task
2121
import com.example.android.architecture.blueprints.todoapp.util.SingletonHolderDoubleArg
22-
import com.google.common.base.Preconditions.checkNotNull
2322
import io.reactivex.Completable
2423
import io.reactivex.Observable
2524
import io.reactivex.Single

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object TasksRemoteDataSource : TasksDataSource {
3939
}
4040

4141
private fun addTask(title: String, description: String) {
42-
val newTask = Task.invoke(title, description)
42+
val newTask = Task(title = title, description = description)
4343
tasksServiceData.put(newTask.id, newTask)
4444
}
4545

@@ -72,7 +72,7 @@ object TasksRemoteDataSource : TasksDataSource {
7272
}
7373

7474
override fun activateTask(task: Task): Completable {
75-
val activeTask = Task.invoke(task.title!!, task.description!!, task.id)
75+
val activeTask = Task(title = task.title!!, description = task.description!!, id = task.id)
7676
tasksServiceData.put(task.id, activeTask)
7777
return Completable.complete()
7878
}

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

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.example.android.architecture.blueprints.todoapp.util
2+
3+
fun String?.isNullOrEmpty() = this == null || this.isEmpty()
4+
fun String?.isNotNullNorEmpty() = !this.isNullOrEmpty()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ object FakeTasksRemoteDataSource : TasksDataSource {
5656
}
5757

5858
override fun activateTask(task: Task): Completable {
59-
val activeTask = Task.invoke(task.title!!, task.description!!, task.id)
59+
val activeTask = Task(title = task.title!!, description = task.description!!, id = task.id)
6060
TasksServiceData.put(task.id, activeTask)
6161
return Completable.complete()
6262
}
6363

6464
override fun activateTask(taskId: String): Completable {
6565
val task = TasksServiceData[taskId]!!
66-
val activeTask = Task.invoke(task.title!!, task.description!!, task.id)
66+
val activeTask = Task(title = task.title!!, description = task.description!!, id = task.id)
6767
TasksServiceData.put(taskId, activeTask)
6868
return Completable.complete()
6969
}

app/src/prod/java/com/example/android/architecture/blueprints/todoapp/Injection.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import com.example.android.architecture.blueprints.todoapp.data.source.remote.Ta
2525
import com.example.android.architecture.blueprints.todoapp.util.schedulers.BaseSchedulerProvider
2626
import com.example.android.architecture.blueprints.todoapp.util.schedulers.SchedulerProvider
2727

28-
import com.google.common.base.Preconditions.checkNotNull
29-
3028
/**
3129
* Enables injection of production implementations for
3230
* [TasksDataSource] at compile time.

app/src/test/java/com/example/android/architecture/blueprints/todoapp/data/source/TasksRepositoryTest.kt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class TasksRepositoryTest {
125125
@Test
126126
fun saveTask_savesTaskToServiceAPI() {
127127
// Given a stub task with title and description
128-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description")
128+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description")
129129

130130
// When a task is saved to the tasks repository
131131
tasksRepository.saveTask(newTask)
@@ -139,7 +139,7 @@ class TasksRepositoryTest {
139139
@Test
140140
fun completeTask_completesTaskToServiceAPIUpdatesCache() {
141141
// Given a stub active task with title and description added in the repository
142-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description")
142+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description")
143143
tasksRepository.saveTask(newTask)
144144

145145
// When a task is completed to the tasks repository
@@ -158,7 +158,7 @@ class TasksRepositoryTest {
158158
@Test
159159
fun completeTaskId_completesTaskToServiceAPIUpdatesCache() {
160160
// Given a stub active task with title and description added in the repository
161-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description")
161+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description")
162162
tasksRepository.saveTask(newTask)
163163

164164
// When a task is completed using its id to the tasks repository
@@ -176,7 +176,7 @@ class TasksRepositoryTest {
176176
@Test
177177
fun activateTask_activatesTaskToServiceAPIUpdatesCache() {
178178
// Given a stub completed task with title and description in the repository
179-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description", true)
179+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description", completed = true)
180180
tasksRepository.saveTask(newTask)
181181

182182
// When a completed task is activated to the tasks repository
@@ -194,7 +194,7 @@ class TasksRepositoryTest {
194194
@Test
195195
fun activateTaskId_activatesTaskToServiceAPIUpdatesCache() {
196196
// Given a stub completed task with title and description in the repository
197-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description", true)
197+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description", completed = true)
198198
tasksRepository.saveTask(newTask)
199199

200200
// When a completed task is activated with its id to the tasks repository
@@ -212,7 +212,7 @@ class TasksRepositoryTest {
212212
@Test
213213
fun getTask_requestsSingleTaskFromLocalDataSource() {
214214
// Given a stub completed task with title and description in the local repository
215-
val task = Task.invoke(TASK_TITLE, "Some Task Description", true)
215+
val task = Task(title = TASK_TITLE, description = "Some Task Description", completed = true)
216216
setTaskAvailable(tasksLocalDataSource, task)
217217
// And the task not available in the remote repository
218218
setTaskNotAvailable(tasksRemoteDataSource, task.id)
@@ -229,7 +229,7 @@ class TasksRepositoryTest {
229229
@Test
230230
fun getTask_whenDataNotLocal_fails() {
231231
// Given a stub completed task with title and description in the remote repository
232-
val task = Task.invoke(TASK_TITLE, "Some Task Description", true)
232+
val task = Task(title = TASK_TITLE, description = "Some Task Description", completed = true)
233233
setTaskAvailable(tasksRemoteDataSource, task)
234234
// And the task not available in the local repository
235235
setTaskNotAvailable(tasksLocalDataSource, task.id)
@@ -245,11 +245,12 @@ class TasksRepositoryTest {
245245
@Test
246246
fun deleteCompletedTasks_deleteCompletedTasksToServiceAPIUpdatesCache() {
247247
// Given 2 stub completed tasks and 1 stub active tasks in the repository
248-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description", true)
248+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description", completed = true)
249249
tasksRepository.saveTask(newTask)
250-
val newTask2 = Task.invoke(TASK_TITLE2, "Some Task Description")
250+
val newTask2 = Task(title = TASK_TITLE2, description = "Some Task Description")
251251
tasksRepository.saveTask(newTask2)
252-
val newTask3 = Task.invoke(TASK_TITLE3, "Some Task Description", true)
252+
val newTask3 = Task(title = TASK_TITLE3, description = "Some Task Description",
253+
completed = true)
253254
tasksRepository.saveTask(newTask3)
254255

255256
// When a completed tasks are cleared to the tasks repository
@@ -269,11 +270,12 @@ class TasksRepositoryTest {
269270
@Test
270271
fun deleteAllTasks_deleteTasksToServiceAPIUpdatesCache() {
271272
// Given 2 stub completed tasks and 1 stub active tasks in the repository
272-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description", true)
273+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description", completed = true)
273274
tasksRepository.saveTask(newTask)
274-
val newTask2 = Task.invoke(TASK_TITLE2, "Some Task Description")
275+
val newTask2 = Task(title = TASK_TITLE2, description = "Some Task Description")
275276
tasksRepository.saveTask(newTask2)
276-
val newTask3 = Task.invoke(TASK_TITLE3, "Some Task Description", true)
277+
val newTask3 = Task(title = TASK_TITLE3, description = "Some Task Description",
278+
completed = true)
277279
tasksRepository.saveTask(newTask3)
278280

279281
// When all tasks are deleted to the tasks repository
@@ -289,7 +291,7 @@ class TasksRepositoryTest {
289291
@Test
290292
fun deleteTask_deleteTaskToServiceAPIRemovedFromCache() {
291293
// Given a task in the repository
292-
val newTask = Task.invoke(TASK_TITLE, "Some Task Description", true)
294+
val newTask = Task(title = TASK_TITLE, description = "Some Task Description", completed = true)
293295
tasksRepository.saveTask(newTask)
294296
assertThat(tasksRepository.cachedTasks!!.containsKey(newTask.id), `is`(true))
295297

@@ -407,7 +409,7 @@ class TasksRepositoryTest {
407409
private const val TASK_TITLE2 = "title2"
408410
private const val TASK_TITLE3 = "title3"
409411
private val TASKS = listOf(
410-
Task.invoke("Title1", "Description1"),
411-
Task.invoke("Title2", "Description2"))
412+
Task(title = "Title1", description = "Description1"),
413+
Task(title = "Title2", description = "Description2"))
412414
}
413415
}

app/src/test/java/com/example/android/architecture/blueprints/todoapp/tasks/TasksViewModelTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import com.example.android.architecture.blueprints.todoapp.data.Task
2020
import com.example.android.architecture.blueprints.todoapp.data.source.TasksRepository
2121
import com.example.android.architecture.blueprints.todoapp.util.schedulers.BaseSchedulerProvider
2222
import com.example.android.architecture.blueprints.todoapp.util.schedulers.ImmediateSchedulerProvider
23-
import com.google.common.collect.Lists
2423
import com.nhaarman.mockito_kotlin.any
2524
import io.reactivex.Completable
2625
import io.reactivex.Observable
@@ -57,7 +56,7 @@ class TasksViewModelTest {
5756
tasksViewModel = TasksViewModel(TasksActionProcessorHolder(tasksRepository, schedulerProvider))
5857

5958
// We subscribe the tasks to 3, with one active and two completed
60-
tasks = Lists.newArrayList(
59+
tasks = listOf(
6160
Task(title = "Title1", description = "Description1", completed = false),
6261
Task(title = "Title2", description = "Description2", completed = true),
6362
Task(title = "Title3", description = "Description3", completed = true))

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ ext {
3232

3333
// App dependencies
3434
supportLibraryVersion = '27.0.2'
35-
guavaVersion = '22.0-android'
3635
junitVersion = '4.12'
3736
mockitoVersion = '1.10.19'
3837
powerMockito = '1.6.2'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy