remove unneeded CollectionUtil and Either.java (#1201)

This commit is contained in:
Konrad Pozniak 2019-04-21 08:24:06 +02:00 committed by GitHub
parent 8b85df08bd
commit 1ae3e86378
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 46 deletions

View File

@ -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)

View File

@ -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<Notification, Either<Placeholder, Notification>> notificationLifter =
private final Function1<Notification, Either<Placeholder, Notification>> notificationLifter =
Either.Right::new;
private List<Either<Placeholder, Notification>> liftNotificationList(List<Notification> list) {
return CollectionUtil.map(list, notificationLifter);
return CollectionsKt.map(list, notificationLifter);
}
private void fullyRefreshWithProgressBar(boolean isShow) {

View File

@ -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<Status, Either<Placeholder, Status>> statusLifter =
private final Function1<Status, Either<Placeholder, Status>> statusLifter =
Either.Right::new;
private @Nullable
@ -1221,7 +1221,7 @@ public class TimelineFragment extends SFragment implements
}
private List<Either<Placeholder, Status>> liftStatusList(List<Status> list) {
return CollectionUtil.map(list, statusLifter);
return CollectionsKt.map(list, statusLifter);
}
private void updateAdapter() {

View File

@ -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 <http://www.gnu.org/licenses>. */
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 <E, R> List<R> map(List<E> list, Function<E, R> mapper) {
final List<R> newList = new ArrayList<>(list.size());
for (E el : list) {
newList.add(mapper.apply(el));
}
return newList;
}
}