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