Merge pull request #8068 from TacoTheDank/lintCleaning

Some lint cleaning
This commit is contained in:
litetex 2022-03-19 14:37:34 +01:00 committed by GitHub
commit 6d2b5d976d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 55 additions and 52 deletions

View file

@ -225,7 +225,7 @@ public class MainActivity extends AppCompatActivity {
drawerLayoutBinding.navigation.getMenu() drawerLayoutBinding.navigation.getMenu()
.add(R.id.menu_tabs_group, kioskId, 0, KioskTranslator .add(R.id.menu_tabs_group, kioskId, 0, KioskTranslator
.getTranslatedKioskName(ks, this)) .getTranslatedKioskName(ks, this))
.setIcon(KioskTranslator.getKioskIcon(ks, this)); .setIcon(KioskTranslator.getKioskIcon(ks));
kioskId++; kioskId++;
} }

View file

@ -1,5 +1,6 @@
package org.schabi.newpipe.fragments; package org.schabi.newpipe.fragments;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager; import androidx.recyclerview.widget.StaggeredGridLayoutManager;
@ -10,7 +11,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager;
*/ */
public abstract class OnScrollBelowItemsListener extends RecyclerView.OnScrollListener { public abstract class OnScrollBelowItemsListener extends RecyclerView.OnScrollListener {
@Override @Override
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) { public void onScrolled(@NonNull final RecyclerView recyclerView, final int dx, final int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
if (dy > 0) { if (dy > 0) {
int pastVisibleItems = 0; int pastVisibleItems = 0;

View file

@ -1,5 +1,7 @@
package org.schabi.newpipe.fragments.detail; package org.schabi.newpipe.fragments.detail;
import androidx.annotation.NonNull;
import org.schabi.newpipe.player.playqueue.PlayQueue; import org.schabi.newpipe.player.playqueue.PlayQueue;
import java.io.Serializable; import java.io.Serializable;
@ -46,6 +48,7 @@ class StackItem implements Serializable {
return playQueue; return playQueue;
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return getServiceId() + ":" + getUrl() + " > " + getTitle(); return getServiceId() + ":" + getUrl() + " > " + getTitle();

View file

@ -342,7 +342,8 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
itemsList.clearOnScrollListeners(); itemsList.clearOnScrollListeners();
itemsList.addOnScrollListener(new DefaultItemListOnScrolledDownListener() { itemsList.addOnScrollListener(new DefaultItemListOnScrolledDownListener() {
@Override @Override
public void onScrolled(final RecyclerView recyclerView, final int dx, final int dy) { public void onScrolled(@NonNull final RecyclerView recyclerView,
final int dx, final int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
if (dy != 0) { if (dy != 0) {

View file

@ -7,6 +7,7 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
@ -34,8 +35,10 @@ public class SuggestionListAdapter
this.listener = listener; this.listener = listener;
} }
@NonNull
@Override @Override
public SuggestionItemHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { public SuggestionItemHolder onCreateViewHolder(@NonNull final ViewGroup parent,
final int viewType) {
return new SuggestionItemHolder(LayoutInflater.from(context) return new SuggestionItemHolder(LayoutInflater.from(context)
.inflate(R.layout.item_search_suggestion, parent, false)); .inflate(R.layout.item_search_suggestion, parent, false));
} }

View file

@ -277,7 +277,7 @@ public final class InfoItemDialog {
} }
/** /**
* Adds {@link StreamDialogDefaultEntry.MARK_AS_WATCHED} if the watch history is enabled * Adds {@link StreamDialogDefaultEntry#MARK_AS_WATCHED} if the watch history is enabled
* and the stream is not a livestream. * and the stream is not a livestream.
* @return the current {@link Builder} instance * @return the current {@link Builder} instance
*/ */
@ -294,7 +294,7 @@ public final class InfoItemDialog {
} }
/** /**
* Adds the {@link StreamDialogDefaultEntry.PLAY_WITH_KODI} entry if it is needed. * Adds the {@link StreamDialogDefaultEntry#PLAY_WITH_KODI} entry if it is needed.
* @return the current {@link Builder} instance * @return the current {@link Builder} instance
*/ */
public Builder addPlayWithKodiEntryIfNeeded() { public Builder addPlayWithKodiEntryIfNeeded() {

View file

@ -97,7 +97,7 @@ public abstract class PlaylistDialog extends DialogFragment implements StateSave
} }
@Override @Override
public void onSaveInstanceState(final Bundle outState) { public void onSaveInstanceState(@NonNull final Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
if (getActivity() != null) { if (getActivity() != null) {
savedState = StateSaver.tryToSave(getActivity().isChangingConfigurations(), savedState = StateSaver.tryToSave(getActivity().isChangingConfigurations(),

View file

@ -50,7 +50,6 @@ import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.xwray.groupie.GroupieAdapter import com.xwray.groupie.GroupieAdapter
import com.xwray.groupie.Item import com.xwray.groupie.Item
import com.xwray.groupie.OnAsyncUpdateListener
import com.xwray.groupie.OnItemClickListener import com.xwray.groupie.OnItemClickListener
import com.xwray.groupie.OnItemLongClickListener import com.xwray.groupie.OnItemLongClickListener
import icepick.State import icepick.State
@ -139,7 +138,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
val factory = FeedViewModel.Factory(requireContext(), groupId) val factory = FeedViewModel.Factory(requireContext(), groupId)
viewModel = ViewModelProvider(this, factory).get(FeedViewModel::class.java) viewModel = ViewModelProvider(this, factory).get(FeedViewModel::class.java)
showPlayedItems = viewModel.getShowPlayedItemsFromPreferences() showPlayedItems = viewModel.getShowPlayedItemsFromPreferences()
viewModel.stateLiveData.observe(viewLifecycleOwner, { it?.let(::handleResult) }) viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let(::handleResult) }
groupAdapter = GroupieAdapter().apply { groupAdapter = GroupieAdapter().apply {
setOnItemClickListener(listenerStreamItem) setOnItemClickListener(listenerStreamItem)
@ -393,14 +392,11 @@ class FeedFragment : BaseStateFragment<FeedState>() {
// This need to be saved in a variable as the update occurs async // This need to be saved in a variable as the update occurs async
val oldOldestSubscriptionUpdate = oldestSubscriptionUpdate val oldOldestSubscriptionUpdate = oldestSubscriptionUpdate
groupAdapter.updateAsync( groupAdapter.updateAsync(loadedState.items, false) {
loadedState.items, false, oldOldestSubscriptionUpdate?.run {
OnAsyncUpdateListener { highlightNewItemsAfter(oldOldestSubscriptionUpdate)
oldOldestSubscriptionUpdate?.run {
highlightNewItemsAfter(oldOldestSubscriptionUpdate)
}
} }
) }
listState?.run { listState?.run {
feedBinding.itemsList.layoutManager?.onRestoreInstanceState(listState) feedBinding.itemsList.layoutManager?.onRestoreInstanceState(listState)

View file

@ -56,7 +56,7 @@ class FeedViewModel(
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
.map { (event, showPlayedItems, notLoadedCount, oldestUpdate) -> .map { (event, showPlayedItems, notLoadedCount, oldestUpdate) ->
var streamItems = if (event is SuccessResultEvent || event is IdleEvent) val streamItems = if (event is SuccessResultEvent || event is IdleEvent)
feedDatabaseManager feedDatabaseManager
.getStreams(groupId, showPlayedItems) .getStreams(groupId, showPlayedItems)
.blockingGet(arrayListOf()) .blockingGet(arrayListOf())

View file

@ -84,7 +84,7 @@ public abstract class HistoryEntryAdapter<E, VH extends RecyclerView.ViewHolder>
} }
@Override @Override
public void onViewRecycled(final VH holder) { public void onViewRecycled(@NonNull final VH holder) {
super.onViewRecycled(holder); super.onViewRecycled(holder);
holder.itemView.setOnClickListener(null); holder.itemView.setOnClickListener(null);
} }

View file

@ -61,7 +61,7 @@ public class ImportConfirmationDialog extends DialogFragment {
} }
@Override @Override
public void onSaveInstanceState(final Bundle outState) { public void onSaveInstanceState(@NonNull final Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
Icepick.saveInstanceState(this, outState); Icepick.saveInstanceState(this, outState);
} }

View file

@ -8,7 +8,6 @@ import androidx.lifecycle.ViewModelProvider
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import io.reactivex.rxjava3.core.Flowable import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.disposables.Disposable import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.functions.BiFunction
import io.reactivex.rxjava3.processors.BehaviorProcessor import io.reactivex.rxjava3.processors.BehaviorProcessor
import io.reactivex.rxjava3.schedulers.Schedulers import io.reactivex.rxjava3.schedulers.Schedulers
import org.schabi.newpipe.database.feed.model.FeedGroupEntity import org.schabi.newpipe.database.feed.model.FeedGroupEntity
@ -33,9 +32,8 @@ class FeedGroupDialogViewModel(
private var subscriptionsFlowable = Flowable private var subscriptionsFlowable = Flowable
.combineLatest( .combineLatest(
filterSubscriptions.startWithItem(initialQuery), filterSubscriptions.startWithItem(initialQuery),
toggleShowOnlyUngrouped.startWithItem(initialShowOnlyUngrouped), toggleShowOnlyUngrouped.startWithItem(initialShowOnlyUngrouped)
BiFunction { t1: String, t2: Boolean -> Filter(t1, t2) } ) { t1: String, t2: Boolean -> Filter(t1, t2) }
)
.distinctUntilChanged() .distinctUntilChanged()
.switchMap { (query, showOnlyUngrouped) -> .switchMap { (query, showOnlyUngrouped) ->
subscriptionManager.getSubscriptions(groupId, query, showOnlyUngrouped) subscriptionManager.getSubscriptions(groupId, query, showOnlyUngrouped)
@ -56,9 +54,8 @@ class FeedGroupDialogViewModel(
private var subscriptionsDisposable = Flowable private var subscriptionsDisposable = Flowable
.combineLatest( .combineLatest(
subscriptionsFlowable, feedDatabaseManager.subscriptionIdsForGroup(groupId), subscriptionsFlowable, feedDatabaseManager.subscriptionIdsForGroup(groupId)
BiFunction { t1: List<PickerSubscriptionItem>, t2: List<Long> -> t1 to t2.toSet() } ) { t1: List<PickerSubscriptionItem>, t2: List<Long> -> t1 to t2.toSet() }
)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.subscribe(mutableSubscriptionsLiveData::postValue) .subscribe(mutableSubscriptionsLiveData::postValue)

View file

@ -57,15 +57,12 @@ class FeedGroupReorderDialog : DialogFragment() {
viewModel = ViewModelProvider(this).get(FeedGroupReorderDialogViewModel::class.java) viewModel = ViewModelProvider(this).get(FeedGroupReorderDialogViewModel::class.java)
viewModel.groupsLiveData.observe(viewLifecycleOwner, Observer(::handleGroups)) viewModel.groupsLiveData.observe(viewLifecycleOwner, Observer(::handleGroups))
viewModel.dialogEventLiveData.observe( viewModel.dialogEventLiveData.observe(viewLifecycleOwner) {
viewLifecycleOwner, when (it) {
Observer { ProcessingEvent -> disableInput()
when (it) { SuccessEvent -> dismiss()
ProcessingEvent -> disableInput()
SuccessEvent -> dismiss()
}
} }
) }
binding.feedGroupsList.layoutManager = LinearLayoutManager(requireContext()) binding.feedGroupsList.layoutManager = LinearLayoutManager(requireContext())
binding.feedGroupsList.adapter = groupAdapter binding.feedGroupsList.adapter = groupAdapter

View file

@ -5,7 +5,6 @@ import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.Bundle; import android.os.Bundle;
@ -601,7 +600,6 @@ public final class PlayQueueActivity extends AppCompatActivity
//2) Icon change accordingly to current App Theme //2) Icon change accordingly to current App Theme
// using rootView.getContext() because getApplicationContext() didn't work // using rootView.getContext() because getApplicationContext() didn't work
final Context context = queueControlBinding.getRoot().getContext();
item.setIcon(player.isMuted() ? R.drawable.ic_volume_off : R.drawable.ic_volume_up); item.setIcon(player.isMuted() ? R.drawable.ic_volume_off : R.drawable.ic_volume_up);
} }
} }

View file

@ -149,7 +149,8 @@ public class AudioReactor implements AudioManager.OnAudioFocusChangeListener, An
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@Override @Override
public void onAudioSessionIdChanged(final EventTime eventTime, final int audioSessionId) { public void onAudioSessionIdChanged(@NonNull final EventTime eventTime,
final int audioSessionId) {
notifyAudioSessionUpdate(true, audioSessionId); notifyAudioSessionUpdate(true, audioSessionId);
} }
private void notifyAudioSessionUpdate(final boolean active, final int audioSessionId) { private void notifyAudioSessionUpdate(final boolean active, final int audioSessionId) {

View file

@ -63,6 +63,7 @@ import java.io.File;
} }
} }
@NonNull
@Override @Override
public DataSource createDataSource() { public DataSource createDataSource() {
Log.d(TAG, "initExoPlayerCache: cacheDir = " + cacheDir.getAbsolutePath()); Log.d(TAG, "initExoPlayerCache: cacheDir = " + cacheDir.getAbsolutePath());
@ -86,8 +87,8 @@ import java.io.File;
Log.d(TAG, "tryDeleteCacheFiles: " + filePath + " deleted = " + deleteSuccessful); Log.d(TAG, "tryDeleteCacheFiles: " + filePath + " deleted = " + deleteSuccessful);
} }
} catch (final Exception ignored) { } catch (final Exception e) {
Log.e(TAG, "Failed to delete file.", ignored); Log.e(TAG, "Failed to delete file.", e);
} }
} }
} }

View file

@ -135,9 +135,7 @@ public class MediaSessionManager {
lastTitleHashCode = title.hashCode(); lastTitleHashCode = title.hashCode();
lastArtistHashCode = artist.hashCode(); lastArtistHashCode = artist.hashCode();
lastDuration = duration; lastDuration = duration;
if (optAlbumArt.isPresent()) { optAlbumArt.ifPresent(bitmap -> lastAlbumArtHashCode = bitmap.hashCode());
lastAlbumArtHashCode = optAlbumArt.get().hashCode();
}
} }
private boolean checkIfMetadataShouldBeSet( private boolean checkIfMetadataShouldBeSet(

View file

@ -126,7 +126,7 @@ public class PlaybackParameterDialog extends DialogFragment {
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@Override @Override
public void onAttach(final Context context) { public void onAttach(@NonNull final Context context) {
super.onAttach(context); super.onAttach(context);
if (context instanceof Callback) { if (context instanceof Callback) {
callback = (Callback) context; callback = (Callback) context;
@ -151,7 +151,7 @@ public class PlaybackParameterDialog extends DialogFragment {
} }
@Override @Override
public void onSaveInstanceState(final Bundle outState) { public void onSaveInstanceState(@NonNull final Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
outState.putDouble(INITIAL_TEMPO_KEY, initialTempo); outState.putDouble(INITIAL_TEMPO_KEY, initialTempo);
outState.putDouble(INITIAL_PITCH_KEY, initialPitch); outState.putDouble(INITIAL_PITCH_KEY, initialPitch);

View file

@ -185,7 +185,7 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
} }
@Override @Override
public boolean onPreferenceTreeClick(final Preference preference) { public boolean onPreferenceTreeClick(@NonNull final Preference preference) {
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "onPreferenceTreeClick() called with: " Log.d(TAG, "onPreferenceTreeClick() called with: "
+ "preference = [" + preference + "]"); + "preference = [" + preference + "]");

View file

@ -169,7 +169,7 @@ public class SettingsActivity extends AppCompatActivity implements
} }
@Override @Override
public boolean onPreferenceStartFragment(final PreferenceFragmentCompat caller, public boolean onPreferenceStartFragment(@NonNull final PreferenceFragmentCompat caller,
final Preference preference) { final Preference preference) {
showSettingsFragment(instantiateFragment(preference.getFragment())); showSettingsFragment(instantiateFragment(preference.getFragment()));
return true; return true;

View file

@ -115,6 +115,7 @@ public final class SettingsResourceRegistry {
return this; return this;
} }
@NonNull
public Class<? extends Fragment> getFragmentClass() { public Class<? extends Fragment> getFragmentClass() {
return fragmentClass; return fragmentClass;
} }

View file

@ -50,7 +50,7 @@ public class NotificationActionsPreference extends Preference {
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@Override @Override
public void onBindViewHolder(final PreferenceViewHolder holder) { public void onBindViewHolder(@NonNull final PreferenceViewHolder holder) {
super.onBindViewHolder(holder); super.onBindViewHolder(holder);
holder.itemView.setClickable(false); holder.itemView.setClickable(false);

View file

@ -4,6 +4,7 @@ import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -11,7 +12,7 @@ import java.util.stream.Stream;
public class PreferenceSearchConfiguration { public class PreferenceSearchConfiguration {
private PreferenceSearchFunction searcher = new PreferenceFuzzySearchFunction(); private PreferenceSearchFunction searcher = new PreferenceFuzzySearchFunction();
private final List<String> parserIgnoreElements = Arrays.asList( private final List<String> parserIgnoreElements = Collections.singletonList(
PreferenceCategory.class.getSimpleName()); PreferenceCategory.class.getSimpleName());
private final List<String> parserContainerElements = Arrays.asList( private final List<String> parserContainerElements = Arrays.asList(
PreferenceCategory.class.getSimpleName(), PreferenceCategory.class.getSimpleName(),

View file

@ -58,22 +58,27 @@ public class PreferenceSearchItem {
this.searchIndexItemResId = searchIndexItemResId; this.searchIndexItemResId = searchIndexItemResId;
} }
@NonNull
public String getKey() { public String getKey() {
return key; return key;
} }
@NonNull
public String getTitle() { public String getTitle() {
return title; return title;
} }
@NonNull
public String getSummary() { public String getSummary() {
return summary; return summary;
} }
@NonNull
public String getEntries() { public String getEntries() {
return entries; return entries;
} }
@NonNull
public String getBreadcrumbs() { public String getBreadcrumbs() {
return breadcrumbs; return breadcrumbs;
} }
@ -94,7 +99,7 @@ public class PreferenceSearchItem {
getBreadcrumbs()); getBreadcrumbs());
} }
@NonNull
@Override @Override
public String toString() { public String toString() {
return "PreferenceItem: " + title + " " + summary + " " + key; return "PreferenceItem: " + title + " " + summary + " " + key;

View file

@ -340,7 +340,7 @@ public abstract class Tab {
@DrawableRes @DrawableRes
@Override @Override
public int getTabIconRes(final Context context) { public int getTabIconRes(final Context context) {
final int kioskIcon = KioskTranslator.getKioskIcon(kioskId, context); final int kioskIcon = KioskTranslator.getKioskIcon(kioskId);
if (kioskIcon <= 0) { if (kioskIcon <= 0) {
throw new IllegalStateException("Kiosk ID is not valid: \"" + kioskId + "\""); throw new IllegalStateException("Kiosk ID is not valid: \"" + kioskId + "\"");
@ -496,7 +496,7 @@ public abstract class Tab {
@DrawableRes @DrawableRes
@Override @Override
public int getTabIconRes(final Context context) { public int getTabIconRes(final Context context) {
return KioskTranslator.getKioskIcon(getDefaultKioskId(context), context); return KioskTranslator.getKioskIcon(getDefaultKioskId(context));
} }
@Override @Override

View file

@ -57,7 +57,7 @@ public final class KioskTranslator {
} }
} }
public static int getKioskIcon(final String kioskId, final Context c) { public static int getKioskIcon(final String kioskId) {
switch (kioskId) { switch (kioskId) {
case "Trending": case "Trending":
case "Top 50": case "Top 50":