修改首页

This commit is contained in:
sifacai@outlook.com 2022-08-31 22:08:59 +08:00
parent 5b4045e67b
commit 92c6648283

View File

@ -26,16 +26,16 @@ import okhttp3.Response;
public class Utils { public class Utils {
// public static <T> T JsonToObj(String jsonStr, Class<T> tClass) { public static <T> T JsonToObj(String jsonStr, Class<T> tClass) {
// if (jsonStr != null && jsonStr.length() > 0) { if (jsonStr != null && jsonStr.length() > 0) {
// try { try {
// return new Gson().fromJson(jsonStr, tClass); return new Gson().fromJson(jsonStr, tClass);
// } catch (Exception e) { } catch (Exception e) {
// return null; return null;
// } }
// } }
// return null; return null;
// } }
/** /**
* 获取Json项 * 获取Json项
@ -44,19 +44,18 @@ public class Utils {
* @param key * @param key
* @return * @return
*/ */
// public static JsonElement getJsonString(JsonObject jo, String key) { public static JsonElement getJsonString(JsonObject jo, String key) {
// JsonElement je = new Gson().toJsonTree("", String.class); JsonElement je = new Gson().toJsonTree("", String.class);
// if (jo.has(key)) { if (jo.has(key)) {
// je = jo.get(key); je = jo.get(key);
// } }
// return je; return je;
// } }
// public static int getPixelsFromDp(Activity context, int i) {
// DisplayMetrics metrics = new DisplayMetrics();
// context.getWindowManager().getDefaultDisplay().getMetrics(metrics);
// return (i * metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
// }
public static int getPixelsFromDp(Activity context, int i) {
DisplayMetrics metrics = new DisplayMetrics();
context.getWindowManager().getDefaultDisplay().getMetrics(metrics);
return (i * metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
}
} }