Skip to content

Commit 9c4d552

Browse files
authored
Merge pull request #8810 from Isira-Seneviratne/Math_floorDiv
Use Math.floorDiv().
2 parents 77737a5 + feb03f7 commit 9c4d552

4 files changed

Lines changed: 7 additions & 9 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/list/BaseListFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ protected RecyclerView.LayoutManager getGridLayoutManager() {
215215
final Resources resources = activity.getResources();
216216
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
217217
width += (24 * resources.getDisplayMetrics().density);
218-
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels
219-
/ (double) width);
218+
final int spanCount = Math.floorDiv(resources.getDisplayMetrics().widthPixels, width);
220219
final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
221220
lm.setSpanSizeLookup(infoListAdapter.getSpanSizeLookup(spanCount));
222221
return lm;

app/src/main/java/org/schabi/newpipe/local/BaseLocalListFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ protected RecyclerView.LayoutManager getGridLayoutManager() {
104104
final Resources resources = activity.getResources();
105105
int width = resources.getDimensionPixelSize(R.dimen.video_item_grid_thumbnail_image_width);
106106
width += (24 * resources.getDisplayMetrics().density);
107-
final int spanCount = (int) Math.floor(resources.getDisplayMetrics().widthPixels
108-
/ (double) width);
107+
final int spanCount = Math.floorDiv(resources.getDisplayMetrics().widthPixels, width);
109108
final GridLayoutManager lm = new GridLayoutManager(activity, spanCount);
110109
lm.setSpanSizeLookup(itemListAdapter.getSpanSizeLookup(spanCount));
111110
return lm;

app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ private byte[] encode(final long number, final boolean withLength) {
652652

653653
final int offset = withLength ? 1 : 0;
654654
final byte[] buffer = new byte[offset + length];
655-
final long marker = (long) Math.floor((length - 1f) / 8f);
655+
final long marker = Math.floorDiv(length - 1, 8);
656656

657657
int shift = 0;
658658
for (int i = length - 1; i >= 0; i--, shift += 8) {

app/src/main/java/us/shandian/giga/util/Utility.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ private static String pad(int number) {
236236
return number < 10 ? ("0" + number) : String.valueOf(number);
237237
}
238238

239-
public static String stringifySeconds(double seconds) {
240-
int h = (int) Math.floor(seconds / 3600);
241-
int m = (int) Math.floor((seconds - (h * 3600)) / 60);
242-
int s = (int) (seconds - (h * 3600) - (m * 60));
239+
public static String stringifySeconds(final long seconds) {
240+
final int h = (int) Math.floorDiv(seconds, 3600);
241+
final int m = (int) Math.floorDiv(seconds - (h * 3600L), 60);
242+
final int s = (int) (seconds - (h * 3600) - (m * 60));
243243

244244
String str = "";
245245

0 commit comments

Comments
 (0)