From 1ae3e86378ff3113ec1cb0ce4c7d1bf384398a29 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Sun, 21 Apr 2019 08:24:06 +0200 Subject: [PATCH] remove unneeded CollectionUtil and Either.java (#1201) --- .../keylesspalace/tusky/ViewMediaActivity.kt | 3 +- .../tusky/fragment/NotificationsFragment.java | 6 +-- .../tusky/fragment/TimelineFragment.java | 6 +-- .../tusky/util/CollectionUtil.java | 38 ------------------- .../com/keylesspalace/tusky/util/Either.java | 0 5 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 app/src/main/java/com/keylesspalace/tusky/util/CollectionUtil.java delete mode 100644 app/src/main/java/com/keylesspalace/tusky/util/Either.java diff --git a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt index a3343a400..6b95bfef2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ViewMediaActivity.kt @@ -47,7 +47,6 @@ import com.keylesspalace.tusky.fragment.ViewImageFragment import com.keylesspalace.tusky.pager.AvatarImagePagerAdapter import com.keylesspalace.tusky.pager.ImagePagerAdapter -import com.keylesspalace.tusky.util.CollectionUtil.map import com.keylesspalace.tusky.util.getTemporaryMediaFilename import com.keylesspalace.tusky.viewdata.AttachmentViewData import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider @@ -116,7 +115,7 @@ class ViewMediaActivity : BaseActivity(), ViewImageFragment.PhotoActionsListener val initialPosition = intent.getIntExtra(EXTRA_ATTACHMENT_INDEX, 0) val adapter = if (attachments != null) { - val realAttachs = map(attachments, AttachmentViewData::attachment) + val realAttachs = attachments!!.map(AttachmentViewData::attachment) // Setup the view pager. ImagePagerAdapter(supportFragmentManager, realAttachs, initialPosition) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index 475edb919..7eee789d3 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -51,7 +51,6 @@ import com.keylesspalace.tusky.entity.Status; import com.keylesspalace.tusky.interfaces.ActionButtonActivity; import com.keylesspalace.tusky.interfaces.ReselectableFragment; import com.keylesspalace.tusky.interfaces.StatusActionListener; -import com.keylesspalace.tusky.util.CollectionUtil; import com.keylesspalace.tusky.util.Either; import com.keylesspalace.tusky.util.HttpHeaderLink; import com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate; @@ -96,6 +95,7 @@ import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import kotlin.Unit; import kotlin.collections.CollectionsKt; +import kotlin.jvm.functions.Function1; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.Callback; @@ -985,11 +985,11 @@ public class NotificationsFragment extends SFragment implements updateAdapter(); } - private final Function> notificationLifter = + private final Function1> notificationLifter = Either.Right::new; private List> liftNotificationList(List list) { - return CollectionUtil.map(list, notificationLifter); + return CollectionsKt.map(list, notificationLifter); } private void fullyRefreshWithProgressBar(boolean isShow) { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index 1d628a016..3e164c94a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -53,7 +53,6 @@ import com.keylesspalace.tusky.network.MastodonApi; import com.keylesspalace.tusky.repository.Placeholder; import com.keylesspalace.tusky.repository.TimelineRepository; import com.keylesspalace.tusky.repository.TimelineRequestMode; -import com.keylesspalace.tusky.util.CollectionUtil; import com.keylesspalace.tusky.util.Either; import com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate; import com.keylesspalace.tusky.util.ListUtils; @@ -97,6 +96,7 @@ import io.reactivex.Observable; import io.reactivex.android.schedulers.AndroidSchedulers; import kotlin.Unit; import kotlin.collections.CollectionsKt; +import kotlin.jvm.functions.Function1; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; @@ -1159,7 +1159,7 @@ public class TimelineFragment extends SFragment implements return -1; } - private final Function> statusLifter = + private final Function1> statusLifter = Either.Right::new; private @Nullable @@ -1221,7 +1221,7 @@ public class TimelineFragment extends SFragment implements } private List> liftStatusList(List list) { - return CollectionUtil.map(list, statusLifter); + return CollectionsKt.map(list, statusLifter); } private void updateAdapter() { diff --git a/app/src/main/java/com/keylesspalace/tusky/util/CollectionUtil.java b/app/src/main/java/com/keylesspalace/tusky/util/CollectionUtil.java deleted file mode 100644 index e5c64874a..000000000 --- a/app/src/main/java/com/keylesspalace/tusky/util/CollectionUtil.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2017 Andrew Dawson - * - * This file is a part of Tusky. - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License as published by the Free Software Foundation; either version 3 of the - * License, or (at your option) any later version. - * - * Tusky is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even - * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. - * - * You should have received a copy of the GNU General Public License along with Tusky; if not, - * see . */ -package com.keylesspalace.tusky.util; - -import androidx.arch.core.util.Function; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by charlag on 05/11/17. - */ - -public final class CollectionUtil { - private CollectionUtil() { - throw new AssertionError(); - } - - public static List map(List list, Function mapper) { - final List newList = new ArrayList<>(list.size()); - for (E el : list) { - newList.add(mapper.apply(el)); - } - return newList; - } -} diff --git a/app/src/main/java/com/keylesspalace/tusky/util/Either.java b/app/src/main/java/com/keylesspalace/tusky/util/Either.java deleted file mode 100644 index e69de29bb..000000000