Skip to content

Commit

Permalink
Use Math.floorDiv().
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Aug 15, 2022
1 parent b9b09d3 commit 1ca7101
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ protected RecyclerView.LayoutManager getGridLayoutManager() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ protected RecyclerView.LayoutManager getGridLayoutManager() {
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;
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/us/shandian/giga/util/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ private static String pad(int number) {
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 = "";

Expand Down

0 comments on commit 1ca7101

Please sign in to comment.