1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-04 17:16:24 +00:00

Restore checkstyle and solve its errors

This commit is contained in:
Stypox 2022-04-16 12:03:59 +02:00
parent 1b39b5376f
commit a19073ec01
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
10 changed files with 41 additions and 36 deletions

View File

@ -166,7 +166,7 @@ afterEvaluate {
if (!System.properties.containsKey('skipFormatKtlint')) {
preDebugBuild.dependsOn formatKtlint
}
//preDebugBuild.dependsOn runCheckstyle, runKtlint
preDebugBuild.dependsOn runCheckstyle, runKtlint
}
sonarqube {

View File

@ -1,5 +1,16 @@
package org.schabi.newpipe.fragments.detail;
import static android.text.TextUtils.isEmpty;
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
import static org.schabi.newpipe.extractor.stream.StreamExtractor.NO_AGE_LIMIT;
import static org.schabi.newpipe.ktx.ViewUtils.animate;
import static org.schabi.newpipe.ktx.ViewUtils.animateRotation;
import static org.schabi.newpipe.player.helper.PlayerHelper.globalScreenOrientationLocked;
import static org.schabi.newpipe.player.helper.PlayerHelper.isClearingQueueConfirmationRequired;
import static org.schabi.newpipe.player.playqueue.PlayQueueItem.RECOVERY_UNSET;
import static org.schabi.newpipe.util.ExtractorHelper.showMetaInfoInTextView;
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.BroadcastReceiver;
@ -43,7 +54,6 @@ import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
import androidx.viewbinding.ViewBinding;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.PlaybackParameters;
@ -78,9 +88,9 @@ import org.schabi.newpipe.fragments.list.videos.RelatedItemsFragment;
import org.schabi.newpipe.ktx.AnimationType;
import org.schabi.newpipe.local.dialog.PlaylistDialog;
import org.schabi.newpipe.local.history.HistoryRecordManager;
import org.schabi.newpipe.player.Player;
import org.schabi.newpipe.player.PlayerService;
import org.schabi.newpipe.player.PlayerService.PlayerType;
import org.schabi.newpipe.player.Player;
import org.schabi.newpipe.player.event.OnKeyDownListener;
import org.schabi.newpipe.player.event.PlayerServiceExtendedEventListener;
import org.schabi.newpipe.player.helper.PlayerHelper;
@ -118,17 +128,6 @@ import io.reactivex.rxjava3.disposables.CompositeDisposable;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import static android.text.TextUtils.isEmpty;
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
import static org.schabi.newpipe.extractor.stream.StreamExtractor.NO_AGE_LIMIT;
import static org.schabi.newpipe.ktx.ViewUtils.animate;
import static org.schabi.newpipe.ktx.ViewUtils.animateRotation;
import static org.schabi.newpipe.player.helper.PlayerHelper.globalScreenOrientationLocked;
import static org.schabi.newpipe.player.helper.PlayerHelper.isClearingQueueConfirmationRequired;
import static org.schabi.newpipe.player.playqueue.PlayQueueItem.RECOVERY_UNSET;
import static org.schabi.newpipe.util.ExtractorHelper.showMetaInfoInTextView;
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
public final class VideoDetailFragment
extends BaseStateFragment<StreamInfo>
implements BackPressable,

View File

@ -239,6 +239,7 @@ public final class Player implements PlaybackListener, Listener {
// UIs, listeners and disposables
//////////////////////////////////////////////////////////////////////////*/
@SuppressWarnings("MemberName") // keep the unusual member name
private final PlayerUiList UIs = new PlayerUiList();
private BroadcastReceiver broadcastReceiver;
@ -1148,7 +1149,7 @@ public final class Player implements PlaybackListener, Listener {
simpleExoPlayer.setRepeatMode(repeatMode);
}
}
public void cycleNextRepeatMode() {
setRepeatMode(nextRepeatMode(getRepeatMode()));
}
@ -1181,7 +1182,7 @@ public final class Player implements PlaybackListener, Listener {
UIs.call(playerUi -> playerUi.onShuffleModeEnabledChanged(shuffleModeEnabled));
notifyPlaybackUpdateToListeners();
}
public void toggleShuffleModeEnabled() {
if (!exoPlayerIsNull()) {
simpleExoPlayer.setShuffleModeEnabled(!simpleExoPlayer.getShuffleModeEnabled());
@ -2301,6 +2302,7 @@ public final class Player implements PlaybackListener, Listener {
/**
* @return the user interfaces connected with the player
*/
@SuppressWarnings("MethodName") // keep the unusual method name
public PlayerUiList UIs() {
return UIs;
}

View File

@ -132,7 +132,7 @@ public final class NotificationUtil {
// also update content intent, in case the user switched players
notificationBuilder.setContentIntent(PendingIntent.getActivity(player.getContext(),
NOTIFICATION_ID, getIntentForNotification(player), FLAG_UPDATE_CURRENT));
NOTIFICATION_ID, getIntentForNotification(), FLAG_UPDATE_CURRENT));
notificationBuilder.setContentTitle(player.getVideoTitle());
notificationBuilder.setContentText(player.getUploaderName());
notificationBuilder.setTicker(player.getVideoTitle());
@ -321,7 +321,7 @@ public final class NotificationUtil {
new Intent(intentAction), FLAG_UPDATE_CURRENT));
}
private Intent getIntentForNotification(final Player player) {
private Intent getIntentForNotification() {
if (player.audioPlayerSelected() || player.popupPlayerSelected()) {
// Means we play in popup or audio only. Let's show the play queue
return NavigationHelper.getPlayQueueActivityIntent(player.getContext());

View File

@ -10,8 +10,6 @@ import org.schabi.newpipe.player.mediasession.MediaSessionCallback;
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
import org.schabi.newpipe.player.ui.VideoPlayerUi;
import java.util.Optional;
public class PlayerMediaSession implements MediaSessionCallback {
private final Player player;

View File

@ -497,7 +497,7 @@ public final class MainPlayerUi extends VideoPlayerUi implements View.OnLayoutCh
//region Captions (text tracks)
@Override
protected void setupSubtitleView(float captionScale) {
protected void setupSubtitleView(final float captionScale) {
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
final int minimumLength = Math.min(metrics.heightPixels, metrics.widthPixels);
final float captionRatioInverse = 20f + 4f * (1.0f - captionScale);

View File

@ -46,7 +46,7 @@ public abstract class PlayerUi {
/**
* Called after the player received an intent and processed it
* Called after the player received an intent and processed it.
*/
public void setupAfterIntent() {
}
@ -80,7 +80,7 @@ public abstract class PlayerUi {
/**
* Called when this UI is being discarded, either because the player is switching to a different
* UI or because the player is shutting down completely
* UI or because the player is shutting down completely.
*/
public void destroy() {
}
@ -88,14 +88,14 @@ public abstract class PlayerUi {
/**
* Called when the player is smooth-stopping, that is, transitioning smoothly to a new play
* queue after the user tapped on a new video stream while a stream was playing in the video
* detail fragment
* detail fragment.
*/
public void smoothStopForImmediateReusing() {
}
/**
* Called when the video detail fragment listener is connected with the player, or right after
* this UI is constructed if the listener is already connected then
* this UI is constructed if the listener is already connected then.
*/
public void onFragmentListenerSet() {
}
@ -104,6 +104,7 @@ public abstract class PlayerUi {
* Broadcasts that the player receives will also be notified to UIs here. If you want to
* register new broadcast actions to receive here, add them to {@link
* Player#setupBroadcastReceiver()}.
* @param intent the broadcast intent received by the player
*/
public void onBroadcastReceived(final Intent intent) {
}
@ -154,12 +155,14 @@ public abstract class PlayerUi {
/**
* @see com.google.android.exoplayer2.Player.Listener#onTracksChanged(Tracks)
* @param currentTracks the available tracks information
*/
public void onTextTracksChanged(@NonNull final Tracks currentTracks) {
}
/**
* @see com.google.android.exoplayer2.Player.Listener#onPlaybackParametersChanged
* @param playbackParameters the new playback parameters
*/
public void onPlaybackParametersChanged(@NonNull final PlaybackParameters playbackParameters) {
}
@ -172,12 +175,13 @@ public abstract class PlayerUi {
/**
* @see com.google.android.exoplayer2.text.TextOutput#onCues
* @param cues the cues to pass to the subtitle view
*/
public void onCues(@NonNull final List<Cue> cues) {
}
/**
* Called when the stream being played changes
* Called when the stream being played changes.
* @param info the {@link StreamInfo} metadata object, along with data about the selected and
* available video streams (to be used to build the resolution menus, for example)
*/
@ -185,7 +189,7 @@ public abstract class PlayerUi {
}
/**
* Called when the thumbnail for the current metadata was loaded
* Called when the thumbnail for the current metadata was loaded.
* @param bitmap the thumbnail to process, or null if there is no thumbnail or there was an
* error when loading the thumbnail
*/

View File

@ -35,7 +35,7 @@ public final class PlayerUiList {
}
/**
* Destroys all matching player UIs and removes them from the list
* Destroys all matching player UIs and removes them from the list.
* @param playerUiType the class of the player UI to destroy; the {@link
* Class#isInstance(Object)} method will be used, so even subclasses will be
* destroyed and removed
@ -67,7 +67,7 @@ public final class PlayerUiList {
}
/**
* Calls the provided consumer on all player UIs in the list
* Calls the provided consumer on all player UIs in the list.
* @param consumer the consumer to call with player UIs
*/
public void call(final Consumer<PlayerUi> consumer) {

View File

@ -86,7 +86,8 @@ import java.util.Optional;
import java.util.stream.Collectors;
public abstract class VideoPlayerUi extends PlayerUi
implements SeekBar.OnSeekBarChangeListener, View.OnClickListener, View.OnLongClickListener, PopupMenu.OnMenuItemClickListener, PopupMenu.OnDismissListener {
implements SeekBar.OnSeekBarChangeListener, View.OnClickListener, View.OnLongClickListener,
PopupMenu.OnMenuItemClickListener, PopupMenu.OnDismissListener {
private static final String TAG = VideoPlayerUi.class.getSimpleName();
// time constants
@ -476,7 +477,7 @@ public abstract class VideoPlayerUi extends PlayerUi
binding.endScreen.setImageBitmap(endScreenBitmap);
}
protected abstract float calculateMaxEndScreenThumbnailHeight(@NonNull final Bitmap bitmap);
protected abstract float calculateMaxEndScreenThumbnailHeight(@NonNull Bitmap bitmap);
//endregion
@ -511,6 +512,7 @@ public abstract class VideoPlayerUi extends PlayerUi
/**
* Sets the current duration into the corresponding elements.
* @param currentProgress the current progress, in milliseconds
*/
private void updatePlayBackElementsCurrentDuration(final int currentProgress) {
// Don't set seekbar progress while user is seeking
@ -522,6 +524,7 @@ public abstract class VideoPlayerUi extends PlayerUi
/**
* Sets the video duration time into all control components (e.g. seekbar).
* @param duration the video duration, in milliseconds
*/
private void setVideoDurationToControls(final int duration) {
binding.playbackEndTime.setText(getTimeString(duration));
@ -1214,7 +1217,7 @@ public abstract class VideoPlayerUi extends PlayerUi
final MediaItemTag.Quality quality = currentMetadata.getMaybeQuality().get();
final List<VideoStream> availableStreams = quality.getSortedVideoStreams();
final int selectedStreamIndex = quality.getSelectedVideoStreamIndex();
if (selectedStreamIndex == menuItemIndex|| availableStreams.size() <= menuItemIndex) {
if (selectedStreamIndex == menuItemIndex || availableStreams.size() <= menuItemIndex) {
return true;
}
@ -1320,7 +1323,7 @@ public abstract class VideoPlayerUi extends PlayerUi
}
@Override
public void onCues(@NonNull List<Cue> cues) {
public void onCues(@NonNull final List<Cue> cues) {
super.onCues(cues);
binding.subtitleView.setCues(cues);
}
@ -1332,7 +1335,7 @@ public abstract class VideoPlayerUi extends PlayerUi
binding.subtitleView.setStyle(captionStyle);
}
protected abstract void setupSubtitleView(final float captionScale);
protected abstract void setupSubtitleView(float captionScale);
//endregion
@ -1518,7 +1521,7 @@ public abstract class VideoPlayerUi extends PlayerUi
}
@Override
public void onVideoSizeChanged(@NonNull VideoSize videoSize) {
public void onVideoSizeChanged(@NonNull final VideoSize videoSize) {
super.onVideoSizeChanged(videoSize);
binding.surfaceView.setAspectRatio(((float) videoSize.width) / videoSize.height);
}

View File

@ -28,7 +28,6 @@ import androidx.preference.PreferenceViewHolder;
import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.ListRadioIconItemBinding;
import org.schabi.newpipe.databinding.SingleChoiceDialogViewBinding;
import org.schabi.newpipe.player.PlayerService;
import org.schabi.newpipe.player.notification.NotificationConstants;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.ThemeHelper;