diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java index 17d079d50..93398d990 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java @@ -646,7 +646,7 @@ public class DownloadDialog extends DialogFragment mainStorage = mainStorageVideo; // subtitle & video files go together format = subtitleStreamsAdapter.getItem(selectedSubtitleIndex).getFormat(); mime = format.mimeType; - filename += format == MediaFormat.TTML ? MediaFormat.SRT.suffix : format.suffix; + filename += (format == MediaFormat.TTML ? MediaFormat.SRT : format).suffix; break; default: throw new RuntimeException("No stream selected"); 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 e71e7f19c..cd4a3a083 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 @@ -1246,9 +1246,9 @@ public class VideoDetailFragment final DisplayMetrics metrics = getResources().getDisplayMetrics(); if (getView() != null) { - final int height = isInMultiWindow() - ? requireView().getHeight() - : activity.getWindow().getDecorView().getHeight(); + final int height = (isInMultiWindow() + ? requireView() + : activity.getWindow().getDecorView()).getHeight(); setHeightThumbnail(height, metrics); getView().getViewTreeObserver().removeOnPreDrawListener(preDrawListener); } @@ -1269,9 +1269,9 @@ public class VideoDetailFragment requireView().getViewTreeObserver().removeOnPreDrawListener(preDrawListener); if (player != null && player.isFullscreen()) { - final int height = isInMultiWindow() - ? requireView().getHeight() - : activity.getWindow().getDecorView().getHeight(); + final int height = (isInMultiWindow() + ? requireView() + : activity.getWindow().getDecorView()).getHeight(); // Height is zero when the view is not yet displayed like after orientation change if (height != 0) { setHeightThumbnail(height, metrics); @@ -1279,9 +1279,9 @@ public class VideoDetailFragment requireView().getViewTreeObserver().addOnPreDrawListener(preDrawListener); } } else { - final int height = isPortrait - ? (int) (metrics.widthPixels / (16.0f / 9.0f)) - : (int) (metrics.heightPixels / 2.0f); + final int height = (int) (isPortrait + ? metrics.widthPixels / (16.0f / 9.0f) + : metrics.heightPixels / 2.0f); setHeightThumbnail(height, metrics); } } diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index e8554e5ac..ea205bbdf 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -225,9 +225,9 @@ public final class MainPlayer extends Service { // DisplayMetrics from activity context knows about MultiWindow feature // while DisplayMetrics from app context doesn't final DisplayMetrics metrics = (playerImpl != null - && playerImpl.getParentActivity() != null) - ? playerImpl.getParentActivity().getResources().getDisplayMetrics() - : getResources().getDisplayMetrics(); + && playerImpl.getParentActivity() != null + ? playerImpl.getParentActivity().getResources() + : getResources()).getDisplayMetrics(); return metrics.heightPixels < metrics.widthPixels; } diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 72f56cb1b..8b606260a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -748,11 +748,10 @@ public abstract class ServicePlayerActivity extends AppCompatActivity //2) Icon change accordingly to current App Theme // using rootView.getContext() because getApplicationContext() didn't work - item.setIcon(player.isMuted() - ? ThemeHelper.resolveResourceIdFromAttr(rootView.getContext(), - R.attr.ic_volume_off) - : ThemeHelper.resolveResourceIdFromAttr(rootView.getContext(), - R.attr.ic_volume_up)); + item.setIcon(ThemeHelper.resolveResourceIdFromAttr(rootView.getContext(), + player.isMuted() + ? R.attr.ic_volume_off + : R.attr.ic_volume_up)); } } } diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java index 1d1d056a8..4b52aa27d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java @@ -84,12 +84,12 @@ public final class PlayerHelper { final int days = (milliSeconds % (86400000 * 7)) / 86400000; STRING_BUILDER.setLength(0); - return days > 0 + return (days > 0 ? STRING_FORMATTER.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds) - .toString() : hours > 0 - ? STRING_FORMATTER.format("%d:%02d:%02d", hours, minutes, seconds).toString() - : STRING_FORMATTER.format("%02d:%02d", minutes, seconds).toString(); + ? STRING_FORMATTER.format("%d:%02d:%02d", hours, minutes, seconds) + : STRING_FORMATTER.format("%02d:%02d", minutes, seconds) + ).toString(); } public static String formatSpeed(final double speed) { diff --git a/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java b/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java index 8f6070ff4..8f7e18a31 100644 --- a/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java +++ b/app/src/main/java/us/shandian/giga/io/StoredDirectoryHelper.java @@ -212,7 +212,7 @@ public class StoredDirectoryHelper { @NonNull @Override public String toString() { - return docTree == null ? Uri.fromFile(ioTree).toString() : docTree.getUri().toString(); + return (docTree == null ? Uri.fromFile(ioTree) : docTree.getUri()).toString(); } diff --git a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java index 35f40aa82..265491b8a 100644 --- a/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java +++ b/app/src/main/java/us/shandian/giga/ui/fragment/MissionsFragment.java @@ -224,9 +224,10 @@ public class MissionsFragment extends Fragment { mList.setAdapter(mAdapter); if (mSwitch != null) { - mSwitch.setIcon(mLinear - ? ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_grid) - : ThemeHelper.resolveResourceIdFromAttr(requireContext(), R.attr.ic_list)); + mSwitch.setIcon(ThemeHelper.resolveResourceIdFromAttr( + requireContext(), mLinear + ? R.attr.ic_grid + : R.attr.ic_list)); mSwitch.setTitle(mLinear ? R.string.grid : R.string.list); mPrefs.edit().putBoolean("linear", mLinear).apply(); }