Skip to content

Commit feb03f7

Browse files
Use Math.floorDiv().
1 parent 95a65d5 commit feb03f7

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
@@ -248,10 +248,10 @@ private static String pad(int number) {
248248
return number < 10 ? ("0" + number) : String.valueOf(number);
249249
}
250250

251-
public static String stringifySeconds(double seconds) {
252-
int h = (int) Math.floor(seconds / 3600);
253-
int m = (int) Math.floor((seconds - (h * 3600)) / 60);
254-
int s = (int) (seconds - (h * 3600) - (m * 60));
251+
public static String stringifySeconds(final long seconds) {
252+
final int h = (int) Math.floorDiv(seconds, 3600);
253+
final int m = (int) Math.floorDiv(seconds - (h * 3600L), 60);
254+
final int s = (int) (seconds - (h * 3600) - (m * 60));
255255

256256
String str = "";
257257

0 commit comments

Comments
 (0)