Log get extras

pull/162/head
M66B 5 years ago
parent 9f6c179cd2
commit 7833d4a8fc

@ -309,37 +309,40 @@ public class Log {
} }
static void logBundle(Bundle data) { static void logBundle(Bundle data) {
if (data != null) { for (String extra : getExtras(data))
Set<String> keys = data.keySet(); i(extra);
StringBuilder stringBuilder = new StringBuilder(); }
for (String key : keys) {
Object v = data.get(key); static List<String> getExtras(Bundle data) {
List<String> result = new ArrayList<>();
Object value = v; if (data == null)
if (v != null && v.getClass().isArray()) { return result;
int length = Array.getLength(v);
if (length <= 10) { Set<String> keys = data.keySet();
String[] elements = new String[length]; for (String key : keys) {
for (int i = 0; i < length; i++) { Object v = data.get(key);
Object element = Array.get(v, i);
if (element instanceof Long) Object value = v;
elements[i] = "0x" + Long.toHexString((Long) element); if (v != null && v.getClass().isArray()) {
else int length = Array.getLength(v);
elements[i] = (element == null ? null : element.toString()); if (length <= 10) {
} String[] elements = new String[length];
value = TextUtils.join(",", elements); for (int i = 0; i < length; i++) {
Object element = Array.get(v, i);
if (element instanceof Long)
elements[i] = "0x" + Long.toHexString((Long) element);
else
elements[i] = (element == null ? null : element.toString());
} }
} else if (v instanceof Long) value = TextUtils.join(",", elements);
value = "0x" + Long.toHexString((Long) v); }
} else if (v instanceof Long)
stringBuilder.append(key) value = "0x" + Long.toHexString((Long) v);
.append("=")
.append(value) result.add(key + "=" + value + (value == null ? "" : " (" + v.getClass().getSimpleName() + ")"));
.append(value == null ? "" : " (" + v.getClass().getSimpleName() + ")")
.append("\r\n");
}
i(stringBuilder.toString());
} }
return result;
} }
static void logMemory(Context context, String message) { static void logMemory(Context context, String message) {

Loading…
Cancel
Save