Fix lambdas

This commit is contained in:
TacoTheDank 2020-07-11 20:01:57 -04:00
parent fa30bc5447
commit 002ba1753d
7 changed files with 22 additions and 37 deletions

View File

@ -106,9 +106,7 @@ public class DownloadServiceTest {
// OPEN: Ideally, I'd like the download time long enough so that multiple in-progress DownloadEvents
// are generated (to simulate typical download), but it'll make download time quite long (1-2 seconds)
// to do so
DownloadService.setDownloaderFactory(new StubDownloaderFactory(50, downloadStatus -> {
downloadStatus.setSuccessful();
}));
DownloadService.setDownloaderFactory(new StubDownloaderFactory(50, DownloadStatus::setSuccessful));
UserPreferences.setEnqueueDownloadedEpisodes(enqueueDownloaded);
withFeedItemEventListener(feedItemEventListener -> {
@ -146,9 +144,8 @@ public class DownloadServiceTest {
private void doTestCancelDownload_UndoEnqueue(boolean itemAlreadyInQueue) throws Exception {
Context context = InstrumentationRegistry.getTargetContext();
// let download take longer to ensure the test can cancel the download in time
DownloadService.setDownloaderFactory(new StubDownloaderFactory(30000, downloadStatus -> {
downloadStatus.setSuccessful();
}));
DownloadService.setDownloaderFactory(
new StubDownloaderFactory(30000, DownloadStatus::setSuccessful));
UserPreferences.setEnqueueDownloadedEpisodes(true);
UserPreferences.setEnableAutodownload(false);

View File

@ -42,9 +42,8 @@ public class BugReportActivity extends AppCompatActivity {
}
crashDetailsTextView.setText(crashDetailsText);
findViewById(R.id.btn_open_bug_tracker).setOnClickListener(v -> {
IntentUtils.openInBrowser(BugReportActivity.this, "https://github.com/AntennaPod/AntennaPod/issues");
});
findViewById(R.id.btn_open_bug_tracker).setOnClickListener(v -> IntentUtils.openInBrowser(
BugReportActivity.this, "https://github.com/AntennaPod/AntennaPod/issues"));
findViewById(R.id.btn_copy_log).setOnClickListener(v -> {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

View File

@ -51,9 +51,7 @@ public abstract class FilterDialog {
filterValues.remove(values[which]);
}
});
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
updateFilter(filterValues);
});
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> updateFilter(filterValues));
builder.setNegativeButton(R.string.cancel_label, null);
builder.create().show();
}

View File

@ -2,7 +2,6 @@ package de.danoeh.antennapod.dialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
@ -68,24 +67,17 @@ public class ShareDialog extends DialogFragment {
setupOptions();
builder.setPositiveButton(R.string.share_label, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
boolean includePlaybackPosition = checkBoxStartAt.isChecked();
if (radioEpisodeWebsite.isChecked()) {
ShareUtils.shareFeedItemLink(ctx, item, includePlaybackPosition);
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "website").apply();
} else {
ShareUtils.shareFeedItemDownloadLink(ctx, item, includePlaybackPosition);
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "media").apply();
}
prefs.edit().putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition).apply();
builder.setPositiveButton(R.string.share_label, (dialog, id) -> {
boolean includePlaybackPosition = checkBoxStartAt.isChecked();
if (radioEpisodeWebsite.isChecked()) {
ShareUtils.shareFeedItemLink(ctx, item, includePlaybackPosition);
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "website").apply();
} else {
ShareUtils.shareFeedItemDownloadLink(ctx, item, includePlaybackPosition);
prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "media").apply();
}
}).setNegativeButton(R.string.cancel_label, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
prefs.edit().putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition).apply();
}).setNegativeButton(R.string.cancel_label, (dialog, id) -> dialog.dismiss());
return builder.create();
}

View File

@ -85,9 +85,8 @@ public class NavDrawerFragment extends Fragment implements AdapterView.OnItemCli
registerForContextMenu(navList);
updateSelection();
root.findViewById(R.id.nav_settings).setOnClickListener(v -> {
startActivity(new Intent(getActivity(), PreferenceActivity.class));
});
root.findViewById(R.id.nav_settings).setOnClickListener(v ->
startActivity(new Intent(getActivity(), PreferenceActivity.class)));
getContext().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
.registerOnSharedPreferenceChangeListener(this);
return root;

View File

@ -118,9 +118,8 @@ public class AutoUpdateManager {
*/
public static void runImmediate(@NonNull Context context) {
Log.d(TAG, "Run auto update immediately in background.");
new Thread(() -> {
DBTasks.refreshAllFeeds(context.getApplicationContext(), true);
}, "ManualRefreshAllFeeds").start();
new Thread(() -> DBTasks.refreshAllFeeds(
context.getApplicationContext(), true), "ManualRefreshAllFeeds").start();
}
public static void disableAutoUpdate(Context context) {

View File

@ -13,6 +13,7 @@ import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import de.danoeh.antennapod.core.feed.FeedComponent;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.feed.FeedMother;
@ -254,7 +255,7 @@ public class ItemEnqueuePositionCalculatorTest {
Collections.unmodifiableList(Arrays.asList(
createFeedItem(11), createFeedItem(12), createFeedItem(13), createFeedItem(14)));
static final List<Long> QUEUE_DEFAULT_IDS =
QUEUE_DEFAULT.stream().map(fi -> fi.getId()).collect(Collectors.toList());
QUEUE_DEFAULT.stream().map(FeedComponent::getId).collect(Collectors.toList());
static Playable getCurrentlyPlaying(long idCurrentlyPlaying) {