Push conditionals inside branch expressions

This commit is contained in:
TacoTheDank 2020-10-31 15:57:26 -04:00
parent 6909d1e527
commit 31cffa68c5
7 changed files with 26 additions and 26 deletions

View file

@ -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");

View file

@ -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);
}
}

View file

@ -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;
}

View file

@ -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));
}
}
}

View file

@ -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) {

View file

@ -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();
}

View file

@ -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();
}