1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-25 04:22:30 +01:00

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()
.add(R.id.menu_tabs_group, kioskId, 0, KioskTranslator
.getTranslatedKioskName(ks, this))
.setIcon(KioskTranslator.getKioskIcon(ks, this));
.setIcon(KioskTranslator.getKioskIcon(ks));
kioskId++;
}

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.fragments;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
@ -10,7 +11,7 @@ import androidx.recyclerview.widget.StaggeredGridLayoutManager;
*/
public abstract class OnScrollBelowItemsListener extends RecyclerView.OnScrollListener {
@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);
if (dy > 0) {
int pastVisibleItems = 0;

View File

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

View File

@ -342,7 +342,8 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
itemsList.clearOnScrollListeners();
itemsList.addOnScrollListener(new DefaultItemListOnScrolledDownListener() {
@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);
if (dy != 0) {

View File

@ -7,6 +7,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import org.schabi.newpipe.R;
@ -34,8 +35,10 @@ public class SuggestionListAdapter
this.listener = listener;
}
@NonNull
@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)
.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.
* @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
*/
public Builder addPlayWithKodiEntryIfNeeded() {

View File

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

View File

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

View File

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

View File

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

View File

@ -61,7 +61,7 @@ public class ImportConfirmationDialog extends DialogFragment {
}
@Override
public void onSaveInstanceState(final Bundle outState) {
public void onSaveInstanceState(@NonNull final Bundle outState) {
super.onSaveInstanceState(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.Flowable
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.functions.BiFunction
import io.reactivex.rxjava3.processors.BehaviorProcessor
import io.reactivex.rxjava3.schedulers.Schedulers
import org.schabi.newpipe.database.feed.model.FeedGroupEntity
@ -33,9 +32,8 @@ class FeedGroupDialogViewModel(
private var subscriptionsFlowable = Flowable
.combineLatest(
filterSubscriptions.startWithItem(initialQuery),
toggleShowOnlyUngrouped.startWithItem(initialShowOnlyUngrouped),
BiFunction { t1: String, t2: Boolean -> Filter(t1, t2) }
)
toggleShowOnlyUngrouped.startWithItem(initialShowOnlyUngrouped)
) { t1: String, t2: Boolean -> Filter(t1, t2) }
.distinctUntilChanged()
.switchMap { (query, showOnlyUngrouped) ->
subscriptionManager.getSubscriptions(groupId, query, showOnlyUngrouped)
@ -56,9 +54,8 @@ class FeedGroupDialogViewModel(
private var subscriptionsDisposable = Flowable
.combineLatest(
subscriptionsFlowable, feedDatabaseManager.subscriptionIdsForGroup(groupId),
BiFunction { t1: List<PickerSubscriptionItem>, t2: List<Long> -> t1 to t2.toSet() }
)
subscriptionsFlowable, feedDatabaseManager.subscriptionIdsForGroup(groupId)
) { t1: List<PickerSubscriptionItem>, t2: List<Long> -> t1 to t2.toSet() }
.subscribeOn(Schedulers.io())
.subscribe(mutableSubscriptionsLiveData::postValue)

View File

@ -57,15 +57,12 @@ class FeedGroupReorderDialog : DialogFragment() {
viewModel = ViewModelProvider(this).get(FeedGroupReorderDialogViewModel::class.java)
viewModel.groupsLiveData.observe(viewLifecycleOwner, Observer(::handleGroups))
viewModel.dialogEventLiveData.observe(
viewLifecycleOwner,
Observer {
when (it) {
ProcessingEvent -> disableInput()
SuccessEvent -> dismiss()
}
viewModel.dialogEventLiveData.observe(viewLifecycleOwner) {
when (it) {
ProcessingEvent -> disableInput()
SuccessEvent -> dismiss()
}
)
}
binding.feedGroupsList.layoutManager = LinearLayoutManager(requireContext())
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 android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
@ -601,7 +600,6 @@ public final class PlayQueueActivity extends AppCompatActivity
//2) Icon change accordingly to current App Theme
// 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);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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