Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (getSupportFragmentManager() != null
&& getSupportFragmentManager().getBackStackEntryCount() == 0) {
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
initFragments();
}

Expand Down
7 changes: 3 additions & 4 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ private void openDownloadDialog() {
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);
Expand All @@ -534,9 +534,8 @@ private void openDownloadDialog() {
downloadDialog.show(fm, "downloadDialog");
fm.executePendingTransactions();
downloadDialog.requireDialog().setOnDismissListener(dialog -> finish());
}, (@NonNull Throwable throwable) -> {
showUnsupportedUrlDialog(currentUrl);
}));
}, throwable ->
showUnsupportedUrlDialog(currentUrl)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/about/License.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public License[] newArray(final int size) {
};
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ public void onScrolled(final RecyclerView recyclerView, final int dx, final int
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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;
Expand Down Expand Up @@ -731,7 +730,7 @@ protected void initListeners() {
}

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;
Expand Down Expand Up @@ -948,7 +947,7 @@ private void runWorker(final boolean forceLoad, final boolean addToBackStack) {
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(
Expand All @@ -969,7 +968,7 @@ private void runWorker(final boolean forceLoad, final boolean addToBackStack) {
openVideoPlayer();
}
}
}, (@NonNull final Throwable throwable) -> {
}, throwable -> {
isLoading.set(false);
onError(throwable);
});
Expand Down Expand Up @@ -1140,7 +1139,7 @@ private PlayQueue setupPlayQueueForIntent(final boolean append) {

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

Expand Down Expand Up @@ -1224,12 +1223,12 @@ private void prepareDescription(final Description description) {

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);
}));
Expand Down Expand Up @@ -1346,19 +1345,24 @@ private void setupBroadcastReceiver() {
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;
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void handleResult(@NonNull final I result) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void onResume() {
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) {
Expand Down Expand Up @@ -977,7 +977,7 @@ public void handleResult(@NonNull final SearchInfo result) {
lastSearchedString = searchString;
nextPage = result.getNextPage();

if (infoListAdapter.getItemsList().size() == 0) {
if (infoListAdapter.getItemsList().isEmpty()) {
if (!result.getRelatedItems().isEmpty()) {
infoListAdapter.addInfoItemList(result.getRelatedItems());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
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;

/*//////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public int getSpanSize(final int position) {
};
}

public class HFHolder extends RecyclerView.ViewHolder {
public static class HFHolder extends RecyclerView.ViewHolder {
public View view;

HFHolder(final View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,7 @@ public PlaybackParameters getPlaybackParameters() {
if (simpleExoPlayer == null) {
return PlaybackParameters.DEFAULT;
}
final PlaybackParameters parameters = simpleExoPlayer.getPlaybackParameters();
return parameters == null ? PlaybackParameters.DEFAULT : parameters;
return simpleExoPlayer.getPlaybackParameters();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ protected void setupSubtitleView(final @NonNull SubtitleView view,
view.setFixedTextSize(TypedValue.COMPLEX_UNIT_PX,
(float) minimumLength / captionRatioInverse);
}
view.setApplyEmbeddedStyles(captionStyle.equals(CaptionStyleCompat.DEFAULT));
view.setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT);
view.setStyle(captionStyle);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int pos
}
}

public class HFHolder extends RecyclerView.ViewHolder {
public static class HFHolder extends RecyclerView.ViewHolder {
public View view;

public HFHolder(final View v) {
Expand Down
Loading