diff options
author | Domingos Lopes <domingos86lopes@gmail.com> | 2016-03-22 02:07:26 -0400 |
---|---|---|
committer | Domingos Lopes <domingos86lopes@gmail.com> | 2016-03-22 02:07:26 -0400 |
commit | a252191d79f09c0f06cf13a700dd48dfdefd3fe4 (patch) | |
tree | 798bf1a99a85f634aece0c88a252b4e550d50193 /app/src/main/java/de | |
parent | 5febe9248ab679a37e48c9f1ff46ca643a889510 (diff) | |
download | AntennaPod-a252191d79f09c0f06cf13a700dd48dfdefd3fe4.zip |
code cleaning:
- lambda expressions, method references,
- multi catches,
- remove unnecessary keywords (public keyword on interface method signatures, static on interfaces or enums, final on private method signatures),
- == false expressions,
- diamond type (<>) expressions,
- replace StringBuffer with StringBuilder for local variables used by a single thread,
- replace Arrays.asList with Collections.singletonList whenever applicable,
- inline variable returns (whenever the variable name's meaning is not important to understand the code),
- replace some chains of if/else if/... with switch/case,
- break append(a + b) into append(a).append(b) for StringBuilder objects,
- unused import statements,
- reduce log TAGs to 23 characters,
- MaterialDialog callback deprecated,
- ActionBarActivity for AppCompatActivity,
Diffstat (limited to 'app/src/main/java/de')
55 files changed, 210 insertions, 382 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java index c835f8073..eef2fa4da 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AboutActivity.java @@ -4,7 +4,7 @@ import android.content.res.TypedArray; import android.graphics.Color; import android.os.Build; import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.MenuItem; import android.view.View; @@ -30,7 +30,7 @@ import rx.schedulers.Schedulers; /** * Displays the 'about' screen */ -public class AboutActivity extends ActionBarActivity { +public class AboutActivity extends AppCompatActivity { private static final String TAG = AboutActivity.class.getSimpleName(); @@ -87,7 +87,7 @@ public class AboutActivity extends ActionBarActivity { res.recycle(); input = getAssets().open(filename); String webViewData = IOUtils.toString(input, Charset.defaultCharset()); - if(false == webViewData.startsWith("<!DOCTYPE html>")) { + if(!webViewData.startsWith("<!DOCTYPE html>")) { //webViewData = webViewData.replace("\n\n", "</p><p>"); webViewData = webViewData.replace("%", "%"); webViewData = diff --git a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java index e90681931..107afcbfe 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/AudioplayerActivity.java @@ -341,11 +341,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe @Override public boolean onOptionsItemSelected(MenuItem item) { - if (drawerToggle != null && drawerToggle.onOptionsItemSelected(item)) { - return true; - } else { - return super.onOptionsItemSelected(item); - } + return drawerToggle != null && drawerToggle.onOptionsItemSelected(item) || super.onOptionsItemSelected(item); } @Override @@ -464,7 +460,7 @@ public class AudioplayerActivity extends MediaplayerActivity implements NavDrawe private DBReader.NavDrawerData navDrawerData; private void loadData() { - subscription = Observable.fromCallable(() -> DBReader.getNavDrawerData()) + subscription = Observable.fromCallable(DBReader::getNavDrawerData) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/activity/DirectoryChooserActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/DirectoryChooserActivity.java index 62e85120d..5fd69ef6a 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/DirectoryChooserActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/DirectoryChooserActivity.java @@ -243,7 +243,7 @@ public class DirectoryChooserActivity extends AppCompatActivity { @Override public void onEvent(int event, String path) { Log.d(TAG, "FileObserver received event " + event); - runOnUiThread(() -> refreshDirectory()); + runOnUiThread(DirectoryChooserActivity.this::refreshDirectory); } }; } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java index 365c4216d..41b2debdc 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/DownloadAuthenticationActivity.java @@ -5,7 +5,6 @@ import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.util.Log; -import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; @@ -73,31 +72,25 @@ public class DownloadAuthenticationActivity extends ActionBarActivity { txtvDescription.setText(txtvDescription.getText() + ":\n\n" + request.getTitle()); - butCancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - setResult(Activity.RESULT_CANCELED); - finish(); - } + butCancel.setOnClickListener(v -> { + setResult(Activity.RESULT_CANCELED); + finish(); }); - butConfirm.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String username = etxtUsername.getText().toString(); - String password = etxtPassword.getText().toString(); - request.setUsername(username); - request.setPassword(password); - Intent result = new Intent(); - result.putExtra(RESULT_REQUEST, request); - setResult(Activity.RESULT_OK, result); - - if (sendToDownloadRequester) { - if (BuildConfig.DEBUG) Log.d(TAG, "Sending request to DownloadRequester"); - DownloadRequester.getInstance().download(DownloadAuthenticationActivity.this, request); - } - finish(); + butConfirm.setOnClickListener(v -> { + String username = etxtUsername.getText().toString(); + String password = etxtPassword.getText().toString(); + request.setUsername(username); + request.setPassword(password); + Intent result = new Intent(); + result.putExtra(RESULT_REQUEST, request); + setResult(Activity.RESULT_OK, result); + + if (sendToDownloadRequester) { + if (BuildConfig.DEBUG) Log.d(TAG, "Sending request to DownloadRequester"); + DownloadRequester.getInstance().download(DownloadAuthenticationActivity.this, request); } + finish(); }); } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java index 9116decb0..805d82cf9 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FeedInfoActivity.java @@ -139,20 +139,14 @@ public class FeedInfoActivity extends ActionBarActivity { Log.d(TAG, "Author is " + feed.getAuthor()); Log.d(TAG, "URL is " + feed.getDownload_url()); FeedPreferences prefs = feed.getPreferences(); - imgvCover.post(new Runnable() { - - @Override - public void run() { - Glide.with(FeedInfoActivity.this) - .load(feed.getImageUri()) - .placeholder(R.color.light_gray) - .error(R.color.light_gray) - .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) - .fitCenter() - .dontAnimate() - .into(imgvCover); - } - }); + imgvCover.post(() -> Glide.with(FeedInfoActivity.this) + .load(feed.getImageUri()) + .placeholder(R.color.light_gray) + .error(R.color.light_gray) + .diskCacheStrategy(ApGlideSettings.AP_DISK_CACHE_STRATEGY) + .fitCenter() + .dontAnimate() + .into(imgvCover)); txtvTitle.setText(feed.getTitle()); String description = feed.getDescription(); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/FlattrAuthActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/FlattrAuthActivity.java index 3b10ba4c3..be1c9f9e6 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/FlattrAuthActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/FlattrAuthActivity.java @@ -9,17 +9,17 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; + +import org.shredzone.flattr4j.exception.FlattrException; + import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.util.flattr.FlattrUtils; import de.danoeh.antennapod.preferences.PreferenceController; -import org.shredzone.flattr4j.exception.FlattrException; - /** Guides the user through the authentication process */ public class FlattrAuthActivity extends ActionBarActivity { @@ -46,25 +46,19 @@ public class FlattrAuthActivity extends ActionBarActivity { butAuthenticate = (Button) findViewById(R.id.but_authenticate); butReturn = (Button) findViewById(R.id.but_return_home); - butReturn.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(FlattrAuthActivity.this, MainActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - } - }); + butReturn.setOnClickListener(v -> { + Intent intent = new Intent(FlattrAuthActivity.this, MainActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + }); - butAuthenticate.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - try { - FlattrUtils.startAuthProcess(FlattrAuthActivity.this); - } catch (FlattrException e) { - e.printStackTrace(); - } - } - }); + butAuthenticate.setOnClickListener(v -> { + try { + FlattrUtils.startAuthProcess(FlattrAuthActivity.this); + } catch (FlattrException e) { + e.printStackTrace(); + } + }); } public static FlattrAuthActivity getInstance() { diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 3ab6a0ab8..9b0733b43 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -657,7 +657,7 @@ public class MainActivity extends AppCompatActivity implements NavDrawerActivity }; private void loadData() { - subscription = Observable.fromCallable(() -> DBReader.getNavDrawerData()) + subscription = Observable.fromCallable(DBReader::getNavDrawerData) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java index f02f87d06..50daf163f 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -387,18 +387,11 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O .getSleepTimerTimeLeft())); stDialog.positiveText(R.string.disable_sleeptimer_label); stDialog.negativeText(R.string.cancel_label); - stDialog.callback(new MaterialDialog.ButtonCallback() { - @Override - public void onPositive(MaterialDialog dialog) { - dialog.dismiss(); - controller.disableSleepTimer(); - } - - @Override - public void onNegative(MaterialDialog dialog) { - dialog.dismiss(); - } + stDialog.onPositive((dialog, which) -> { + dialog.dismiss(); + controller.disableSleepTimer(); }); + stDialog.onNegative((dialog, which) -> dialog.dismiss()); stDialog.build().show(); } break; @@ -464,9 +457,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O txtvPlaybackSpeed.setText(speedStr); } else if(fromUser) { float speed = Float.valueOf(UserPreferences.getPlaybackSpeed()); - barPlaybackSpeed.post(() -> { - barPlaybackSpeed.setProgress((int) (20 * speed) - 10); - }); + barPlaybackSpeed.post(() -> barPlaybackSpeed.setProgress((int) (20 * speed) - 10)); } } @@ -748,9 +739,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O } if (butRev != null) { - butRev.setOnClickListener(v -> { - onRewind(); - }); + butRev.setOnClickListener(v -> onRewind()); butRev.setOnLongClickListener(new View.OnLongClickListener() { int choice; @@ -787,14 +776,10 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O }); } - butPlay.setOnClickListener(v -> { - onPlayPause(); - }); + butPlay.setOnClickListener(v -> onPlayPause()); if (butFF != null) { - butFF.setOnClickListener(v -> { - onFastForward(); - }); + butFF.setOnClickListener(v -> onFastForward()); butFF.setOnLongClickListener(new View.OnLongClickListener() { int choice; @@ -832,9 +817,7 @@ public abstract class MediaplayerActivity extends AppCompatActivity implements O } if (butSkip != null) { - butSkip.setOnClickListener(v -> { - sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE)); - }); + butSkip.setOnClickListener(v -> sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE))); } } diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index 60d671898..a53f9bdb8 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -7,8 +7,8 @@ import android.content.Intent; import android.os.Bundle; import android.os.Looper; import android.support.v4.app.NavUtils; -import android.support.v7.app.ActionBarActivity; import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; @@ -79,7 +79,7 @@ import rx.schedulers.Schedulers; * If the feed cannot be downloaded or parsed, an error dialog will be displayed * and the activity will finish as soon as the error dialog is closed. */ -public class OnlineFeedViewActivity extends ActionBarActivity { +public class OnlineFeedViewActivity extends AppCompatActivity { private static final String TAG = "OnlineFeedViewActivity"; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java index bc3e686e5..bc1a40b11 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlFeedChooserActivity.java @@ -2,7 +2,7 @@ package de.danoeh.antennapod.activity; import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.util.SparseBooleanArray; import android.view.Menu; import android.view.MenuInflater; @@ -22,7 +22,7 @@ import de.danoeh.antennapod.core.preferences.UserPreferences; * Displays the feeds that the OPML-Importer has read and lets the user choose * which feeds he wants to import. */ -public class OpmlFeedChooserActivity extends ActionBarActivity { +public class OpmlFeedChooserActivity extends AppCompatActivity { private static final String TAG = "OpmlFeedChooserActivity"; public static final String EXTRA_SELECTED_ITEMS = "de.danoeh.antennapod.selectedItems"; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportBaseActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportBaseActivity.java index fb145db1f..8726af281 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportBaseActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportBaseActivity.java @@ -6,7 +6,7 @@ import android.net.Uri; import android.os.Environment; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.util.Log; import com.afollestad.materialdialogs.MaterialDialog; @@ -26,7 +26,7 @@ import de.danoeh.antennapod.core.util.LangUtils; /** * Base activity for Opml Import - e.g. with code what to do afterwards * */ -public class OpmlImportBaseActivity extends ActionBarActivity { +public class OpmlImportBaseActivity extends AppCompatActivity { private static final String TAG = "OpmlImportBaseActivity"; private OpmlImportWorker importWorker; diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java index 15d97cc2c..b781e5141 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OpmlImportFromPathActivity.java @@ -53,7 +53,7 @@ public class OpmlImportFromPathActivity extends OpmlImportBaseActivity { intentPickAction = new Intent(Intent.ACTION_PICK); intentPickAction.setData(Uri.parse("file://")); - if(false == IntentUtils.isCallable(getApplicationContext(), intentPickAction)) { + if(!IntentUtils.isCallable(getApplicationContext(), intentPickAction)) { intentPickAction.setData(null); if(false == IntentUtils.isCallable(getApplicationContext(), intentPickAction)) { txtvHeaderExplanation1.setVisibility(View.GONE); @@ -70,7 +70,7 @@ public class OpmlImportFromPathActivity extends OpmlImportBaseActivity { intentGetContentAction = new Intent(Intent.ACTION_GET_CONTENT); intentGetContentAction.addCategory(Intent.CATEGORY_OPENABLE); intentGetContentAction.setType("*/*"); - if(false == IntentUtils.isCallable(getApplicationContext(), intentGetContentAction)) { + if(!IntentUtils.isCallable(getApplicationContext(), intentGetContentAction)) { txtvHeaderExplanation2.setVisibility(View.GONE); txtvExplanation2.setVisibility(View.GONE); findViewById(R.id.divider2).setVisibility(View.GONE); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java index 80ccb7c99..ba22a42b4 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/PreferenceActivity.java @@ -8,7 +8,7 @@ import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceFragment; import android.support.v7.app.ActionBar; -import android.support.v7.app.ActionBarActivity; +import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.ViewGroup; @@ -24,7 +24,7 @@ import de.danoeh.antennapod.preferences.PreferenceController; * PreferenceActivity for API 11+. In order to change the behavior of the preference UI, see * PreferenceController. */ -public class PreferenceActivity extends ActionBarActivity { +public class PreferenceActivity extends AppCompatActivity { private PreferenceController preferenceController; private MainFragment prefFragment; @@ -49,7 +49,7 @@ public class PreferenceActivity extends ActionBarActivity { protected void onCreate(Bundle savedInstanceState) { // This must be the FIRST thing we do, otherwise other code may not have the // reference it needs - instance = new WeakReference<PreferenceActivity>(this); + instance = new WeakReference<>(this); setTheme(UserPreferences.getTheme()); super.onCreate(savedInstanceState); diff --git a/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java index 28c2b7206..e5418c924 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java @@ -5,7 +5,6 @@ import android.content.Intent; import android.content.res.Configuration; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v4.app.NavUtils; import android.support.v7.app.ActionBarActivity; import android.util.Log; import android.view.LayoutInflater; @@ -42,7 +41,7 @@ import de.danoeh.antennapod.core.service.GpodnetSyncService; * Step 3: Choose from a list of actions */ public class GpodnetAuthenticationActivity extends ActionBarActivity { - private static final String TAG = "GpodnetAuthenticationActivity"; + private static final String TAG = "GpodnetAuthActivity"; private static final String CURRENT_STEP = "current_step"; @@ -177,7 +176,7 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity { // load device list - final AtomicReference<List<GpodnetDevice>> devices = new AtomicReference<List<GpodnetDevice>>(); + final AtomicReference<List<GpodnetDevice>> devices = new AtomicReference<>(); new AsyncTask<GpodnetService, Void, List<GpodnetDevice>>() { private volatile Exception exception; @@ -194,11 +193,11 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity { protected void onPostExecute(List<GpodnetDevice> gpodnetDevices) { super.onPostExecute(gpodnetDevices); if (gpodnetDevices != null) { - List<String> deviceNames = new ArrayList<String>(); + List<String> deviceNames = new ArrayList<>(); for (GpodnetDevice device : gpodnetDevices) { deviceNames.add(device.getCaption()); } - spinnerDevices.setAdapter(new ArrayAdapter<String>(GpodnetAuthenticationActivity.this, + spinnerDevices.setAdapter(new ArrayAdapter<>(GpodnetAuthenticationActivity.this, android.R.layout.simple_spinner_dropdown_item, deviceNames)); spinnerDevices.setEnabled(true); if (!deviceNames.isEmpty()) { @@ -274,14 +273,11 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity { }); deviceID.setText(generateDeviceID()); - chooseDevice.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - final int position = spinnerDevices.getSelectedItemPosition(); - if (position != AdapterView.INVALID_POSITION) { - selectedDevice = devices.get().get(position); - advance(); - } + chooseDevice.setOnClickListener(v -> { + final int position = spinnerDevices.getSelectedItemPosition(); + if (position != AdapterView.INVALID_POSITION) { + selectedDevice = devices.get().get(position); + advance(); } }); } @@ -325,20 +321,14 @@ public class GpodnetAuthenticationActivity extends ActionBarActivity { final Button sync = (Button) view.findViewById(R.id.butSyncNow); final Button back = (Button) view.findViewById(R.id.butGoMainscreen); - sync.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - GpodnetSyncService.sendSyncIntent(GpodnetAuthenticationActivity.this); - finish(); - } + sync.setOnClickListener(v -> { + GpodnetSyncService.sendSyncIntent(GpodnetAuthenticationActivity.this); + finish(); }); - back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(GpodnetAuthenticationActivity.this, MainActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - } + back.setOnClickListener(v -> { + Intent intent = new Intent(GpodnetAuthenticationActivity.this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); }); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonCallback.java b/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonCallback.java index a75789815..66e6f9a00 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonCallback.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/ActionButtonCallback.java @@ -4,5 +4,5 @@ import de.danoeh.antennapod.core.feed.FeedItem; public interface ActionButtonCallback { /** Is called when the action button of a list item has been pressed. */ - abstract void onActionButtonPressed(FeedItem item); + void onActionButtonPressed(FeedItem item); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/AdapterUtils.java b/app/src/main/java/de/danoeh/antennapod/adapter/AdapterUtils.java index 935a0dcd4..8aaf0055a 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/AdapterUtils.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/AdapterUtils.java @@ -50,7 +50,7 @@ public class AdapterUtils { Log.d(TAG, "size: " + media.getSize()); if (media.getSize() > 0) { txtvPos.setText(Converter.byteToString(media.getSize())); - } else if(NetworkUtils.isDownloadAllowed() && false == media.checkedOnSizeButUnknown()) { + } else if(NetworkUtils.isDownloadAllowed() && !media.checkedOnSizeButUnknown()) { txtvPos.setText("{fa-spinner}"); Iconify.addIcons(txtvPos); NetworkUtils.getFeedMediaSizeObservable(media) diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java index 07f895468..d141e0239 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/AllEpisodesRecycleAdapter.java @@ -121,7 +121,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR holder.title.setText(item.getTitle()); String pubDateStr = DateUtils.formatAbbrev(mainActivityRef.get(), item.getPubDate()); holder.pubDate.setText(pubDateStr); - if (showOnlyNewEpisodes || false == item.isNew()) { + if (showOnlyNewEpisodes || !item.isNew()) { holder.statusUnread.setVisibility(View.INVISIBLE); } else { holder.statusUnread.setVisibility(View.VISIBLE); @@ -135,7 +135,7 @@ public class AllEpisodesRecycleAdapter extends RecyclerView.Adapter<AllEpisodesR holder.txtvDuration.setText(Converter.getDurationStringLong(media.getDuration())); } else if (media.getSize() > 0) { holder.txtvDuration.setText(Converter.byteToString(media.getSize())); - } else if(NetworkUtils.isDownloadAllowed() && false == media.checkedOnSizeButUnknown()) { + } else if(NetworkUtils.isDownloadAllowed() && !media.checkedOnSizeButUnknown()) { holder.txtvDuration.setText("{fa-spinner}"); Iconify.addIcons(holder.txtvDuration); NetworkUtils.getFeedMediaSizeObservable(media) diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java index 8bde1097b..df9fce6d2 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/ChaptersListAdapter.java @@ -109,7 +109,7 @@ public class ChaptersListAdapter extends ArrayAdapter<Chapter> { if (link.length != 0) { if (action == MotionEvent.ACTION_UP) { link[0].onClick(widget); - } else if (action == MotionEvent.ACTION_DOWN) { + } else { Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0])); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java index 469a807e1..00ab96f6c 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java @@ -1,9 +1,7 @@ package de.danoeh.antennapod.adapter; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; -import android.support.v7.app.AlertDialog; import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java index 34999757f..a017983f0 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -11,7 +11,6 @@ import android.widget.BaseAdapter; import android.widget.TextView; import android.widget.Toast; -import com.joanzapata.iconify.Iconify; import com.joanzapata.iconify.widget.IconButton; import com.joanzapata.iconify.widget.IconTextView; diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java index 4a0ff1f12..e1efdaa7b 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadlistAdapter.java @@ -131,11 +131,11 @@ public class DownloadlistAdapter extends BaseAdapter { } public interface ItemAccess { - public int getCount(); + int getCount(); - public Downloader getItem(int position); + Downloader getItem(int position); - public void onSecondaryActionClick(Downloader downloader); + void onSecondaryActionClick(Downloader downloader); } } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index 6d7e6dcac..ec1e18ee8 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -73,7 +73,7 @@ public class NavListAdapter extends BaseAdapter } private void loadItems() { - List<String> newTags = new ArrayList<String>(Arrays.asList(MainActivity.NAV_DRAWER_TAGS)); + List<String> newTags = new ArrayList<>(Arrays.asList(MainActivity.NAV_DRAWER_TAGS)); List<String> hiddenFragments = UserPreferences.getHiddenDrawerItems(); for(String hidden : hiddenFragments) { newTags.remove(hidden); @@ -236,13 +236,13 @@ public class NavListAdapter extends BaseAdapter holder.count.setText("{md-disc-full 150%}"); Iconify.addIcons(holder.count); holder.count.setVisibility(View.VISIBLE); - holder.count.setOnClickListener(v -> { + holder.count.setOnClickListener(v -> new AlertDialog.Builder(context) .setTitle(R.string.episode_cache_full_title) .setMessage(R.string.episode_cache_full_message) .setPositiveButton(android.R.string.ok, (dialog, which) -> {}) - .show(); - }); + .show() + ); } else { holder.count.setVisibility(View.GONE); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java index 6cf61f90b..981d7563a 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/QueueRecyclerAdapter.java @@ -258,7 +258,7 @@ public class QueueRecyclerAdapter extends RecyclerView.Adapter<QueueRecyclerAdap } else { if(media.getSize() > 0) { progressLeft.setText(Converter.byteToString(media.getSize())); - } else if(NetworkUtils.isDownloadAllowed() && false == media.checkedOnSizeButUnknown()) { + } else if(NetworkUtils.isDownloadAllowed() && !media.checkedOnSizeButUnknown()) { progressLeft.setText("{fa-spinner}"); Iconify.addIcons(progressLeft); NetworkUtils.getFeedMediaSizeObservable(media) diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java index 83f5dcb4d..c15dd4ac6 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SearchlistAdapter.java @@ -9,7 +9,6 @@ import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; -import com.bumptech.glide.load.engine.DiskCacheStrategy; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.Feed; @@ -112,7 +111,7 @@ public class SearchlistAdapter extends BaseAdapter { TextView subtitle; } - public static interface ItemAccess { + public interface ItemAccess { int getCount(); SearchResult getItem(int position); diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java index 743f9fc86..aea3d583f 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/gpodnet/PodcastListAdapter.java @@ -9,7 +9,6 @@ import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; -import com.bumptech.glide.load.engine.DiskCacheStrategy; import org.apache.commons.lang3.StringUtils; diff --git a/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlExportWorker.java b/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlExportWorker.java index 5c24c2822..13abb26ea 100644 --- a/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlExportWorker.java +++ b/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlExportWorker.java @@ -3,7 +3,6 @@ package de.danoeh.antennapod.asynctask; import android.annotation.SuppressLint; import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; @@ -80,14 +79,7 @@ public class OpmlExportWorker extends AsyncTask<Void, Void, Void> { progDialog.dismiss(); AlertDialog.Builder alert = new AlertDialog.Builder(context) .setNeutralButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, - int which) { - dialog.dismiss(); - } - }); + (dialog, which) -> dialog.dismiss()); if (exception != null) { alert.setTitle(R.string.export_error_label); alert.setMessage(exception.getMessage()); diff --git a/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java b/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java index cc27b6c9d..1cb653f01 100644 --- a/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java +++ b/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlFeedQueuer.java @@ -43,9 +43,8 @@ public class OpmlFeedQueuer extends AsyncTask<Void, Void, Void> { @Override protected Void doInBackground(Void... params) { DownloadRequester requester = DownloadRequester.getInstance(); - for (int idx = 0; idx < selection.length; idx++) { - OpmlElement element = OpmlImportHolder.getReadElements().get( - selection[idx]); + for (int selected : selection) { + OpmlElement element = OpmlImportHolder.getReadElements().get(selected); Feed feed = new Feed(element.getXmlUrl(), null, element.getText()); try { diff --git a/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlImportWorker.java b/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlImportWorker.java index 86636485d..45ec6c5fa 100644 --- a/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlImportWorker.java +++ b/app/src/main/java/de/danoeh/antennapod/asynctask/OpmlImportWorker.java @@ -3,21 +3,20 @@ package de.danoeh.antennapod.asynctask; import android.annotation.SuppressLint; import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; import android.os.AsyncTask; import android.support.v7.app.AlertDialog; import android.util.Log; -import de.danoeh.antennapod.core.BuildConfig; -import de.danoeh.antennapod.core.R; -import de.danoeh.antennapod.core.opml.OpmlElement; -import de.danoeh.antennapod.core.opml.OpmlReader; + import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; +import de.danoeh.antennapod.core.R; +import de.danoeh.antennapod.core.opml.OpmlElement; +import de.danoeh.antennapod.core.opml.OpmlReader; + public class OpmlImportWorker extends AsyncTask<Void, Void, ArrayList<OpmlElement>> { private static final String TAG = "OpmlImportWorker"; diff --git a/app/src/main/java/de/danoeh/antennapod/config/DBTasksCallbacksImpl.java b/app/src/main/java/de/danoeh/antennapod/config/DBTasksCallbacksImpl.java index 9f8af1142..c3f7ae9c8 100644 --- a/app/src/main/java/de/danoeh/antennapod/config/DBTasksCallbacksImpl.java +++ b/app/src/main/java/de/danoeh/antennapod/config/DBTasksCallbacksImpl.java @@ -2,7 +2,6 @@ package de.danoeh.antennapod.config; import de.danoeh.antennapod.core.DBTasksCallbacks; import de.danoeh.antennapod.core.preferences.UserPreferences; -import de.danoeh.antennapod.core.storage.APCleanupAlgorithm; import de.danoeh.antennapod.core.storage.APDownloadAlgorithm; import de.danoeh.antennapod.core.storage.AutomaticDownloadAlgorithm; import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java index bdb2d68ba..6f9e221ec 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/AuthenticationDialog.java @@ -2,13 +2,13 @@ package de.danoeh.antennapod.dialog; import android.app.Dialog; import android.content.Context; -import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.view.Window; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; + import de.danoeh.antennapod.R; /** @@ -58,26 +58,13 @@ public abstract class AuthenticationDialog extends Dialog { if (passwordInitialValue != null) { etxtPassword.setText(passwordInitialValue); } - setOnCancelListener(new OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - onCancelled(); - } - }); - butCancel.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - cancel(); - } - }); - butConfirm.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - onConfirmed(etxtUsername.getText().toString(), - etxtPassword.getText().toString(), - showSaveCredentialsCheckbox && saveUsernamePassword.isChecked()); - dismiss(); - } + setOnCancelListener(dialog -> onCancelled()); + butCancel.setOnClickListener(v -> cancel()); + butConfirm.setOnClickListener(v -> { + onConfirmed(etxtUsername.getText().toString(), + etxtPassword.getText().toString(), + showSaveCredentialsCheckbox && saveUsernamePassword.isChecked()); + dismiss(); }); } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/AutoFlattrPreferenceDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/AutoFlattrPreferenceDialog.java index 75b1bc8d2..93425949c 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/AutoFlattrPreferenceDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/AutoFlattrPreferenceDialog.java @@ -3,7 +3,6 @@ package de.danoeh.antennapod.dialog; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; -import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.CheckBox; @@ -42,12 +41,9 @@ public class AutoFlattrPreferenceDialog { setStatusMsgText(activity, txtvStatus, initialValue); skbPercent.setProgress(initialValue); - chkAutoFlattr.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - skbPercent.setEnabled(chkAutoFlattr.isChecked()); - txtvStatus.setEnabled(chkAutoFlattr.isChecked()); - } + chkAutoFlattr.setOnClickListener(v -> { + skbPercent.setEnabled(chkAutoFlattr.isChecked()); + txtvStatus.setEnabled(chkAutoFlattr.isChecked()); }); skbPercent.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @@ -69,20 +65,14 @@ public class AutoFlattrPreferenceDialog { builder.setTitle(R.string.pref_auto_flattr_title) .setView(view) - .setPositiveButton(R.string.confirm_label, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - float progDouble = ((float) skbPercent.getProgress()) / 100.0f; - callback.onConfirmed(chkAutoFlattr.isChecked(), progDouble); - dialog.dismiss(); - } + .setPositiveButton(R.string.confirm_label, (dialog, which) -> { + float progDouble = ((float) skbPercent.getProgress()) / 100.0f; + callback.onConfirmed(chkAutoFlattr.isChecked(), progDouble); + dialog.dismiss(); }) - .setNegativeButton(R.string.cancel_label, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - callback.onCancelled(); - dialog.dismiss(); - } + .setNegativeButton(R.string.cancel_label, (dialog, which) -> { + callback.onCancelled(); + dialog.dismiss(); }) .setCancelable(false).show(); } @@ -97,10 +87,10 @@ public class AutoFlattrPreferenceDialog { } } - public static interface AutoFlattrPreferenceDialogInterface { - public void onCancelled(); + public interface AutoFlattrPreferenceDialogInterface { + void onCancelled(); - public void onConfirmed(boolean autoFlattrEnabled, float autoFlattrValue); + void onConfirmed(boolean autoFlattrEnabled, float autoFlattrValue); } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java index ac7a9efee..577a3ecbe 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java @@ -54,7 +54,7 @@ public class EpisodesApplyActionFragment extends Fragment { private final Map<Long,FeedItem> idMap = new ArrayMap<>(); private final List<FeedItem> episodes = new ArrayList<>(); private int actions; - private final List<String> titles = new ArrayList(); + private final List<String> titles = new ArrayList<>(); private final LongList checkedIds = new LongList(); private MenuItem mSelectToggle; @@ -285,9 +285,9 @@ public class EpisodesApplyActionFragment extends Fragment { private void sortByDuration(final boolean reverse) { Collections.sort(episodes, (lhs, rhs) -> { int ordering; - if (false == lhs.hasMedia()) { + if (!lhs.hasMedia()) { ordering = 1; - } else if (false == rhs.hasMedia()) { + } else if (!rhs.hasMedia()) { ordering = -1; } else { ordering = lhs.getMedia().getDuration() - rhs.getMedia().getDuration(); @@ -304,7 +304,7 @@ public class EpisodesApplyActionFragment extends Fragment { private void checkAll() { for (FeedItem episode : episodes) { - if(false == checkedIds.contains(episode.getId())) { + if(!checkedIds.contains(episode.getId())) { checkedIds.add(episode.getId()); } } @@ -391,14 +391,14 @@ public class EpisodesApplyActionFragment extends Fragment { private void downloadChecked() { // download the check episodes in the same order as they are currently displayed - List<FeedItem> toDownload = new ArrayList<FeedItem>(checkedIds.size()); + List<FeedItem> toDownload = new ArrayList<>(checkedIds.size()); for(FeedItem episode : episodes) { if(checkedIds.contains(episode.getId())) { toDownload.add(episode); } } try { - DBTasks.downloadFeedItems(getActivity(), toDownload.toArray(new FeedItem[0])); + DBTasks.downloadFeedItems(getActivity(), toDownload.toArray(new FeedItem[toDownload.size()])); } catch (DownloadRequestException e) { e.printStackTrace(); DownloadRequestErrorDialogCreator.newRequestErrorDialog(getActivity(), e.getMessage()); diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java index 5f531e88f..b50e21d15 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/GpodnetSetHostnameDialog.java @@ -1,7 +1,6 @@ package de.danoeh.antennapod.dialog; import android.content.Context; -import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.InputType; diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java index d745bb51c..98a4b5356 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/ProxyDialog.java @@ -98,9 +98,7 @@ public class ProxyDialog { AntennapodHttpClient.reinit(); dialog.dismiss(); }) - .onNegative((dialog1, which) -> { - dialog1.dismiss(); - }) + .onNegative((dialog1, which) -> dialog1.dismiss()) .autoDismiss(false) .build(); View view = dialog.getCustomView(); @@ -208,8 +206,7 @@ public class ProxyDialog { String port = etPort.getText().toString(); if(port.length() > 0) { try { - int portValue = Integer.parseInt(port); - return portValue; + return Integer.parseInt(port); } catch(NumberFormatException e) { // ignore } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/RatingDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/RatingDialog.java index ed0db92a4..64fc1fda4 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/RatingDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/RatingDialog.java @@ -94,11 +94,7 @@ public class RatingDialog { long firstDate = mPreferences.getLong(KEY_FIRST_START_DATE, now); long diff = now - firstDate; long diffDays = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS); - if (diffDays >= AFTER_DAYS) { - return true; - } else { - return false; - } + return diffDays >= AFTER_DAYS; } @Nullable @@ -107,30 +103,16 @@ public class RatingDialog { if(context == null) { return null; } - MaterialDialog dialog = new MaterialDialog.Builder(context) + return new MaterialDialog.Builder(context) .title(R.string.rating_title) .content(R.string.rating_message) .positiveText(R.string.rating_now_label) .negativeText(R.string.rating_never_label) .neutralText(R.string.rating_later_label) - .callback(new MaterialDialog.ButtonCallback() { - @Override - public void onPositive(MaterialDialog dialog) { - rateNow(); - } - - @Override - public void onNegative(MaterialDialog dialog) { - saveRated(); - } - - @Override - public void onNeutral(MaterialDialog dialog) { - resetStartDate(); - } - }) + .onPositive((dialog, which) -> rateNow()) + .onNegative((dialog, which) -> saveRated()) + .onNeutral((dialog, which) -> resetStartDate()) .cancelListener(dialog1 -> resetStartDate()) .build(); - return dialog; } } diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java index 89e24f882..8a13a75d9 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/SleepTimerDialog.java @@ -1,17 +1,13 @@ package de.danoeh.antennapod.dialog; -import android.app.Dialog; import android.content.Context; import android.content.SharedPreferences; -import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.util.Log; import android.view.View; -import android.view.Window; import android.view.inputmethod.InputMethodManager; import android.widget.ArrayAdapter; -import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Spinner; @@ -58,14 +54,8 @@ public abstract class SleepTimerDialog { builder.customView(R.layout.time_dialog, false); builder.positiveText(R.string.set_sleeptimer_label); builder.negativeText(R.string.cancel_label); - builder.callback(new MaterialDialog.ButtonCallback() { - @Override - public void onNegative(MaterialDialog dialog) { - dialog.dismiss(); - } - - @Override - public void onPositive(MaterialDialog dialog) { + builder.onNegative((dialog, which) -> dialog.dismiss()); + builder.onPositive((dialog, which) -> { try { savePreferences(); long input = readTimeMillis(); @@ -77,8 +67,7 @@ public abstract class SleepTimerDialog { Toast.LENGTH_LONG); toast.show(); } - } - }); + }); dialog = builder.build(); View view = dialog.getView(); diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java index 3ed82b9bd..2bf9c4e7a 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/VariableSpeedDialog.java @@ -102,8 +102,8 @@ public class VariableSpeedDialog { builder.setPositiveButton(android.R.string.ok, (dialog, which) -> { int choiceCount = 0; - for (int i = 0; i < speedChecked.length; i++) { - if (speedChecked[i]) { + for (boolean checked : speedChecked) { + if (checked) { choiceCount++; } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java index d979dc382..45364ca07 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java @@ -47,36 +47,18 @@ public class AddFeedFragment extends Fragment { final MainActivity activity = (MainActivity) getActivity(); activity.getSupportActionBar().setTitle(R.string.add_feed_label); - butSearchITunes.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - activity.loadChildFragment(new ItunesSearchFragment()); - } - }); + butSearchITunes.setOnClickListener(v -> activity.loadChildFragment(new ItunesSearchFragment())); - butBrowserGpoddernet.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - activity.loadChildFragment(new GpodnetMainFragment()); - } - }); + butBrowserGpoddernet.setOnClickListener(v -> activity.loadChildFragment(new GpodnetMainFragment())); - butOpmlImport.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - startActivity(new Intent(getActivity(), - OpmlImportFromPathActivity.class)); - } - }); + butOpmlImport.setOnClickListener(v -> startActivity(new Intent(getActivity(), + OpmlImportFromPathActivity.class))); - butConfirm.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class); - intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, etxtFeedurl.getText().toString()); - intent.putExtra(OnlineFeedViewActivity.ARG_TITLE, getString(R.string.add_feed_label)); - startActivity(intent); - } + butConfirm.setOnClickListener(v -> { + Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class); + intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, etxtFeedurl.getText().toString()); + intent.putExtra(OnlineFeedViewActivity.ARG_TITLE, getString(R.string.add_feed_label)); + startActivity(intent); }); return root; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index aa2879330..c562d5559 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -81,7 +81,7 @@ public class AllEpisodesFragment extends Fragment { private boolean itemsLoaded = false; private boolean viewsCreated = false; - private AtomicReference<MainActivity> activity = new AtomicReference<MainActivity>(); + private AtomicReference<MainActivity> activity = new AtomicReference<>(); private boolean isUpdatingFeeds; @@ -379,10 +379,7 @@ public class AllEpisodesFragment extends Fragment { @Override public boolean isInQueue(FeedItem item) { - if (item != null) { - return item.isTagged(FeedItem.TAG_QUEUE); - } - return false; + return item != null && item.isTagged(FeedItem.TAG_QUEUE); } @Override @@ -471,7 +468,7 @@ public class AllEpisodesFragment extends Fragment { recyclerView.setVisibility(View.GONE); progLoading.setVisibility(View.VISIBLE); } - subscription = Observable.fromCallable(() -> loadData()) + subscription = Observable.fromCallable(this::loadData) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(data -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java index a53c85f1c..261974f2f 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/CompletedDownloadsFragment.java @@ -205,7 +205,7 @@ public class CompletedDownloadsFragment extends ListFragment { if (items == null && viewCreated) { setListShown(false); } - subscription = Observable.fromCallable(() -> DBReader.getDownloadedItems()) + subscription = Observable.fromCallable(DBReader::getDownloadedItems) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java index b470d379a..93527b149 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java @@ -154,7 +154,7 @@ public class DownloadLogFragment extends ListFragment { if(subscription != null) { subscription.unsubscribe(); } - subscription = Observable.fromCallable(() -> DBReader.getDownloadLog()) + subscription = Observable.fromCallable(DBReader::getDownloadLog) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java index 3fd69214d..ca60e7bf2 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java @@ -5,7 +5,6 @@ import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; -import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ImageButton; import android.widget.ImageView; @@ -53,16 +52,12 @@ public class ExternalPlayerFragment extends Fragment { mFeedName = (TextView) root.findViewById(R.id.txtvAuthor); mProgressBar = (ProgressBar) root.findViewById(R.id.episodeProgress); - fragmentLayout.setOnClickListener(new OnClickListener() { + fragmentLayout.setOnClickListener(v -> { + Log.d(TAG, "layoutInfo was clicked"); - @Override - public void onClick(View v) { - Log.d(TAG, "layoutInfo was clicked"); - - if (controller != null && controller.getMedia() != null) { - startActivity(PlaybackService.getPlayerActivityIntent( - getActivity(), controller.getMedia())); - } + if (controller != null && controller.getMedia() != null) { + startActivity(PlaybackService.getPlayerActivityIntent( + getActivity(), controller.getMedia())); } }); return root; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java index 4a93bac7e..5b301333e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemDescriptionFragment.java @@ -148,7 +148,7 @@ public class ItemDescriptionFragment extends Fragment implements AudioplayerCont super.onPageFinished(view, url); Log.d(TAG, "Page finished"); // Restoring the scroll position might not always work - view.postDelayed(() -> restoreFromPreference(), 50); + view.postDelayed(ItemDescriptionFragment.this::restoreFromPreference, 50); } }); @@ -318,8 +318,7 @@ public class ItemDescriptionFragment extends Fragment implements AudioplayerCont private String loadData() { Timeline timeline = new Timeline(getActivity(), shownotesProvider); - String data = timeline.processShownotes(highlightTimecodes); - return data; + return timeline.processShownotes(highlightTimecodes); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java index 0f5aa06ca..92f4a9f7c 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemFragment.java @@ -507,7 +507,7 @@ public class ItemFragment extends Fragment { if(subscription != null) { subscription.unsubscribe(); } - subscription = Observable.fromCallable(() -> loadInBackground()) + subscription = Observable.fromCallable(this::loadInBackground) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java index 303d273bc..f2f8921bb 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItemlistFragment.java @@ -185,11 +185,7 @@ public class ItemlistFragment extends ListFragment { private final MenuItemUtils.UpdateRefreshMenuItemChecker updateRefreshMenuItemChecker = new MenuItemUtils.UpdateRefreshMenuItemChecker() { @Override public boolean isRefreshing() { - if (feed != null && DownloadService.isRunning && DownloadRequester.getInstance().isDownloadingFile(feed)) { - return true; - } else { - return false; - } + return feed != null && DownloadService.isRunning && DownloadRequester.getInstance().isDownloadingFile(feed); } }; @@ -405,7 +401,7 @@ public class ItemlistFragment extends ListFragment { public void onEventMainThread(FeedItemEvent event) { Log.d(TAG, "onEventMainThread() called with: " + "event = [" + event + "]"); - boolean queueChanged = false; +// boolean queueChanged = false; if(feed == null || feed.getItems() == null || adapter == null) { return; } @@ -628,7 +624,7 @@ public class ItemlistFragment extends ListFragment { if(subscription != null) { subscription.unsubscribe(); } - subscription = Observable.fromCallable(() -> loadData()) + subscription = Observable.fromCallable(this::loadData) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ItunesSearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ItunesSearchFragment.java index b736688b9..977c015b1 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/ItunesSearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/ItunesSearchFragment.java @@ -81,9 +81,8 @@ public class ItunesSearchFragment extends Fragment { if (result != null && result.size() > 0) { gridView.setVisibility(View.VISIBLE); txtvEmpty.setVisibility(View.GONE); - for (Podcast p : result) { - adapter.add(p); - } + + adapter.addAll(result); adapter.notifyDataSetInvalidated(); } else { gridView.setVisibility(View.GONE); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java index c5b77fae2..f6cb71af5 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/PlaybackHistoryFragment.java @@ -220,7 +220,7 @@ public class PlaybackHistoryFragment extends ListFragment { private FeedItemlistAdapter.ItemAccess itemAccess = new FeedItemlistAdapter.ItemAccess() { @Override public boolean isInQueue(FeedItem item) { - return (queue != null) ? queue.contains(item.getId()) : false; + return (queue != null) && queue.contains(item.getId()); } @Override @@ -255,7 +255,7 @@ public class PlaybackHistoryFragment extends ListFragment { if(subscription != null) { subscription.unsubscribe(); } - subscription = Observable.fromCallable(() -> loadData()) + subscription = Observable.fromCallable(this::loadData) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java index e5bb1d895..4bfc3c9da 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java @@ -230,9 +230,8 @@ public class QueueFragment extends Fragment { resetViewState(); } - private final MenuItemUtils.UpdateRefreshMenuItemChecker updateRefreshMenuItemChecker = () -> { - return DownloadService.isRunning && DownloadRequester.getInstance().isDownloadingFeeds(); - }; + private final MenuItemUtils.UpdateRefreshMenuItemChecker updateRefreshMenuItemChecker = + () -> DownloadService.isRunning && DownloadRequester.getInstance().isDownloadingFeeds(); @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { @@ -415,7 +414,7 @@ public class QueueFragment extends Fragment { Snackbar snackbar = Snackbar.make(root, getString(R.string.marked_as_read_label), Snackbar.LENGTH_LONG); snackbar.setAction(getString(R.string.undo), v -> { DBWriter.addQueueItemAt(getActivity(), item.getId(), position, false); - if(false == isRead) { + if(!isRead) { DBWriter.markItemPlayed(FeedItem.UNPLAYED, item.getId()); } }); @@ -424,12 +423,12 @@ public class QueueFragment extends Fragment { @Override public boolean isLongPressDragEnabled() { - return false == UserPreferences.isQueueLocked(); + return !UserPreferences.isQueueLocked(); } @Override public boolean isItemViewSwipeEnabled() { - return false == UserPreferences.isQueueLocked(); + return !UserPreferences.isQueueLocked(); } @Override @@ -608,7 +607,7 @@ public class QueueFragment extends Fragment { txtvEmpty.setVisibility(View.GONE); progLoading.setVisibility(View.VISIBLE); } - subscription = Observable.fromCallable(() -> DBReader.getQueue()) + subscription = Observable.fromCallable(DBReader::getQueue) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(items -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java index dbd18163c..510909379 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SearchFragment.java @@ -208,7 +208,7 @@ public class SearchFragment extends ListFragment { if (viewCreated && !itemsLoaded) { setListShown(false); } - subscription = Observable.fromCallable(() -> performSearch()) + subscription = Observable.fromCallable(this::performSearch) .subscribeOn(Schedulers.newThread()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(result -> { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java index 204f36956..15e9c9943 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/PodcastListFragment.java @@ -14,7 +14,6 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; import android.widget.Button; import android.widget.GridView; import android.widget.ProgressBar; @@ -84,18 +83,9 @@ public abstract class PodcastListFragment extends Fragment { txtvError = (TextView) root.findViewById(R.id.txtvError); butRetry = (Button) root.findViewById(R.id.butRetry); - gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - onPodcastSelected((GpodnetPodcast) gridView.getAdapter().getItem(position)); - } - }); - butRetry.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - loadData(); - } - }); + gridView.setOnItemClickListener((parent, view, position, id) -> + onPodcastSelected((GpodnetPodcast) gridView.getAdapter().getItem(position))); + butRetry.setOnClickListener(v -> loadData()); loadData(); return root; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SuggestionListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SuggestionListFragment.java index 133bb0281..46e062f1f 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SuggestionListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/SuggestionListFragment.java @@ -1,13 +1,13 @@ package de.danoeh.antennapod.fragment.gpodnet; +import java.util.ArrayList; +import java.util.List; + import de.danoeh.antennapod.core.gpoddernet.GpodnetService; import de.danoeh.antennapod.core.gpoddernet.GpodnetServiceException; import de.danoeh.antennapod.core.gpoddernet.model.GpodnetPodcast; import de.danoeh.antennapod.core.preferences.GpodnetPreferences; -import java.util.ArrayList; -import java.util.List; - /** * Displays suggestions from gpodder.net */ @@ -20,7 +20,7 @@ public class SuggestionListFragment extends PodcastListFragment { service.authenticate(GpodnetPreferences.getUsername(), GpodnetPreferences.getPassword()); return service.getSuggestions(SUGGESTIONS_COUNT); } else { - return new ArrayList<GpodnetPodcast>(); + return new ArrayList<>(); } } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java index 338f02e61..d2c7f32dd 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/gpodnet/TagListFragment.java @@ -11,7 +11,6 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView; import android.widget.TextView; import java.util.List; @@ -65,13 +64,10 @@ public class TagListFragment extends ListFragment { public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - GpodnetTag tag = (GpodnetTag) getListAdapter().getItem(position); - MainActivity activity = (MainActivity) getActivity(); - activity.loadChildFragment(TagFragment.newInstance(tag)); - } + getListView().setOnItemClickListener((parent, view1, position, id) -> { + GpodnetTag tag = (GpodnetTag) getListAdapter().getItem(position); + MainActivity activity = (MainActivity) getActivity(); + activity.loadChildFragment(TagFragment.newInstance(tag)); }); startLoadTask(); diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java index 58fe8afbf..cdcf6cfd0 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java @@ -41,7 +41,7 @@ public class FeedItemMenuHandler { * menu-object and call setVisibility(visibility) on the returned * MenuItem object. */ - abstract void setItemVisibility(int id, boolean visible); + void setItemVisibility(int id, boolean visible); } /** @@ -98,7 +98,7 @@ public class FeedItemMenuHandler { mi.setItemVisibility(R.id.share_download_url_item, false); mi.setItemVisibility(R.id.share_download_url_with_position_item, false); } - if(false == hasMedia || selectedItem.getMedia().getPosition() <= 0) { + if(!hasMedia || selectedItem.getMedia().getPosition() <= 0) { mi.setItemVisibility(R.id.share_link_with_position_item, false); mi.setItemVisibility(R.id.share_download_url_with_position_item, false); } @@ -113,7 +113,7 @@ public class FeedItemMenuHandler { mi.setItemVisibility(R.id.reset_position, false); } - if(false == UserPreferences.isEnableAutodownload()) { + if(!UserPreferences.isEnableAutodownload()) { mi.setItemVisibility(R.id.activate_auto_download, false); mi.setItemVisibility(R.id.deactivate_auto_download, false); } else if(selectedItem.getAutoDownload()) { diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/NavDrawerActivity.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/NavDrawerActivity.java index 6ceaaada4..c973990c9 100644 --- a/app/src/main/java/de/danoeh/antennapod/menuhandler/NavDrawerActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/NavDrawerActivity.java @@ -5,5 +5,5 @@ package de.danoeh.antennapod.menuhandler; */ public interface NavDrawerActivity { - public boolean isDrawerOpen(); + boolean isDrawerOpen(); } diff --git a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java index d8d263313..6a85f7341 100644 --- a/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java +++ b/app/src/main/java/de/danoeh/antennapod/preferences/PreferenceController.java @@ -184,20 +184,17 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc ); ui.findPreference(PreferenceController.PREF_CHOOSE_DATA_DIR) .setOnPreferenceClickListener( - new Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - if (Build.VERSION.SDK_INT >= 19) { - showChooseDataFolderDialog(); - } else { - Intent intent = new Intent(activity, DirectoryChooserActivity.class); - activity.startActivityForResult(intent, - DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED); - } - return true; + preference -> { + if (Build.VERSION.SDK_INT >= 19) { + showChooseDataFolderDialog(); + } else { + Intent intent = new Intent(activity, DirectoryChooserActivity.class); + activity.startActivityForResult(intent, + DirectoryChooserActivity.RESULT_CODE_DIR_SELECTED); } - } - ); + return true; + } + ); ui.findPreference(UserPreferences.PREF_THEME) .setOnPreferenceChangeListener( (preference, newValue) -> { @@ -630,7 +627,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc Preference.OnPreferenceClickListener clickListener = preference -> { if (preference instanceof CheckBoxPreference) { String key = preference.getKey(); - ArrayList<String> prefValuesList = new ArrayList<String>( + ArrayList<String> prefValuesList = new ArrayList<>( Arrays.asList(UserPreferences .getAutodownloadSelectedNetworks()) ); @@ -639,10 +636,10 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc Log.d(TAG, "Selected network " + key + ". New state: " + newValue); int index = prefValuesList.indexOf(key); - if (index >= 0 && newValue == false) { + if (index >= 0 && !newValue) { // remove network prefValuesList.remove(index); - } else if (index < 0 && newValue == true) { + } else if (index < 0 && newValue) { prefValuesList.add(key); } @@ -678,9 +675,9 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc if (selectedNetworks != null) { PreferenceScreen prefScreen = (PreferenceScreen) ui.findPreference(PreferenceController.AUTO_DL_PREF_SCREEN); - for (int i = 0; i < selectedNetworks.length; i++) { - if (selectedNetworks[i] != null) { - prefScreen.removePreference(selectedNetworks[i]); + for (CheckBoxPreference network : selectedNetworks) { + if (network != null) { + prefScreen.removePreference(network); } } } |