use of org.acra.ReportField in project acra by ACRA.
the class HttpSender method remap.
@NonNull
private Map<String, String> remap(@NonNull Map<ReportField, Element> report) {
Set<ReportField> fields = config.getReportFields();
if (fields.isEmpty()) {
fields = new ImmutableSet<ReportField>(ACRAConstants.DEFAULT_REPORT_FIELDS);
}
final Map<String, String> finalReport = new HashMap<String, String>(report.size());
for (ReportField field : fields) {
Element element = report.get(field);
String value = element != null ? TextUtils.join("\n", element.flatten()) : null;
if (mMapping == null || mMapping.get(field) == null) {
finalReport.put(field.toString(), value);
} else {
finalReport.put(mMapping.get(field), value);
}
}
return finalReport;
}
use of org.acra.ReportField in project acra by ACRA.
the class JsonUtils method toCrashReportData.
public static CrashReportData toCrashReportData(JSONObject json) {
CrashReportData data = new CrashReportData();
for (Iterator<String> iterator = json.keys(); iterator.hasNext(); ) {
String key = iterator.next();
try {
ReportField field = ReportField.valueOf(key);
Object value = json.get(key);
if (value instanceof JSONObject) {
data.put(field, new ComplexElement((JSONObject) value));
} else if (value instanceof Number) {
data.putNumber(field, (Number) value);
} else if (value instanceof Boolean) {
data.putBoolean(field, (Boolean) value);
} else {
data.putString(field, value.toString());
}
} catch (IllegalArgumentException e) {
Log.w(LOG_TAG, "Unknown report key " + key, e);
} catch (JSONException e) {
Log.w(LOG_TAG, "Unable to read report field " + key, e);
}
}
return data;
}
Aggregations