Screen.java
2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.megvii.idcardlib.util;
import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;
public class Screen {
public static float LEFTMENU_UI_PERCENT = 0.15f;
public static int mNotificationBarHeight;
public static int mScreenWidth;
public static int mScreenHeight;
public static int mWidth;
public static int mHeight;
public static float densityDpi;
public static float density;
public static float drawWidth;
public static float drawHeight;
private static final int PADDING_L = 30;
private static final int PADDING_R = 30;
private static final int PADDING_T = 50;
private static final int PADDING_B = 40;
public static float drawPaddingLeft;
public static float drawPaddingRight;
public static float drawPaddingTop;
public static float drawPaddingBottom;
public static int drawRows;
public static float lineHeight;
public static float line_space = 0;
public static float charHeight;
public static void initialize(Context context) {
if (drawWidth == 0 || drawHeight == 0 || mWidth == 0 || mHeight == 0
|| density == 0) {
Resources res = context.getResources();
DisplayMetrics metrics = res.getDisplayMetrics();
density = metrics.density;
mNotificationBarHeight = (int) (35 * density);
mWidth = metrics.widthPixels;// - (int)(50 * density)
mHeight = metrics.heightPixels/* - mNotificationBarHeight */;// -
// (int)(50
// *
// density)
mScreenWidth = metrics.widthPixels;
mScreenHeight = metrics.heightPixels;
densityDpi = metrics.densityDpi;
drawPaddingLeft = density * PADDING_L;
drawPaddingRight = density * PADDING_R;
drawPaddingTop = density * PADDING_T;
drawPaddingBottom = density * PADDING_B;
drawWidth = mWidth - drawPaddingLeft - drawPaddingRight;
drawHeight = mHeight - drawPaddingTop - drawPaddingBottom;
}
}
public static String clipImageUrl(String url, String add) {
String temp = null;
if (url != null) {
if (add != null) {
if (url.endsWith(".jpg") || url.endsWith(".png")
|| url.endsWith(".gif") || url.endsWith(".bmp")) {
String end = url.substring(url.length() - 4, url.length());
int point = url.lastIndexOf(".");
int index = url.lastIndexOf("/");
if (index != -1) {
String sub = url.substring(index + 1, point);
if (sub.endsWith("_m") || sub.endsWith("_b")
|| sub.endsWith("_s")) {
String clip = sub.substring(0, sub.length() - 2);
temp = url.substring(0, index + 1) + clip + add
+ end;
} else {
temp = url.substring(0, index + 1) + sub + add
+ end;
}
}
}
} else {
temp = url;
}
}
return temp;
}
}