diff --git a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java index c1c3eb0cd..69bfdfc2a 100644 --- a/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java +++ b/app/src/main/java/org/schabi/newpipe/DownloaderImpl.java @@ -114,8 +114,8 @@ public final class DownloaderImpl extends Downloader { // Necessary because some servers (e.g. Framatube.org) // don't support the old cipher suites. // https://github.com/square/okhttp/issues/4053#issuecomment-402579554 - final List cipherSuites = new ArrayList<>(); - cipherSuites.addAll(ConnectionSpec.MODERN_TLS.cipherSuites()); + final List cipherSuites = + new ArrayList<>(ConnectionSpec.MODERN_TLS.cipherSuites()); cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA); cipherSuites.add(CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA); final ConnectionSpec legacyTLS = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 482e3d32f..27fa94bef 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -568,7 +568,7 @@ public class RouterActivity extends AppCompatActivity { } } } - return result.toArray(new String[result.size()]); + return result.toArray(new String[0]); } private static class AdapterChoiceItem { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 863c4eb7e..2885c9f7b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -672,7 +672,8 @@ public class VideoDetailFragment } break; case R.id.detail_title_root_layout: - ShareUtils.copyToClipboard(requireContext(), videoTitleTextView.getText().toString()); + ShareUtils.copyToClipboard(requireContext(), + videoTitleTextView.getText().toString()); break; } diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java index 9d1f5acbd..da7e8df8b 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/videos/RelatedVideosFragment.java @@ -166,12 +166,10 @@ public class RelatedVideosFragment extends BaseListInfoFragment { info.getOriginalUrl(), info.getUrl(), info.getId(), Collections.emptyList(), null); final RelatedStreamInfo relatedStreamInfo = new RelatedStreamInfo( info.getServiceId(), handler, info.getName()); - final List streams = new ArrayList<>(); - streams.addAll(info.getRelatedStreams()); + final List streams = new ArrayList<>(info.getRelatedStreams()); relatedStreamInfo.setRelatedItems(streams); return relatedStreamInfo; } diff --git a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java index a83e844ea..89dc08f38 100644 --- a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java +++ b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java @@ -106,7 +106,7 @@ public class TLSSocketFactoryCompat extends SSLSocketFactory { } private Socket enableTLSOnSocket(final Socket socket) { - if (socket != null && (socket instanceof SSLSocket)) { + if (socket instanceof SSLSocket) { ((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1.1", "TLSv1.2"}); } return socket; diff --git a/app/src/main/java/us/shandian/giga/get/DownloadMission.java b/app/src/main/java/us/shandian/giga/get/DownloadMission.java index 3f651d2ee..d7c586083 100644 --- a/app/src/main/java/us/shandian/giga/get/DownloadMission.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadMission.java @@ -633,7 +633,7 @@ public class DownloadMission extends Mission { calculated = offsets[current < offsets.length ? current : (offsets.length - 1)] + length; calculated -= offsets[0];// don't count reserved space - return calculated > nearLength ? calculated : nearLength; + return Math.max(calculated, nearLength); } /** diff --git a/app/src/main/java/us/shandian/giga/io/FileStream.java b/app/src/main/java/us/shandian/giga/io/FileStream.java index 2cc4d5db8..bbc56b20c 100644 --- a/app/src/main/java/us/shandian/giga/io/FileStream.java +++ b/app/src/main/java/us/shandian/giga/io/FileStream.java @@ -30,12 +30,12 @@ public class FileStream extends SharpStream { } @Override - public int read(byte b[]) throws IOException { + public int read(byte[] b) throws IOException { return source.read(b); } @Override - public int read(byte b[], int off, int len) throws IOException { + public int read(byte[] b, int off, int len) throws IOException { return source.read(b, off, len); } diff --git a/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java b/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java index 680f484e6..50dbd1c3d 100644 --- a/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java +++ b/app/src/main/java/us/shandian/giga/postprocessing/Postprocessing.java @@ -115,7 +115,7 @@ public abstract class Postprocessing implements Serializable { mission.done = 0; long length = mission.storage.length() - mission.offsets[0]; - mission.length = length > mission.nearLength ? length : mission.nearLength; + mission.length = Math.max(length, mission.nearLength); final ProgressReport readProgress = (long position) -> { position -= mission.offsets[0]; diff --git a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java index d490bcb0f..c9518e477 100644 --- a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java +++ b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java @@ -49,6 +49,7 @@ import java.io.File; import java.lang.ref.WeakReference; import java.net.URI; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import us.shandian.giga.get.DownloadMission; @@ -302,9 +303,7 @@ public class MissionAdapter extends Adapter implements Handler.Callb float averageSpeed = speed; if (h.lastSpeedIdx < 0) { - for (int i = 0; i < h.lastSpeed.length; i++) { - h.lastSpeed[i] = speed; - } + Arrays.fill(h.lastSpeed, speed); h.lastSpeedIdx = 0; } else { for (int i = 0; i < h.lastSpeed.length; i++) {