From 4734d04d4f06311f42fb7cb9eecbea7e15909361 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:29:58 -0500 Subject: [PATCH 01/11] Use two more KTX extensions --- .../org/schabi/newpipe/local/feed/FeedFragment.kt | 12 +++++++----- .../local/subscription/dialog/FeedGroupDialog.kt | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index e4d10fb61..825b36045 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -29,6 +29,7 @@ import android.view.MenuItem import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AlertDialog +import androidx.core.content.edit import androidx.core.os.bundleOf import androidx.core.view.isVisible import androidx.lifecycle.Observer @@ -142,9 +143,9 @@ class FeedFragment : BaseListFragment() { AlertDialog.Builder(requireContext()) .setMessage(R.string.feed_use_dedicated_fetch_method_help_text) .setNeutralButton(enableDisableButtonText) { _, _ -> - sharedPreferences.edit() - .putBoolean(getString(R.string.feed_use_dedicated_fetch_method_key), !usingDedicatedMethod) - .apply() + sharedPreferences.edit { + putBoolean(getString(R.string.feed_use_dedicated_fetch_method_key), !usingDedicatedMethod) + } } .setPositiveButton(resources.getString(R.string.finish), null) .create() @@ -255,8 +256,9 @@ class FeedFragment : BaseListFragment() { oldestSubscriptionUpdate = loadedState.oldestUpdate - refresh_subtitle_text.isVisible = loadedState.notLoadedCount > 0 - if (loadedState.notLoadedCount > 0) { + val loadedCount = loadedState.notLoadedCount > 0 + refresh_subtitle_text.isVisible = loadedCount + if (loadedCount) { refresh_subtitle_text.text = getString(R.string.feed_subscription_not_loaded_count, loadedState.notLoadedCount) } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt index 28ffa6265..9f82aefb7 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupDialog.kt @@ -3,7 +3,6 @@ package org.schabi.newpipe.local.subscription.dialog import android.app.Dialog import android.os.Bundle import android.os.Parcelable -import android.text.TextUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -225,7 +224,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable { } toolbar_search_clear.setOnClickListener { - if (TextUtils.isEmpty(toolbar_search_edit_text.text)) { + if (toolbar_search_edit_text.text.isEmpty()) { hideSearch() return@setOnClickListener } From ea5939c1b7da2279181d195073eb9ca038ee4b44 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:45:19 -0500 Subject: [PATCH 02/11] Kotlin lint fixing --- .../main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt | 3 +-- .../schabi/newpipe/player/event/BasePlayerGestureListener.kt | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt index 13c3183da..0976de248 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedViewModel.kt @@ -48,8 +48,7 @@ class FeedViewModel(applicationContext: Context, val groupId: Long = FeedGroupEn .throttleLatest(DEFAULT_THROTTLE_TIMEOUT, TimeUnit.MILLISECONDS) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe { - val (event, listFromDB, notLoadedCount, oldestUpdate) = it + .subscribe { (event, listFromDB, notLoadedCount, oldestUpdate) -> val oldestUpdateCalendar = oldestUpdate?.toCalendar() diff --git a/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt b/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt index 681c1b9af..5bd13a569 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt +++ b/app/src/main/java/org/schabi/newpipe/player/event/BasePlayerGestureListener.kt @@ -15,6 +15,7 @@ import org.schabi.newpipe.util.AnimationUtils import kotlin.math.abs import kotlin.math.hypot import kotlin.math.max +import kotlin.math.min /** * Base gesture handling for [VideoPlayerImpl] @@ -117,7 +118,7 @@ abstract class BasePlayerGestureListener( initSecPointerX = event.getX(1) initSecPointerY = event.getY(1) // record distance between fingers - initPointerDistance = Math.hypot(initFirstPointerX - initSecPointerX.toDouble(), + initPointerDistance = hypot(initFirstPointerX - initSecPointerX.toDouble(), initFirstPointerY - initSecPointerY.toDouble()) isResizing = true @@ -185,7 +186,7 @@ abstract class BasePlayerGestureListener( playerImpl.updateScreenSize() playerImpl.updatePopupSize( - Math.min(playerImpl.screenWidth.toDouble(), newWidth).toInt(), + min(playerImpl.screenWidth.toDouble(), newWidth).toInt(), -1) return true } From e25622df4b76cca4d2b0874afb561906833c526a Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:48:01 -0500 Subject: [PATCH 03/11] Lint: Move declarations into assignments --- .../newpipe/fragments/OnScrollBelowItemsListener.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/OnScrollBelowItemsListener.java b/app/src/main/java/org/schabi/newpipe/fragments/OnScrollBelowItemsListener.java index e93c333cb..cbd44566e 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/OnScrollBelowItemsListener.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/OnScrollBelowItemsListener.java @@ -14,12 +14,10 @@ public abstract class OnScrollBelowItemsListener extends RecyclerView.OnScrollLi super.onScrolled(recyclerView, dx, dy); if (dy > 0) { int pastVisibleItems = 0; - final int visibleItemCount; - final int totalItemCount; final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); - visibleItemCount = layoutManager.getChildCount(); - totalItemCount = layoutManager.getItemCount(); + final int visibleItemCount = layoutManager.getChildCount(); + final int totalItemCount = layoutManager.getItemCount(); // Already covers the GridLayoutManager case if (layoutManager instanceof LinearLayoutManager) { From 39e5d8ccc2410acb1b9bd5740590e3eff871c30e Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:50:00 -0500 Subject: [PATCH 04/11] Lint: Make a bunch of stuff final --- ...agmentStatePagerAdapterMenuWorkaround.java | 4 ++-- .../org/schabi/newpipe/DownloaderImpl.java | 4 ++-- .../org/schabi/newpipe/about/License.java | 2 +- .../newpipe/fragments/MainFragment.java | 2 +- .../list/comments/CommentsFragment.java | 2 +- .../list/videos/RelatedVideosFragment.java | 2 +- .../local/dialog/PlaylistAppendDialog.java | 2 +- .../newpipe/player/NotificationUtil.java | 2 +- .../player/playback/MediaSourceManager.java | 2 +- .../PeertubeInstanceListFragment.java | 14 ++++++------- .../settings/UpdateSettingsFragment.java | 2 +- .../settings/tabs/ChooseTabsFragment.java | 8 ++++---- .../org/schabi/newpipe/settings/tabs/Tab.java | 2 +- .../newpipe/streams/OggFromWebMWriter.java | 4 ++-- .../newpipe/streams/SrtFromTtmlWriter.java | 4 ++-- .../schabi/newpipe/streams/WebMReader.java | 2 +- .../newpipe/util/TLSSocketFactoryCompat.java | 2 +- .../newpipe/views/NewPipeRecyclerView.java | 4 ++-- .../giga/get/DownloadInitializer.java | 2 +- .../giga/get/sqlite/FinishedMissionStore.java | 2 +- .../shandian/giga/io/CircularFileWriter.java | 2 +- .../giga/io/StoredDirectoryHelper.java | 2 +- .../giga/postprocessing/Postprocessing.java | 2 +- .../giga/service/DownloadManagerService.java | 2 +- .../giga/ui/adapter/MissionAdapter.java | 20 +++++++++---------- .../us/shandian/giga/ui/common/Deleter.java | 12 +++++------ .../giga/ui/fragment/MissionsFragment.java | 2 +- 27 files changed, 55 insertions(+), 55 deletions(-) diff --git a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java index 471360c60..433c155c2 100644 --- a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java +++ b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java @@ -86,8 +86,8 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt private final int mBehavior; private FragmentTransaction mCurTransaction = null; - private ArrayList mSavedState = new ArrayList(); - private ArrayList mFragments = new ArrayList(); + private final ArrayList mSavedState = new ArrayList(); + private final ArrayList mFragments = new ArrayList(); private Fragment mCurrentPrimaryItem = null; /** diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java index 69bfdfc2a..431b8034a 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java +++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java @@ -50,8 +50,8 @@ public final class DownloaderImpl extends Downloader { public static final String YOUTUBE_DOMAIN = "youtube.com"; private static DownloaderImpl instance; - private Map mCookies; - private OkHttpClient client; + private final Map mCookies; + private final OkHttpClient client; private DownloaderImpl(final OkHttpClient.Builder builder) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { diff --git a/app/src/main/java/org/schabi/newpipe/about/License.java b/app/src/main/java/org/schabi/newpipe/about/License.java index 877b51fd8..6670e12ac 100644 --- a/app/src/main/java/org/schabi/newpipe/about/License.java +++ b/app/src/main/java/org/schabi/newpipe/about/License.java @@ -23,7 +23,7 @@ public class License implements Parcelable, Serializable { }; private final String abbreviation; private final String name; - private String filename; + private final String filename; public License(final String name, final String abbreviation, final String filename) { if (name == null) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index d138a298c..e78bfa7ce 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -43,7 +43,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte private SelectedTabsPagerAdapter pagerAdapter; private ScrollableTabLayout tabLayout; - private List tabsList = new ArrayList<>(); + private final List tabsList = new ArrayList<>(); private TabsManager tabsManager; private boolean hasTabsChanged = false; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java index fc61a4518..cb9f83895 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/comments/CommentsFragment.java @@ -24,7 +24,7 @@ import io.reactivex.Single; import io.reactivex.disposables.CompositeDisposable; public class CommentsFragment extends BaseListInfoFragment { - private CompositeDisposable disposables = new CompositeDisposable(); + private final CompositeDisposable disposables = new CompositeDisposable(); public static CommentsFragment getInstance(final int serviceId, final String url, final String name) { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java index da7e8df8b..90cb60d33 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java @@ -31,7 +31,7 @@ import io.reactivex.disposables.CompositeDisposable; public class RelatedVideosFragment extends BaseListInfoFragment implements SharedPreferences.OnSharedPreferenceChangeListener { private static final String INFO_KEY = "related_info_key"; - private CompositeDisposable disposables = new CompositeDisposable(); + private final CompositeDisposable disposables = new CompositeDisposable(); private RelatedStreamInfo relatedStreamInfo; /*////////////////////////////////////////////////////////////////////////// diff --git a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java index 7a63bee30..4a09da77f 100644 --- a/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java +++ b/app/src/main/java/org/schabi/newpipe/local/dialog/PlaylistAppendDialog.java @@ -38,7 +38,7 @@ public final class PlaylistAppendDialog extends PlaylistDialog { private RecyclerView playlistRecyclerView; private LocalItemListAdapter playlistAdapter; - private CompositeDisposable playlistDisposables = new CompositeDisposable(); + private final CompositeDisposable playlistDisposables = new CompositeDisposable(); public static Disposable onPlaylistFound( final Context context, final Runnable onSuccess, final Runnable onFailed diff --git a/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java b/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java index 62f1d5dc2..259b2de13 100644 --- a/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java +++ b/app/src/main/java/org/schabi/newpipe/player/NotificationUtil.java @@ -48,7 +48,7 @@ public final class NotificationUtil { @Nullable private static NotificationUtil instance = null; @NotificationConstants.Action - private int[] notificationSlots = NotificationConstants.SLOT_DEFAULTS.clone(); + private final int[] notificationSlots = NotificationConstants.SLOT_DEFAULTS.clone(); private NotificationManagerCompat notificationManager; private NotificationCompat.Builder notificationBuilder; diff --git a/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java b/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java index 1b8c62e64..056002b14 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java +++ b/app/src/main/java/org/schabi/newpipe/player/playback/MediaSourceManager.java @@ -123,7 +123,7 @@ public class MediaSourceManager { @NonNull private ManagedMediaSourcePlaylist playlist; - private Handler removeMediaSourceHandler = new Handler(); + private final Handler removeMediaSourceHandler = new Handler(); public MediaSourceManager(@NonNull final PlaybackListener listener, @NonNull final PlayQueue playQueue) { diff --git a/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java b/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java index 7559f6ed5..1e23c513b 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/PeertubeInstanceListFragment.java @@ -53,7 +53,7 @@ import io.reactivex.schedulers.Schedulers; public class PeertubeInstanceListFragment extends Fragment { private static final int MENU_ITEM_RESTORE_ID = 123456; - private List instanceList = new ArrayList<>(); + private final List instanceList = new ArrayList<>(); private PeertubeInstance selectedInstance; private String savedInstanceListKey; private InstanceListAdapter instanceListAdapter; @@ -344,7 +344,7 @@ public class PeertubeInstanceListFragment extends Fragment { private class InstanceListAdapter extends RecyclerView.Adapter { private final LayoutInflater inflater; - private ItemTouchHelper itemTouchHelper; + private final ItemTouchHelper itemTouchHelper; private RadioButton lastChecked; InstanceListAdapter(final Context context, final ItemTouchHelper itemTouchHelper) { @@ -377,11 +377,11 @@ public class PeertubeInstanceListFragment extends Fragment { } class TabViewHolder extends RecyclerView.ViewHolder { - private AppCompatImageView instanceIconView; - private TextView instanceNameView; - private TextView instanceUrlView; - private RadioButton instanceRB; - private ImageView handle; + private final AppCompatImageView instanceIconView; + private final TextView instanceNameView; + private final TextView instanceUrlView; + private final RadioButton instanceRB; + private final ImageView handle; TabViewHolder(final View itemView) { super(itemView); diff --git a/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java index 476cf97ab..f25b25df2 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/UpdateSettingsFragment.java @@ -8,7 +8,7 @@ import androidx.preference.Preference; import org.schabi.newpipe.R; public class UpdateSettingsFragment extends BasePreferenceFragment { - private Preference.OnPreferenceChangeListener updatePreferenceChange + private final Preference.OnPreferenceChangeListener updatePreferenceChange = (preference, newValue) -> { defaultPreferences.edit() .putBoolean(getString(R.string.update_app_key), (boolean) newValue).apply(); diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java index 2554ecc5c..44406abac 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/ChooseTabsFragment.java @@ -334,7 +334,7 @@ public class ChooseTabsFragment extends Fragment { private class SelectedTabsAdapter extends RecyclerView.Adapter { private final LayoutInflater inflater; - private ItemTouchHelper itemTouchHelper; + private final ItemTouchHelper itemTouchHelper; SelectedTabsAdapter(final Context context, final ItemTouchHelper itemTouchHelper) { this.itemTouchHelper = itemTouchHelper; @@ -367,9 +367,9 @@ public class ChooseTabsFragment extends Fragment { } class TabViewHolder extends RecyclerView.ViewHolder { - private AppCompatImageView tabIconView; - private TextView tabNameView; - private ImageView handle; + private final AppCompatImageView tabIconView; + private final TextView tabNameView; + private final ImageView handle; TabViewHolder(final View itemView) { super(itemView); diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java index 8e440c93d..ac07392cd 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java @@ -156,7 +156,7 @@ public abstract class Tab { CHANNEL(new ChannelTab()), PLAYLIST(new PlaylistTab()); - private Tab tab; + private final Tab tab; Type(final Tab tab) { this.tab = tab; diff --git a/app/src/main/java/org/schabi/newpipe/streams/OggFromWebMWriter.java b/app/src/main/java/org/schabi/newpipe/streams/OggFromWebMWriter.java index 44104f133..3b3c74e3a 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/OggFromWebMWriter.java +++ b/app/src/main/java/org/schabi/newpipe/streams/OggFromWebMWriter.java @@ -31,8 +31,8 @@ public class OggFromWebMWriter implements Closeable { private boolean done = false; private boolean parsed = false; - private SharpStream source; - private SharpStream output; + private final SharpStream source; + private final SharpStream output; private int sequenceCount = 0; private final int streamId; diff --git a/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java b/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java index 8cb31141b..7aff655a0 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java +++ b/app/src/main/java/org/schabi/newpipe/streams/SrtFromTtmlWriter.java @@ -20,8 +20,8 @@ import java.nio.charset.StandardCharsets; public class SrtFromTtmlWriter { private static final String NEW_LINE = "\r\n"; - private SharpStream out; - private boolean ignoreEmptyFrames; + private final SharpStream out; + private final boolean ignoreEmptyFrames; private final Charset charset = StandardCharsets.UTF_8; private int frameIndex = 0; diff --git a/app/src/main/java/org/schabi/newpipe/streams/WebMReader.java b/app/src/main/java/org/schabi/newpipe/streams/WebMReader.java index 193f89996..7f7615426 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/WebMReader.java +++ b/app/src/main/java/org/schabi/newpipe/streams/WebMReader.java @@ -49,7 +49,7 @@ public class WebMReader { Audio/*2*/, Video/*1*/, Other } - private DataReader stream; + private final DataReader stream; private Segment segment; private WebMTrack[] tracks; private int selectedTrack; diff --git a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java index 89dc08f38..8cf5a4cdf 100644 --- a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java +++ b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java @@ -24,7 +24,7 @@ public class TLSSocketFactoryCompat extends SSLSocketFactory { private static TLSSocketFactoryCompat instance = null; - private SSLSocketFactory internalSSLSocketFactory; + private final SSLSocketFactory internalSSLSocketFactory; public TLSSocketFactoryCompat() throws KeyManagementException, NoSuchAlgorithmException { final SSLContext context = SSLContext.getInstance("TLS"); diff --git a/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java b/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java index a4f7a0506..23b961297 100644 --- a/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java +++ b/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java @@ -33,8 +33,8 @@ import androidx.recyclerview.widget.RecyclerView; public class NewPipeRecyclerView extends RecyclerView { private static final String TAG = "NewPipeRecyclerView"; - private Rect focusRect = new Rect(); - private Rect tempFocus = new Rect(); + private final Rect focusRect = new Rect(); + private final Rect tempFocus = new Rect(); private boolean allowDpadScroll = true; diff --git a/app/src/main/java/us/shandian/giga/get/DownloadInitializer.java b/app/src/main/java/us/shandian/giga/get/DownloadInitializer.java index 618200f27..327278ba3 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadInitializer.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadInitializer.java @@ -23,7 +23,7 @@ public class DownloadInitializer extends Thread { private final static int RESERVE_SPACE_DEFAULT = 5 * 1024 * 1024;// 5 MiB private final static int RESERVE_SPACE_MAXIMUM = 150 * 1024 * 1024;// 150 MiB - private DownloadMission mMission; + private final DownloadMission mMission; private HttpURLConnection mConn; DownloadInitializer(@NonNull DownloadMission mission) { diff --git a/app/src/main/java/us/shandian/giga/get/sqlite/FinishedMissionStore.java b/app/src/main/java/us/shandian/giga/get/sqlite/FinishedMissionStore.java index bf9460b3d..1d1dca0df 100644 --- a/app/src/main/java/us/shandian/giga/get/sqlite/FinishedMissionStore.java +++ b/app/src/main/java/us/shandian/giga/get/sqlite/FinishedMissionStore.java @@ -68,7 +68,7 @@ public class FinishedMissionStore extends SQLiteOpenHelper { " UNIQUE(" + KEY_TIMESTAMP + ", " + KEY_PATH + "));"; - private Context context; + private final Context context; public FinishedMissionStore(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); diff --git a/app/src/main/java/us/shandian/giga/io/CircularFileWriter.java b/app/src/main/java/us/shandian/giga/io/CircularFileWriter.java index d3dde7835..4d62ab200 100644 --- a/app/src/main/java/us/shandian/giga/io/CircularFileWriter.java +++ b/app/src/main/java/us/shandian/giga/io/CircularFileWriter.java @@ -15,7 +15,7 @@ public class CircularFileWriter extends SharpStream { private final static int NOTIFY_BYTES_INTERVAL = 64 * 1024;// 64 KiB private final static int THRESHOLD_AUX_LENGTH = 15 * 1024 * 1024;// 15 MiB - private OffsetChecker callback; + private final OffsetChecker callback; public ProgressReport onProgress; public WriteErrorHandle onWriteError; diff --git a/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java b/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java index 8f7e18a31..95cce2f0a 100644 --- a/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java +++ b/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java @@ -31,7 +31,7 @@ public class StoredDirectoryHelper { private Context context; - private String tag; + private final String tag; public StoredDirectoryHelper(@NonNull Context context, @NonNull Uri path, String tag) throws IOException { this.tag = tag; diff --git a/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java b/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java index 50dbd1c3d..36634fe79 100644 --- a/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java +++ b/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java @@ -73,7 +73,7 @@ public abstract class Postprocessing implements Serializable { /** * Gets the given algorithm short name */ - private String name; + private final String name; private String[] args; diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index 0392e7235..b43733a51 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -109,7 +109,7 @@ public class DownloadManagerService extends Service { private int downloadFailedNotificationID = DOWNLOADS_NOTIFICATION_ID + 1; private Builder downloadFailedNotification = null; - private SparseArray mFailedDownloads = new SparseArray<>(5); + private final SparseArray mFailedDownloads = new SparseArray<>(5); private Bitmap icLauncher; private Bitmap icDownloadDone; diff --git a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java index 80c238d91..8bbef74c1 100644 --- a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java +++ b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java @@ -96,21 +96,21 @@ public class MissionAdapter extends Adapter implements Handler.Callb ALGORITHMS.put(R.id.sha1, "SHA1"); } - private Context mContext; - private LayoutInflater mInflater; - private DownloadManager mDownloadManager; - private Deleter mDeleter; + private final Context mContext; + private final LayoutInflater mInflater; + private final DownloadManager mDownloadManager; + private final Deleter mDeleter; private int mLayout; - private DownloadManager.MissionIterator mIterator; - private ArrayList mPendingDownloadsItems = new ArrayList<>(); - private Handler mHandler; + private final DownloadManager.MissionIterator mIterator; + private final ArrayList mPendingDownloadsItems = new ArrayList<>(); + private final Handler mHandler; private MenuItem mClear; private MenuItem mStartButton; private MenuItem mPauseButton; - private View mEmptyMessage; + private final View mEmptyMessage; private RecoverHelper mRecover; - private View mView; - private ArrayList mHidden; + private final View mView; + private final ArrayList mHidden; private Snackbar mSnackbar; private final Runnable rUpdater = this::updater; diff --git a/app/src/main/java/us/shandian/giga/ui/common/Deleter.java b/app/src/main/java/us/shandian/giga/ui/common/Deleter.java index a0828c23d..1d57605b9 100644 --- a/app/src/main/java/us/shandian/giga/ui/common/Deleter.java +++ b/app/src/main/java/us/shandian/giga/ui/common/Deleter.java @@ -27,12 +27,12 @@ public class Deleter { private ArrayList items; private boolean running = true; - private Context mContext; - private MissionAdapter mAdapter; - private DownloadManager mDownloadManager; - private MissionIterator mIterator; - private Handler mHandler; - private View mView; + private final Context mContext; + private final MissionAdapter mAdapter; + private final DownloadManager mDownloadManager; + private final MissionIterator mIterator; + private final Handler mHandler; + private final View mView; private final Runnable rShow; private final Runnable rNext; diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 265491b8a..9632c4ae0 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -66,7 +66,7 @@ public class MissionsFragment extends Fragment { private DownloadMission unsafeMissionTarget = null; - private ServiceConnection mConnection = new ServiceConnection() { + private final ServiceConnection mConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder binder) { From 00b08318a596eef01c50005b0d42dc84665dcadc Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:52:30 -0500 Subject: [PATCH 05/11] Lint: Redundant 'new' expression in constant array creation --- app/src/main/java/org/schabi/newpipe/about/AboutActivity.java | 2 +- app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java | 2 +- app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java | 2 +- .../main/java/us/shandian/giga/io/StoredDirectoryHelper.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java index a15bb9e41..e3e56816c 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java @@ -31,7 +31,7 @@ public class AboutActivity extends AppCompatActivity { /** * List of all software components. */ - private static final SoftwareComponent[] SOFTWARE_COMPONENTS = new SoftwareComponent[]{ + private static final SoftwareComponent[] SOFTWARE_COMPONENTS = { new SoftwareComponent("Giga Get", "2014 - 2015", "Peter Cai", "https://github.com/PaperAirplane-Dev-Team/GigaGet", StandardLicenses.GPL3), new SoftwareComponent("NewPipe Extractor", "2017 - 2020", "Christian Schabesberger", diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index b83f9fd97..3b7ae1d64 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -154,7 +154,7 @@ public class ErrorActivity extends AppCompatActivity { public static void reportError(final Context context, final CrashReportData report, final ErrorInfo errorInfo) { - final String[] el = new String[]{report.getString(ReportField.STACK_TRACE)}; + final String[] el = {report.getString(ReportField.STACK_TRACE)}; final Intent intent = new Intent(context, ErrorActivity.class); intent.putExtra(ERROR_INFO, errorInfo); diff --git a/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java b/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java index 152521018..2675c2240 100644 --- a/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/AnimationUtils.java @@ -157,7 +157,7 @@ public final class AnimationUtils { + "colorStart = [" + colorStart + "], colorEnd = [" + colorEnd + "]"); } - final int[][] empty = new int[][]{new int[0]}; + final int[][] empty = {new int[0]}; final ValueAnimator viewPropertyAnimator = ValueAnimator .ofObject(new ArgbEvaluator(), colorStart, colorEnd); viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator()); diff --git a/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java b/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java index 95cce2f0a..5edc5f3ed 100644 --- a/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java +++ b/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java @@ -82,7 +82,7 @@ public class StoredDirectoryHelper { docTree.getUri(), DocumentsContract.getDocumentId(docTree.getUri()) ); - String[] projection = new String[]{COLUMN_DISPLAY_NAME}; + String[] projection = {COLUMN_DISPLAY_NAME}; String selection = "(LOWER(" + COLUMN_DISPLAY_NAME + ") LIKE ?%"; ContentResolver cr = context.getContentResolver(); From 773bde14ab29fe068356aaa47e57f0dcd1a11801 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:54:16 -0500 Subject: [PATCH 06/11] Lint: 'size() == 0' replaceable with 'isEmpty()' --- .../schabi/newpipe/fragments/detail/VideoDetailFragment.java | 2 +- .../schabi/newpipe/fragments/list/BaseListInfoFragment.java | 2 +- .../schabi/newpipe/fragments/list/search/SearchFragment.java | 4 ++-- .../org/schabi/newpipe/settings/tabs/TabsJsonHelperTest.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 67bc51c58..b9140c41c 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1140,7 +1140,7 @@ public final class VideoDetailFragment PlayQueue queue = playQueue; // Size can be 0 because queue removes bad stream automatically when error occurs - if (queue == null || queue.size() == 0) { + if (queue == null || queue.isEmpty()) { queue = new SinglePlayQueue(currentInfo); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java index f21eb5291..43fc74922 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListInfoFragment.java @@ -204,7 +204,7 @@ public abstract class BaseListInfoFragment name = result.getName(); setTitle(name); - if (infoListAdapter.getItemsList().size() == 0) { + if (infoListAdapter.getItemsList().isEmpty()) { if (result.getRelatedItems().size() > 0) { infoListAdapter.addInfoItemList(result.getRelatedItems()); showListFooter(hasMoreItems()); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 1e54176d4..1452241aa 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -256,7 +256,7 @@ public class SearchFragment extends BaseListFragment Date: Wed, 18 Nov 2020 17:57:30 -0500 Subject: [PATCH 07/11] Lint: Lambda fix --- app/src/main/java/org/schabi/newpipe/RouterActivity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 537d71901..f650d882e 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -534,9 +534,8 @@ public class RouterActivity extends AppCompatActivity { downloadDialog.show(fm, "downloadDialog"); fm.executePendingTransactions(); downloadDialog.requireDialog().setOnDismissListener(dialog -> finish()); - }, (@NonNull Throwable throwable) -> { - showUnsupportedUrlDialog(currentUrl); - })); + }, (@NonNull Throwable throwable) -> + showUnsupportedUrlDialog(currentUrl))); } @Override From ad2ea0b8071931037607e28734049d5006ff873d Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 17:58:41 -0500 Subject: [PATCH 08/11] Lint: 'if' replaceable with 'switch' --- .../fragments/detail/VideoDetailFragment.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index b9140c41c..8e445572d 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1346,19 +1346,24 @@ public final class VideoDetailFragment broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { - if (intent.getAction().equals(ACTION_SHOW_MAIN_PLAYER)) { - bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); - } else if (intent.getAction().equals(ACTION_HIDE_MAIN_PLAYER)) { - bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); - } else if (intent.getAction().equals(ACTION_PLAYER_STARTED)) { - // If the state is not hidden we don't need to show the mini player - if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) { - bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); - } - // Rebound to the service if it was closed via notification or mini player - if (!PlayerHolder.bound) { - PlayerHolder.startService(App.getApp(), false, VideoDetailFragment.this); - } + switch (intent.getAction()) { + case ACTION_SHOW_MAIN_PLAYER: + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); + break; + case ACTION_HIDE_MAIN_PLAYER: + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN); + break; + case ACTION_PLAYER_STARTED: + // If the state is not hidden we don't need to show the mini player + if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN) { + bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + } + // Rebound to the service if it was closed via notification or mini player + if (!PlayerHolder.bound) { + PlayerHolder.startService( + App.getApp(), false, VideoDetailFragment.this); + } + break; } } }; From 0274cd6beb2c9a0e78b3a8d12c180cab3b74ceae Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Wed, 18 Nov 2020 18:02:33 -0500 Subject: [PATCH 09/11] Lint: Inner class may be static --- .../newpipe/info_list/InfoListAdapter.java | 2 +- .../player/playqueue/PlayQueueAdapter.java | 2 +- .../schabi/newpipe/streams/Mp4DashReader.java | 36 +++++++++---------- .../newpipe/streams/Mp4FromDashWriter.java | 2 +- .../schabi/newpipe/streams/WebMReader.java | 8 ++--- .../newpipe/views/FocusAwareSeekBar.java | 2 +- .../giga/service/DownloadManager.java | 2 +- .../giga/ui/adapter/MissionAdapter.java | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java index 2978f9948..56bc63384 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java @@ -371,7 +371,7 @@ public class InfoListAdapter extends RecyclerView.Adapter implements Handler.Callb } } - class ViewHolderHeader extends RecyclerView.ViewHolder { + static class ViewHolderHeader extends RecyclerView.ViewHolder { TextView header; ViewHolderHeader(View view) { From 04cb6ba3d0d575a3440ff4ef6fbade3cd9013830 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 15:25:07 -0500 Subject: [PATCH 10/11] Update Android Studio --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index de8691749..6e9b57cac 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' + classpath 'com.android.tools.build:gradle:4.1.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong From 2669ba944d7573c991ad89c9a1005b47e12412f6 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 19 Nov 2020 18:54:27 -0500 Subject: [PATCH 11/11] Correct some other small lints --- .../main/java/org/schabi/newpipe/MainActivity.java | 3 +-- .../main/java/org/schabi/newpipe/RouterActivity.java | 4 ++-- .../newpipe/fragments/detail/VideoDetailFragment.java | 11 +++++------ .../java/org/schabi/newpipe/player/BasePlayer.java | 3 +-- .../org/schabi/newpipe/player/VideoPlayerImpl.java | 2 +- .../java/org/schabi/newpipe/report/ErrorActivity.java | 6 +++--- .../newpipe/settings/ContentSettingsFragment.java | 9 ++++----- .../java/org/schabi/newpipe/settings/tabs/Tab.java | 2 +- .../main/java/org/schabi/newpipe/util/KoreUtil.java | 5 ++--- 9 files changed, 20 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 9bcbe4ff1..f51ecf2d3 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -139,8 +139,7 @@ public class MainActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - if (getSupportFragmentManager() != null - && getSupportFragmentManager().getBackStackEntryCount() == 0) { + if (getSupportFragmentManager().getBackStackEntryCount() == 0) { initFragments(); } diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index f650d882e..e14eeeba6 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -519,7 +519,7 @@ public class RouterActivity extends AppCompatActivity { disposables.add(ExtractorHelper.getStreamInfo(currentServiceId, currentUrl, true) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull StreamInfo result) -> { + .subscribe(result -> { final List sortedVideoStreams = ListHelper .getSortedStreamVideosList(this, result.getVideoStreams(), result.getVideoOnlyStreams(), false); @@ -534,7 +534,7 @@ public class RouterActivity extends AppCompatActivity { downloadDialog.show(fm, "downloadDialog"); fm.executePendingTransactions(); downloadDialog.requireDialog().setOnDismissListener(dialog -> finish()); - }, (@NonNull Throwable throwable) -> + }, throwable -> showUnsupportedUrlDialog(currentUrl))); } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 8e445572d..772a291b1 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -19,7 +19,6 @@ import android.view.ViewTreeObserver; import androidx.core.text.HtmlCompat; import androidx.preference.PreferenceManager; import android.provider.Settings; -import android.text.Spanned; import android.text.TextUtils; import android.text.util.Linkify; import android.util.DisplayMetrics; @@ -731,7 +730,7 @@ public final class VideoDetailFragment } private View.OnTouchListener getOnControlsTouchListener() { - return (View view, MotionEvent motionEvent) -> { + return (view, motionEvent) -> { if (!PreferenceManager.getDefaultSharedPreferences(activity) .getBoolean(getString(R.string.show_hold_to_append_key), true)) { return false; @@ -948,7 +947,7 @@ public final class VideoDetailFragment currentWorker = ExtractorHelper.getStreamInfo(serviceId, url, forceLoad) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull final StreamInfo result) -> { + .subscribe(result -> { isLoading.set(false); hideMainPlayer(); if (result.getAgeLimit() != NO_AGE_LIMIT && !prefs.getBoolean( @@ -969,7 +968,7 @@ public final class VideoDetailFragment openVideoPlayer(); } } - }, (@NonNull final Throwable throwable) -> { + }, throwable -> { isLoading.set(false); onError(throwable); }); @@ -1224,12 +1223,12 @@ public final class VideoDetailFragment if (description.getType() == Description.HTML) { disposables.add(Single.just(description.getContent()) - .map((@NonNull final String descriptionText) -> + .map(descriptionText -> HtmlCompat.fromHtml(descriptionText, HtmlCompat.FROM_HTML_MODE_LEGACY)) .subscribeOn(Schedulers.computation()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe((@NonNull final Spanned spanned) -> { + .subscribe(spanned -> { videoDescriptionView.setText(spanned); videoDescriptionView.setVisibility(View.VISIBLE); })); diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 1355f4285..4790dc029 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -1545,8 +1545,7 @@ public abstract class BasePlayer implements if (simpleExoPlayer == null) { return PlaybackParameters.DEFAULT; } - final PlaybackParameters parameters = simpleExoPlayer.getPlaybackParameters(); - return parameters == null ? PlaybackParameters.DEFAULT : parameters; + return simpleExoPlayer.getPlaybackParameters(); } /** diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 5b4b987a4..e25ec90c4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -337,7 +337,7 @@ public class VideoPlayerImpl extends VideoPlayer view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX, (float) minimumLength / captionRatioInverse); } - view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT)); + view.setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT); view.setStyle(captionStyle); } diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 3b7ae1d64..259dff44d 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -216,15 +216,15 @@ public class ErrorActivity extends AppCompatActivity { addGuruMeditation(); currentTimeStamp = getCurrentTimeStamp(); - reportEmailButton.setOnClickListener((View v) -> + reportEmailButton.setOnClickListener(v -> openPrivacyPolicyDialog(this, "EMAIL")); - copyButton.setOnClickListener((View v) -> { + copyButton.setOnClickListener(v -> { ShareUtils.copyToClipboard(this, buildMarkdown()); Toast.makeText(this, R.string.msg_copied, Toast.LENGTH_SHORT).show(); }); - reportGithubButton.setOnClickListener((View v) -> + reportGithubButton.setOnClickListener(v -> openPrivacyPolicyDialog(this, "GITHUB")); diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java index 37431fa58..3fba6890a 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsFragment.java @@ -3,7 +3,6 @@ package org.schabi.newpipe.settings; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -134,7 +133,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { addPreferencesFromResource(R.xml.content_settings); final Preference importDataPreference = findPreference(getString(R.string.import_data)); - importDataPreference.setOnPreferenceClickListener((Preference p) -> { + importDataPreference.setOnPreferenceClickListener(p -> { final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, false) @@ -145,7 +144,7 @@ public class ContentSettingsFragment extends BasePreferenceFragment { }); final Preference exportDataPreference = findPreference(getString(R.string.export_data)); - exportDataPreference.setOnPreferenceClickListener((Preference p) -> { + exportDataPreference.setOnPreferenceClickListener(p -> { final Intent i = new Intent(getActivity(), FilePickerActivityHelper.class) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_MULTIPLE, false) .putExtra(FilePickerActivityHelper.EXTRA_ALLOW_CREATE_DIR, true) @@ -199,9 +198,9 @@ public class ContentSettingsFragment extends BasePreferenceFragment { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage(R.string.override_current_data) .setPositiveButton(getString(R.string.finish), - (DialogInterface d, int id) -> importDatabase(path)) + (d, id) -> importDatabase(path)) .setNegativeButton(android.R.string.cancel, - (DialogInterface d, int id) -> d.cancel()); + (d, id) -> d.cancel()); builder.create().show(); } } diff --git a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java index ac07392cd..aaac03232 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java +++ b/app/src/main/java/org/schabi/newpipe/settings/tabs/Tab.java @@ -116,7 +116,7 @@ public abstract class Tab { return true; } - return obj instanceof Tab && obj.getClass().equals(this.getClass()) + return obj instanceof Tab && obj.getClass() == this.getClass() && ((Tab) obj).getTabId() == this.getTabId(); } diff --git a/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java b/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java index 983fe689b..7d37b25c4 100644 --- a/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java +++ b/app/src/main/java/org/schabi/newpipe/util/KoreUtil.java @@ -2,7 +2,6 @@ package org.schabi.newpipe.util; import android.content.Context; -import android.content.DialogInterface; import androidx.appcompat.app.AlertDialog; @@ -20,9 +19,9 @@ public final class KoreUtil { public static void showInstallKoreDialog(final Context context) { final AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(R.string.kore_not_found) - .setPositiveButton(R.string.install, (DialogInterface dialog, int which) -> + .setPositiveButton(R.string.install, (dialog, which) -> NavigationHelper.installKore(context)) - .setNegativeButton(R.string.cancel, (DialogInterface dialog, int which) -> { + .setNegativeButton(R.string.cancel, (dialog, which) -> { }); builder.create().show(); }