From feb03f7e30ad1e5efecf0a1555df574673c693a3 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Mon, 15 Aug 2022 21:01:12 +0530 Subject: [PATCH] Use Math.floorDiv(). --- .../schabi/newpipe/fragments/list/BaseListFragment.java | 3 +-- .../org/schabi/newpipe/local/BaseLocalListFragment.java | 3 +-- .../main/java/org/schabi/newpipe/streams/WebMWriter.java | 2 +- app/src/main/java/us/shandian/giga/util/Utility.java | 8 ++++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java index 633ba5d78..1212cf4ad 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java @@ -215,8 +215,7 @@ public abstract class BaseListFragment extends BaseStateFragment final Resources resources = activity.getResources(); int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width); width += (24 * resources.getDisplayMetrics().density); - final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels - / (double) width); + final int spanCount = Math.floorDiv(resources.getDisplayMetrics().widthPixels, width); final GridLayoutManager lm = new GridLayoutManager(activity, spanCount); lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount)); return lm; diff --git a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java index 8790c3059..7474537fa 100644 --- a/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java @@ -104,8 +104,7 @@ public abstract class BaseLocalListFragment extends BaseStateFragment final Resources resources = activity.getResources(); int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width); width += (24 * resources.getDisplayMetrics().density); - final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels - / (double) width); + final int spanCount = Math.floorDiv(resources.getDisplayMetrics().widthPixels, width); final GridLayoutManager lm = new GridLayoutManager(activity, spanCount); lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount)); return lm; diff --git a/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java b/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java index 2b69f23ac..530959d96 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java +++ b/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java @@ -652,7 +652,7 @@ public class WebMWriter implements Closeable { final int offset = withLength ? 1 : 0; 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; for (int i = length - 1; i >= 0; i--, shift += 8) { diff --git a/app/src/main/java/us/shandian/giga/util/Utility.java b/app/src/main/java/us/shandian/giga/util/Utility.java index 4cd424ab9..3c86682d0 100644 --- a/app/src/main/java/us/shandian/giga/util/Utility.java +++ b/app/src/main/java/us/shandian/giga/util/Utility.java @@ -248,10 +248,10 @@ public class Utility { return number < 10 ? ("0" + number) : String.valueOf(number); } - public static String stringifySeconds(double seconds) { - int h = (int) Math.floor(seconds / 3600); - int m = (int) Math.floor((seconds - (h * 3600)) / 60); - int s = (int) (seconds - (h * 3600) - (m * 60)); + public static String stringifySeconds(final long seconds) { + final int h = (int) Math.floorDiv(seconds, 3600); + final int m = (int) Math.floorDiv(seconds - (h * 3600L), 60); + final int s = (int) (seconds - (h * 3600) - (m * 60)); String str = "";