Remove stream library that is just used in 3 locations (#6976)
Especially on the SwipeActionsDialog, this is even a bit easier to understand.
This commit is contained in:
parent
393a8cebd3
commit
095a6b3e9d
|
@ -123,7 +123,6 @@ dependencies {
|
|||
implementation 'com.github.ByteHamster:SearchPreference:v2.5.0'
|
||||
implementation 'com.github.skydoves:balloon:1.5.3'
|
||||
implementation 'com.github.xabaras:RecyclerViewSwipeDecorator:1.3'
|
||||
implementation "com.annimon:stream:$annimonStreamVersion"
|
||||
|
||||
// Non-free dependencies:
|
||||
playImplementation 'com.google.android.play:core:1.8.0'
|
||||
|
|
|
@ -66,12 +66,6 @@
|
|||
website="https://jsoup.org/"
|
||||
license="MIT"
|
||||
licenseText="LICENSE_JSOUP.txt" />
|
||||
<library
|
||||
name="Lightweight-Stream-API"
|
||||
author="Victor Melnik"
|
||||
website="https://github.com/aNNiMON/Lightweight-Stream-API"
|
||||
license="Apache 2.0"
|
||||
licenseText="LICENSE_APACHE-2.0.txt" />
|
||||
<library
|
||||
name="Material Components for Android"
|
||||
author="Google"
|
||||
|
|
|
@ -13,8 +13,7 @@ import androidx.appcompat.content.res.AppCompatResources;
|
|||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
import androidx.gridlayout.widget.GridLayout;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
|
@ -29,8 +28,16 @@ import de.danoeh.antennapod.fragment.FeedItemlistFragment;
|
|||
import de.danoeh.antennapod.fragment.InboxFragment;
|
||||
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
|
||||
import de.danoeh.antennapod.fragment.QueueFragment;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.AddToQueueSwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.DeleteSwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.MarkFavoriteSwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.RemoveFromHistorySwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.RemoveFromInboxSwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.RemoveFromQueueSwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.StartDownloadSwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.SwipeAction;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.SwipeActions;
|
||||
import de.danoeh.antennapod.fragment.swipeactions.TogglePlaybackStateSwipeAction;
|
||||
import de.danoeh.antennapod.ui.common.ThemeUtils;
|
||||
|
||||
public class SwipeActionsDialog {
|
||||
|
@ -56,47 +63,54 @@ public class SwipeActionsDialog {
|
|||
|
||||
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
|
||||
|
||||
keys = SwipeActions.swipeActions;
|
||||
keys = new ArrayList<>();
|
||||
if (tag.equals(QueueFragment.TAG)) {
|
||||
keys.add(new RemoveFromQueueSwipeAction());
|
||||
} else {
|
||||
keys.add(new AddToQueueSwipeAction());
|
||||
}
|
||||
if (!tag.equals(CompletedDownloadsFragment.TAG)) {
|
||||
keys.add(new StartDownloadSwipeAction());
|
||||
}
|
||||
if (!tag.equals(CompletedDownloadsFragment.TAG)
|
||||
&& ! tag.equals(QueueFragment.TAG)
|
||||
&& !tag.equals(PlaybackHistoryFragment.TAG)) {
|
||||
keys.add(new RemoveFromInboxSwipeAction());
|
||||
}
|
||||
if (!tag.equals(InboxFragment.TAG)) {
|
||||
keys.add(new DeleteSwipeAction());
|
||||
}
|
||||
keys.add(new MarkFavoriteSwipeAction());
|
||||
if (tag.equals(PlaybackHistoryFragment.TAG)) {
|
||||
keys.add(new RemoveFromHistorySwipeAction());
|
||||
}
|
||||
if (!tag.equals(InboxFragment.TAG)) {
|
||||
keys.add(new TogglePlaybackStateSwipeAction());
|
||||
}
|
||||
|
||||
String forFragment = "";
|
||||
switch (tag) {
|
||||
case InboxFragment.TAG:
|
||||
forFragment = context.getString(R.string.inbox_label);
|
||||
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.TOGGLE_PLAYED)
|
||||
&& !a.getId().equals(SwipeAction.DELETE)
|
||||
&& !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
|
||||
break;
|
||||
case AllEpisodesFragment.TAG:
|
||||
forFragment = context.getString(R.string.episodes_label);
|
||||
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
|
||||
break;
|
||||
case CompletedDownloadsFragment.TAG:
|
||||
forFragment = context.getString(R.string.downloads_label);
|
||||
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_INBOX)
|
||||
&& !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)
|
||||
&& !a.getId().equals(SwipeAction.START_DOWNLOAD)).toList();
|
||||
break;
|
||||
case FeedItemlistFragment.TAG:
|
||||
forFragment = context.getString(R.string.individual_subscription);
|
||||
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
|
||||
break;
|
||||
case QueueFragment.TAG:
|
||||
forFragment = context.getString(R.string.queue_label);
|
||||
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.ADD_TO_QUEUE)
|
||||
&& !a.getId().equals(SwipeAction.REMOVE_FROM_INBOX)
|
||||
&& !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
|
||||
break;
|
||||
case PlaybackHistoryFragment.TAG:
|
||||
forFragment = context.getString(R.string.playback_history_label);
|
||||
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_INBOX)).toList();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (!tag.equals(QueueFragment.TAG)) {
|
||||
keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_QUEUE)).toList();
|
||||
}
|
||||
|
||||
builder.setTitle(context.getString(R.string.swipeactions_label) + " - " + forFragment);
|
||||
SwipeactionsDialogBinding viewBinding = SwipeactionsDialogBinding.inflate(LayoutInflater.from(context));
|
||||
builder.setView(viewBinding.getRoot());
|
||||
|
|
|
@ -13,8 +13,6 @@ import androidx.lifecycle.OnLifecycleEvent;
|
|||
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -37,12 +35,11 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life
|
|||
public static final String KEY_PREFIX_SWIPEACTIONS = "PrefSwipeActions";
|
||||
public static final String KEY_PREFIX_NO_ACTION = "PrefNoSwipeAction";
|
||||
|
||||
public static final List<SwipeAction> swipeActions = Collections.unmodifiableList(
|
||||
private static final List<SwipeAction> swipeActions = Collections.unmodifiableList(
|
||||
Arrays.asList(new AddToQueueSwipeAction(), new RemoveFromInboxSwipeAction(),
|
||||
new StartDownloadSwipeAction(), new MarkFavoriteSwipeAction(),
|
||||
new TogglePlaybackStateSwipeAction(), new RemoveFromQueueSwipeAction(),
|
||||
new DeleteSwipeAction(), new RemoveFromHistorySwipeAction())
|
||||
);
|
||||
new DeleteSwipeAction(), new RemoveFromHistorySwipeAction()));
|
||||
|
||||
private final Fragment fragment;
|
||||
private final String tag;
|
||||
|
@ -65,6 +62,15 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life
|
|||
this(0, fragment, tag);
|
||||
}
|
||||
|
||||
public static SwipeAction getAction(String key) {
|
||||
for (SwipeAction action : swipeActions) {
|
||||
if (action.getId().equals(key)) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_START)
|
||||
public void reloadPreference() {
|
||||
actions = getPrefs(fragment.requireContext(), tag);
|
||||
|
@ -255,10 +261,8 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life
|
|||
public Actions(String prefs) {
|
||||
String[] actions = prefs.split(",");
|
||||
if (actions.length == 2) {
|
||||
this.right = Stream.of(swipeActions)
|
||||
.filter(a -> a.getId().equals(actions[0])).single();
|
||||
this.left = Stream.of(swipeActions)
|
||||
.filter(a -> a.getId().equals(actions[1])).single();
|
||||
right = getAction(actions[0]);
|
||||
left = getAction(actions[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ project.ext {
|
|||
eventbusVersion = "3.3.1"
|
||||
rxAndroidVersion = "2.1.1"
|
||||
rxJavaVersion = "2.2.2"
|
||||
annimonStreamVersion = "1.2.2"
|
||||
|
||||
// Google Play build
|
||||
wearableSupportVersion = "2.6.0"
|
||||
|
|
|
@ -66,7 +66,6 @@ dependencies {
|
|||
annotationProcessor "org.greenrobot:eventbus-annotation-processor:$eventbusVersion"
|
||||
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
|
||||
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
|
||||
implementation "com.annimon:stream:$annimonStreamVersion"
|
||||
|
||||
// Non-free dependencies:
|
||||
playApi "com.google.android.support:wearable:$wearableSupportVersion"
|
||||
|
|
|
@ -11,8 +11,6 @@ import androidx.work.ForegroundInfo;
|
|||
import androidx.work.WorkManager;
|
||||
import androidx.work.Worker;
|
||||
import androidx.work.WorkerParameters;
|
||||
import com.annimon.stream.Collectors;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import de.danoeh.antennapod.core.ClientConfigurator;
|
||||
|
@ -104,11 +102,16 @@ public class FeedUpdateWorker extends Worker {
|
|||
private Notification createNotification(@Nullable List<Feed> toUpdate) {
|
||||
Context context = getApplicationContext();
|
||||
String contentText = "";
|
||||
String bigText = "";
|
||||
StringBuilder bigText = new StringBuilder();
|
||||
if (toUpdate != null) {
|
||||
contentText = context.getResources().getQuantityString(R.plurals.downloads_left,
|
||||
toUpdate.size(), toUpdate.size());
|
||||
bigText = Stream.of(toUpdate).map(feed -> "• " + feed.getTitle()).collect(Collectors.joining("\n"));
|
||||
for (int i = 0; i < toUpdate.size(); i++) {
|
||||
bigText.append("• ").append(toUpdate.get(i).getTitle());
|
||||
if (i != toUpdate.size() - 1) {
|
||||
bigText.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
return new NotificationCompat.Builder(context, NotificationUtils.CHANNEL_ID_DOWNLOADING)
|
||||
.setContentTitle(context.getString(R.string.download_notification_title_feeds))
|
||||
|
|
Loading…
Reference in New Issue