Replace some guava usage with kotlin

pull/1451/head
Alex Baker 4 years ago
parent a5663cd299
commit 675cc1f6c9

@ -4,7 +4,6 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import com.google.common.collect.Lists
import com.google.common.io.Files
import com.todoroo.astrid.data.Task
import com.todoroo.astrid.service.TaskCreator
@ -90,7 +89,7 @@ class ShareLinkActivity : InjectingAppCompatActivity() {
?: uri.lastPathSegment
}
val basename = Files.getNameWithoutExtension(filename!!)
return Lists.newArrayList(FileHelper.copyToUri(this, preferences.attachmentsDirectory!!, uri, basename))
return arrayListOf(FileHelper.copyToUri(this, preferences.attachmentsDirectory!!, uri, basename))
}
private fun copyMultipleAttachments(intent: Intent): ArrayList<Uri> {

@ -1,6 +1,5 @@
package com.todoroo.astrid.service
import com.google.common.collect.Lists
import com.todoroo.andlib.utility.DateUtilities
import com.todoroo.astrid.dao.TaskDao
import com.todoroo.astrid.data.Task
@ -54,7 +53,7 @@ class TaskDuplicator @Inject constructor(
val newId = taskDao.createNew(clone)
val tags = tagDataDao.getTagDataForTask(originalId)
if (tags.isNotEmpty()) {
tagDao.insert(Lists.transform(tags) { td: TagData? -> Tag(clone, td!!) })
tagDao.insert(tags.map { Tag(clone, it) })
}
val googleTask = googleTaskDao.getByTaskId(originalId)
val addToTop = preferences.addTasksToTop()
@ -71,7 +70,7 @@ class TaskDuplicator @Inject constructor(
}
val alarms = alarmDao.getAlarms(originalId)
if (alarms.isNotEmpty()) {
alarmDao.insert(Lists.transform(alarms) { a: Alarm? -> Alarm(clone.id, a!!.time) })
alarmDao.insert(alarms.map { Alarm(clone.id, it.time) })
}
gcalHelper.createTaskEventIfEnabled(clone)
taskDao.save(clone, null) // TODO: delete me

@ -15,7 +15,6 @@ import com.etesync.journalmanager.model.CollectionInfo
import com.etesync.journalmanager.model.CollectionInfo.Companion.fromJson
import com.etesync.journalmanager.model.SyncEntry
import com.etesync.journalmanager.util.TokenAuthenticator
import com.google.common.collect.Lists
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@ -213,7 +212,7 @@ class EteSyncClient {
suspend fun pushEntries(journal: Journal, entries: List<JournalEntryManager.Entry>?, remoteCtag: String?) = withContext(Dispatchers.IO) {
var remoteCtag = remoteCtag
val journalEntryManager = JournalEntryManager(httpClient!!, httpUrl!!, journal.uid!!)
for (partition in Lists.partition(entries!!, MAX_PUSH)) {
for (partition in entries!!.chunked(MAX_PUSH)) {
journalEntryManager.create(partition, remoteCtag)
remoteCtag = partition[partition.size - 1].uid
}

@ -10,7 +10,6 @@ import android.content.Context
import android.os.Bundle
import com.google.api.services.drive.DriveScopes
import com.google.api.services.tasks.TasksScopes
import com.google.common.collect.Lists
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@ -30,7 +29,7 @@ class GoogleAccountManager @Inject constructor(
private val accountManager: AccountManager = AccountManager.get(context)
val accounts: List<String>
get() = Lists.transform(accountList) { account: Account? -> account!!.name }
get() = accountList.map { it.name }
private val accountList: List<Account>
get() = if (permissionChecker.canAccessAccounts()) {

@ -6,7 +6,6 @@ import com.google.api.client.util.DateTime
import com.google.api.services.tasks.model.Task
import com.google.api.services.tasks.model.TaskList
import com.google.api.services.tasks.model.Tasks
import com.google.common.collect.Lists
import com.todoroo.andlib.utility.DateUtilities
import com.todoroo.astrid.api.GtasksFilter
import com.todoroo.astrid.dao.TaskDao
@ -129,7 +128,7 @@ class GoogleTaskSynchronizer @Inject constructor(
preferences.setString(R.string.p_default_list, null)
}
}
for (list in googleTaskListDao.getByRemoteId(Lists.transform(gtaskLists) { obj: TaskList? -> obj!!.id })) {
for (list in googleTaskListDao.getByRemoteId(gtaskLists.map { it.id })) {
if (isNullOrEmpty(list.remoteId)) {
firebase.reportException(RuntimeException("Empty remote id"))
continue

@ -2,7 +2,6 @@ package org.tasks.jobs
import android.content.Intent
import android.os.IBinder
import com.google.common.collect.Lists
import com.todoroo.andlib.utility.AndroidUtilities
import dagger.hilt.android.AndroidEntryPoint
import org.tasks.Notifier
@ -31,7 +30,7 @@ class NotificationService : InjectingService() {
if (!notificationQueue.remove(overdueJobs)) {
throw RuntimeException("Failed to remove jobs from queue")
}
notifier.triggerNotifications(Lists.transform(overdueJobs) { obj: NotificationQueueEntry? -> obj!!.toNotification() })
notifier.triggerNotifications(overdueJobs.map { it.toNotification() })
}
}

Loading…
Cancel
Save