1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-06-26 07:03:20 +00:00

Merge pull request #4929 from TacoTheDank/murder-all-the-annoying-lints

Various code improvements
This commit is contained in:
Tobias Groza 2020-11-20 15:53:37 +01:00 committed by GitHub
commit bbfa280e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 146 additions and 148 deletions

View File

@ -86,8 +86,8 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
private final int mBehavior;
private FragmentTransaction mCurTransaction = null;
private ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
private ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
private final ArrayList<Fragment.SavedState> mSavedState = new ArrayList<Fragment.SavedState>();
private final ArrayList<Fragment> mFragments = new ArrayList<Fragment>();
private Fragment mCurrentPrimaryItem = null;
/**

View File

@ -50,8 +50,8 @@ public final class DownloaderImpl extends Downloader {
public static final String YOUTUBE_DOMAIN = "youtube.com";
private static DownloaderImpl instance;
private Map<String, String> mCookies;
private OkHttpClient client;
private final Map<String, String> mCookies;
private final OkHttpClient client;
private DownloaderImpl(final OkHttpClient.Builder builder) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {

View File

@ -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();
}

View File

@ -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<VideoStream> sortedVideoStreams = ListHelper
.getSortedStreamVideosList(this, result.getVideoStreams(),
result.getVideoOnlyStreams(), false);
@ -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);
}));
}, throwable ->
showUnsupportedUrlDialog(currentUrl)));
}
@Override

View File

@ -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",

View File

@ -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) {

View File

@ -43,7 +43,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
private SelectedTabsPagerAdapter pagerAdapter;
private ScrollableTabLayout tabLayout;
private List<Tab> tabsList = new ArrayList<>();
private final List<Tab> tabsList = new ArrayList<>();
private TabsManager tabsManager;
private boolean hasTabsChanged = false;

View File

@ -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) {

View File

@ -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);
});
@ -1140,7 +1139,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);
}
@ -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);
}));
@ -1346,19 +1345,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;
}
}
};

View File

@ -204,7 +204,7 @@ public abstract class BaseListInfoFragment<I extends ListInfo>
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());

View File

@ -24,7 +24,7 @@ import io.reactivex.Single;
import io.reactivex.disposables.CompositeDisposable;
public class CommentsFragment extends BaseListInfoFragment<CommentsInfo> {
private CompositeDisposable disposables = new CompositeDisposable();
private final CompositeDisposable disposables = new CompositeDisposable();
public static CommentsFragment getInstance(final int serviceId, final String url,
final String name) {

View File

@ -256,7 +256,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
if (!TextUtils.isEmpty(searchString)) {
if (wasLoading.getAndSet(false)) {
search(searchString, contentFilter, sortFilter);
} else if (infoListAdapter.getItemsList().size() == 0) {
} else if (infoListAdapter.getItemsList().isEmpty()) {
if (savedState == null) {
search(searchString, contentFilter, sortFilter);
} else if (!isLoading.get() && !wasSearchFocused) {
@ -977,7 +977,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
lastSearchedString = searchString;
nextPage = result.getNextPage();
if (infoListAdapter.getItemsList().size() == 0) {
if (infoListAdapter.getItemsList().isEmpty()) {
if (!result.getRelatedItems().isEmpty()) {
infoListAdapter.addInfoItemList(result.getRelatedItems());
} else {

View File

@ -31,7 +31,7 @@ import io.reactivex.disposables.CompositeDisposable;
public class RelatedVideosFragment extends BaseListInfoFragment<RelatedStreamInfo>
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;
/*//////////////////////////////////////////////////////////////////////////

View File

@ -371,7 +371,7 @@ public class InfoListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
};
}
public class HFHolder extends RecyclerView.ViewHolder {
public static class HFHolder extends RecyclerView.ViewHolder {
public View view;
HFHolder(final View v) {

View File

@ -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

View File

@ -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<FeedState, Unit>() {
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<FeedState, Unit>() {
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)
}

View File

@ -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()

View File

@ -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
}

View File

@ -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();
}
/**

View File

@ -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;

View File

@ -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);
}

View File

@ -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
}

View File

@ -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) {

View File

@ -215,7 +215,7 @@ public class PlayQueueAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
}
}
public class HFHolder extends RecyclerView.ViewHolder {
public static class HFHolder extends RecyclerView.ViewHolder {
public View view;
public HFHolder(final View v) {

View File

@ -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);
@ -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"));

View File

@ -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();
}
}

View File

@ -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<PeertubeInstance> instanceList = new ArrayList<>();
private final List<PeertubeInstance> 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<InstanceListAdapter.TabViewHolder> {
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);

View File

@ -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();

View File

@ -334,7 +334,7 @@ public class ChooseTabsFragment extends Fragment {
private class SelectedTabsAdapter
extends RecyclerView.Adapter<ChooseTabsFragment.SelectedTabsAdapter.TabViewHolder> {
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);

View File

@ -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();
}
@ -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;

View File

@ -743,24 +743,24 @@ public class Mp4DashReader {
return readFullBox(b);
}
class Box {
static class Box {
int type;
long offset;
long size;
}
public class Moof {
public static class Moof {
int mfhdSequenceNumber;
public Traf traf;
}
public class Traf {
public static class Traf {
public Tfhd tfhd;
long tfdt;
public Trun trun;
}
public class Tfhd {
public static class Tfhd {
int bFlags;
public int trackId;
int defaultSampleDuration;
@ -768,7 +768,7 @@ public class Mp4DashReader {
int defaultSampleFlags;
}
class TrunEntry {
static class TrunEntry {
int sampleDuration;
int sampleSize;
int sampleFlags;
@ -779,7 +779,7 @@ public class Mp4DashReader {
}
public class Trun {
public static class Trun {
public int chunkDuration;
public int chunkSize;
@ -837,7 +837,7 @@ public class Mp4DashReader {
}
}
public class Tkhd {
public static class Tkhd {
int trackId;
long duration;
short bVolume;
@ -848,25 +848,25 @@ public class Mp4DashReader {
short bAlternateGroup;
}
public class Trak {
public static class Trak {
public Tkhd tkhd;
public Elst edstElst;
public Mdia mdia;
}
class Mvhd {
static class Mvhd {
long timeScale;
long nextTrackId;
}
class Moov {
static class Moov {
Mvhd mvhd;
Trak[] trak;
Trex[] mvexTrex;
}
public class Trex {
public static class Trex {
private int trackId;
int defaultSampleDescriptionIndex;
int defaultSampleDuration;
@ -874,37 +874,37 @@ public class Mp4DashReader {
int defaultSampleFlags;
}
public class Elst {
public static class Elst {
public long mediaTime;
public int bMediaRate;
}
public class Mdia {
public static class Mdia {
public int mdhdTimeScale;
public byte[] mdhd;
public Hdlr hdlr;
public Minf minf;
}
public class Hdlr {
public static class Hdlr {
public int type;
public int subType;
public byte[] bReserved;
}
public class Minf {
public static class Minf {
public byte[] dinf;
public byte[] stblStsd;
public byte[] mhd;
}
public class Mp4Track {
public static class Mp4Track {
public TrackKind kind;
public Trak trak;
public Trex trex;
}
public class Mp4DashChunk {
public static class Mp4DashChunk {
public InputStream data;
public Moof moof;
private int i = 0;
@ -936,7 +936,7 @@ public class Mp4DashReader {
}
}
public class Mp4DashSample {
public static class Mp4DashSample {
public TrunEntry info;
public byte[] data;
}

View File

@ -897,7 +897,7 @@ public class Mp4FromDashWriter {
return buffer.array();
}
class TablesInfo {
static class TablesInfo {
int stts;
int stsc;
int[] stscBEntries;

View File

@ -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;

View File

@ -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;

View File

@ -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;
@ -397,19 +397,19 @@ public class WebMReader {
return obj;
}
class Element {
static class Element {
int type;
long offset;
long contentSize;
long size;
}
public class Info {
public static class Info {
public long timecodeScale;
public long duration;
}
public class WebMTrack {
public static class WebMTrack {
public long trackNumber;
protected int trackType;
public String codecId;
@ -454,7 +454,7 @@ public class WebMReader {
}
}
public class SimpleBlock {
public static class SimpleBlock {
public InputStream data;
public boolean createdFromBlock;

View File

@ -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());

View File

@ -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();
}

View File

@ -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");

View File

@ -109,7 +109,7 @@ public final class FocusAwareSeekBar extends AppCompatSeekBar {
}
}
private final class NestedListener implements OnSeekBarChangeListener {
private static final class NestedListener implements OnSeekBarChangeListener {
private final OnSeekBarChangeListener delegate;
boolean isSeeking;

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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;

View File

@ -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;
@ -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();

View File

@ -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;

View File

@ -686,7 +686,7 @@ public class DownloadManager {
}
}
public class MissionItem {
public static class MissionItem {
public int special;
public Mission mission;

View File

@ -109,7 +109,7 @@ public class DownloadManagerService extends Service {
private int downloadFailedNotificationID = DOWNLOADS_NOTIFICATION_ID + 1;
private Builder downloadFailedNotification = null;
private SparseArray<DownloadMission> mFailedDownloads = new SparseArray<>(5);
private final SparseArray<DownloadMission> mFailedDownloads = new SparseArray<>(5);
private Bitmap icLauncher;
private Bitmap icDownloadDone;

View File

@ -96,21 +96,21 @@ public class MissionAdapter extends Adapter<ViewHolder> 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<ViewHolderItem> mPendingDownloadsItems = new ArrayList<>();
private Handler mHandler;
private final DownloadManager.MissionIterator mIterator;
private final ArrayList<ViewHolderItem> 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<Mission> mHidden;
private final View mView;
private final ArrayList<Mission> mHidden;
private Snackbar mSnackbar;
private final Runnable rUpdater = this::updater;
@ -976,7 +976,7 @@ public class MissionAdapter extends Adapter<ViewHolder> implements Handler.Callb
}
}
class ViewHolderHeader extends RecyclerView.ViewHolder {
static class ViewHolderHeader extends RecyclerView.ViewHolder {
TextView header;
ViewHolderHeader(View view) {

View File

@ -27,12 +27,12 @@ public class Deleter {
private ArrayList<Mission> 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;

View File

@ -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) {

View File

@ -81,7 +81,7 @@ public class TabsJsonHelperTest {
private boolean isTabsArrayEmpty(final String returnedJson) throws JsonParserException {
final JsonObject jsonObject = JsonParser.object().from(returnedJson);
assertTrue(jsonObject.containsKey(JSON_TABS_ARRAY_KEY));
return jsonObject.getArray(JSON_TABS_ARRAY_KEY).size() == 0;
return jsonObject.getArray(JSON_TABS_ARRAY_KEY).isEmpty();
}
@Test

View File

@ -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