diff --git a/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt b/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt index c3cc66a94..910f0a60f 100644 --- a/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt +++ b/app/src/debug/java/org/tasks/preferences/fragments/Debug.kt @@ -4,7 +4,6 @@ import android.os.Bundle import androidx.annotation.StringRes import androidx.preference.Preference import at.bitfire.cert4android.CustomCertManager.Companion.resetCertificates -import com.google.common.primitives.Ints import org.tasks.R import org.tasks.billing.BillingClient import org.tasks.billing.Inventory @@ -22,7 +21,7 @@ class Debug : InjectingPreferenceFragment() { override fun getPreferenceXml() = R.xml.preferences_debug override fun setupPreferences(savedInstanceState: Bundle?) { - for (pref in Ints.asList( + for (pref in listOf( R.string.p_leakcanary, R.string.p_flipper, R.string.p_strict_mode_vm, diff --git a/app/src/main/java/org/tasks/activities/attribution/AttributionActivity.kt b/app/src/main/java/org/tasks/activities/attribution/AttributionActivity.kt index 54b14861d..089c36d40 100644 --- a/app/src/main/java/org/tasks/activities/attribution/AttributionActivity.kt +++ b/app/src/main/java/org/tasks/activities/attribution/AttributionActivity.kt @@ -7,7 +7,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import butterknife.BindView import butterknife.ButterKnife -import com.google.common.base.Joiner import com.google.common.collect.Multimaps import org.tasks.R import org.tasks.activities.attribution.AttributionViewModel.LibraryAttribution @@ -58,7 +57,7 @@ class AttributionActivity : ThemedInjectingAppCompatActivity() { val byCopyrightHolder = Multimaps.index(attributions) { lib -> lib!!.copyrightHolder } return byCopyrightHolder.keySet().sorted().map { val libraries = byCopyrightHolder[it].map { a -> "\u2022 " + a.libraryName } - AttributionRow(it, Joiner.on("\n").join(libraries.toList().sorted())) + AttributionRow(it, libraries.sorted().joinToString("\n")) } } diff --git a/app/src/main/java/org/tasks/billing/PurchaseActivity.kt b/app/src/main/java/org/tasks/billing/PurchaseActivity.kt index 848edb7fc..b5b492f91 100644 --- a/app/src/main/java/org/tasks/billing/PurchaseActivity.kt +++ b/app/src/main/java/org/tasks/billing/PurchaseActivity.kt @@ -12,9 +12,6 @@ import androidx.appcompat.widget.Toolbar import butterknife.ButterKnife import butterknife.OnClick import com.google.android.material.button.MaterialButtonToggleGroup -import com.google.common.collect.ContiguousSet -import com.google.common.collect.DiscreteDomain -import com.google.common.collect.Range import org.tasks.LocalBroadcastManager import org.tasks.R import org.tasks.databinding.ActivityPurchaseBinding @@ -147,8 +144,7 @@ class PurchaseActivity : ThemedInjectingAppCompatActivity(), OnPurchasesUpdated, binding.unsubscribe.visibility = if (currentSubscription == null || currentSubscription?.isCanceled == true) View.GONE else View.VISIBLE updateSubscribeButton() setWaitScreen(false) - adapter.submitList( - ArrayList(ContiguousSet.create(Range.closed(1, 10), DiscreteDomain.integers()))) + adapter.submitList((1..10).toList()) binding.recyclerView.layoutManager = IconLayoutManager(this) binding.recyclerView.adapter = adapter } diff --git a/app/src/main/java/org/tasks/caldav/iCalendar.kt b/app/src/main/java/org/tasks/caldav/iCalendar.kt index 74bef302a..6711e6d37 100644 --- a/app/src/main/java/org/tasks/caldav/iCalendar.kt +++ b/app/src/main/java/org/tasks/caldav/iCalendar.kt @@ -2,11 +2,7 @@ package org.tasks.caldav import at.bitfire.ical4android.Task import at.bitfire.ical4android.Task.Companion.tasksFromReader -import com.google.common.base.Predicate import com.google.common.collect.Iterables -import com.google.common.collect.Lists -import com.google.common.collect.Sets.difference -import com.google.common.collect.Sets.newHashSet import com.todoroo.andlib.utility.DateUtilities import com.todoroo.astrid.dao.TaskDao import com.todoroo.astrid.helper.UUIDHelper @@ -41,7 +37,7 @@ class iCalendar @Inject constructor( private val caldavDao: CaldavDao) { companion object { - private val IS_PARENT = Predicate { r: RelatedTo? -> + private val IS_PARENT: (RelatedTo?) -> Boolean = { r: RelatedTo? -> r!!.parameters.isEmpty || r.getParameter(Parameter.RELTYPE) === RelType.PARENT } @@ -58,9 +54,7 @@ class iCalendar @Inject constructor( } fun getParent(remote: Task): String? { - val relatedTo = remote.relatedTo - val parent = Iterables.tryFind(relatedTo, IS_PARENT) - return if (parent.isPresent) parent.get().value else null + return remote.relatedTo.find(IS_PARENT)?.value } fun setParent(remote: Task, value: String?) { @@ -68,9 +62,9 @@ class iCalendar @Inject constructor( if (isNullOrEmpty(value)) { Iterables.removeIf(relatedTo, IS_PARENT) } else { - val parent = Iterables.tryFind(relatedTo, IS_PARENT) - if (parent.isPresent) { - parent.get().value = value + val parent = relatedTo.find(IS_PARENT) + if (parent != null) { + parent.value = value } else { relatedTo.add(RelatedTo(value)) } @@ -106,8 +100,8 @@ class iCalendar @Inject constructor( return emptyList() } val tags = tagDataDao.getTags(categories).toMutableList() - val existing = Lists.transform(tags) { obj: TagData? -> obj!!.name } - val toCreate = difference(newHashSet(categories), newHashSet(existing)) + val existing = tags.map(TagData::name) + val toCreate = categories subtract existing for (name in toCreate) { val tag = TagData(name) tagDataDao.createNew(tag) @@ -120,7 +114,7 @@ class iCalendar @Inject constructor( val remoteModel = CaldavConverter.toCaldav(caldavTask, task) val categories = remoteModel.categories categories.clear() - categories.addAll(Lists.transform(tagDataDao.getTagDataForTask(task.getId())) { obj: TagData? -> obj!!.name }) + categories.addAll(tagDataDao.getTagDataForTask(task.getId()).map { it.name!! }) if (isNullOrEmpty(caldavTask.remoteId)) { val caldavUid = UUIDHelper.newUUID() caldavTask.remoteId = caldavUid diff --git a/app/src/main/java/org/tasks/data/TagDataDao.kt b/app/src/main/java/org/tasks/data/TagDataDao.kt index 1fd9c2767..09aa437fa 100644 --- a/app/src/main/java/org/tasks/data/TagDataDao.kt +++ b/app/src/main/java/org/tasks/data/TagDataDao.kt @@ -3,7 +3,6 @@ package org.tasks.data import androidx.core.util.Pair import androidx.lifecycle.LiveData import androidx.room.* -import com.google.common.collect.Iterables import com.todoroo.astrid.data.Task import com.todoroo.astrid.helper.UUIDHelper import org.tasks.db.DbUtils @@ -89,7 +88,7 @@ abstract class TagDataDao { tasks: List, partiallySelected: List, selected: List): List { val modified = HashSet() val keep = partiallySelected.plus(selected).map { it.remoteId!! } - for (sublist in Iterables.partition(tasks, DbUtils.MAX_SQLITE_ARGS - keep.size)) { + for (sublist in tasks.chunked(DbUtils.MAX_SQLITE_ARGS - keep.size)) { val tags = tagsToDelete(sublist.map(Task::id), keep) deleteTags(tags) modified.addAll(tags.map(Tag::task)) diff --git a/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt b/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt index 9f1b7ae86..942314c84 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/ScrollableWidget.kt @@ -5,7 +5,6 @@ import android.appwidget.AppWidgetManager import android.content.Intent import android.os.Bundle import androidx.preference.* -import com.google.common.primitives.Ints.max import com.todoroo.astrid.api.Filter import org.tasks.LocalBroadcastManager import org.tasks.R @@ -62,7 +61,7 @@ class ScrollableWidget : InjectingPreferenceFragment() { val footer = setupSlider(R.string.p_widget_footer_opacity, row.value) val opacity = findPreference(R.string.opacity) as SeekBarPreference - opacity.value = max(header.value, row.value, footer.value) + opacity.value = maxOf(header.value, row.value, footer.value) if (header.value != row.value || header.value != footer.value) { (findPreference(R.string.preferences_advanced) as PreferenceCategory).initialExpandedChildrenCount = 4 }