Skip to content

Commit 35aad34

Browse files
committed
Use service helper for getting int pixels for size
1 parent 5ef568b commit 35aad34

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/src/main/java/com/github/mobile/util/HttpImageGetter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ private static class LoadingImageGetter implements ImageGetter {
5151
private final Drawable image;
5252

5353
private LoadingImageGetter(final Context context, final int size) {
54-
int imageSize = Math.round(context.getResources()
55-
.getDisplayMetrics().density * size + 0.5F);
54+
int imageSize = ServiceUtils.getIntPixels(context, size);
5655
image = context.getResources().getDrawable(
5756
drawable.image_loading_icon);
5857
image.setBounds(0, 0, imageSize, imageSize);

app/src/main/java/com/github/mobile/util/ServiceUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ public static int getIntPixels(final View view, final int dp) {
106106
return getIntPixels(view.getResources(), dp);
107107
}
108108

109+
/**
110+
* Get pixels from dps
111+
*
112+
* @param context
113+
* @param dp
114+
* @return pixels
115+
*/
116+
public static int getIntPixels(final Context context, final int dp) {
117+
return getIntPixels(context.getResources(), dp);
118+
}
119+
109120
/**
110121
* Get pixels from dps
111122
*

0 commit comments

Comments
 (0)