Merge pull request #8810 from Isira-Seneviratne/Math_floorDiv

Use Math.floorDiv().
This commit is contained in:
Stypox 2022-12-04 18:08:12 +01:00 committed by GitHub
commit 9c4d5526f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 9 deletions

View File

@ -215,8 +215,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
final Resources resources = activity.getResources(); final Resources resources = activity.getResources();
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width); int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
width += (24 * resources.getDisplayMetrics().density); width += (24 * resources.getDisplayMetrics().density);
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels final int spanCount = Math.floorDiv(resources.getDisplayMetrics().widthPixels, width);
/ (double) width);
final GridLayoutManager lm = new GridLayoutManager(activity, spanCount); final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount)); lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
return lm; return lm;

View File

@ -104,8 +104,7 @@ public abstract class BaseLocalListFragment<I, N> extends BaseStateFragment<I>
final Resources resources = activity.getResources(); final Resources resources = activity.getResources();
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width); int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
width += (24 * resources.getDisplayMetrics().density); width += (24 * resources.getDisplayMetrics().density);
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels final int spanCount = Math.floorDiv(resources.getDisplayMetrics().widthPixels, width);
/ (double) width);
final GridLayoutManager lm = new GridLayoutManager(activity, spanCount); final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount)); lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount));
return lm; return lm;

View File

@ -652,7 +652,7 @@ public class WebMWriter implements Closeable {
final int offset = withLength ? 1 : 0; final int offset = withLength ? 1 : 0;
final byte[] buffer = new byte[offset + length]; final byte[] buffer = new byte[offset + length];
final long marker = (long) Math.floor((length - 1f) / 8f); final long marker = Math.floorDiv(length - 1, 8);
int shift = 0; int shift = 0;
for (int i = length - 1; i >= 0; i--, shift += 8) { for (int i = length - 1; i >= 0; i--, shift += 8) {

View File

@ -236,10 +236,10 @@ public class Utility {
return number < 10 ? ("0" + number) : String.valueOf(number); return number < 10 ? ("0" + number) : String.valueOf(number);
} }
public static String stringifySeconds(double seconds) { public static String stringifySeconds(final long seconds) {
int h = (int) Math.floor(seconds / 3600); final int h = (int) Math.floorDiv(seconds, 3600);
int m = (int) Math.floor((seconds - (h * 3600)) / 60); final int m = (int) Math.floorDiv(seconds - (h * 3600L), 60);
int s = (int) (seconds - (h * 3600) - (m * 60)); final int s = (int) (seconds - (h * 3600) - (m * 60));
String str = ""; String str = "";