MCPcopy Create free account
hub / github.com/M66B/FairEmail / decodeAddresses

Method decodeAddresses

app/src/main/java/eu/faircode/email/DB.java:3356–3379  ·  view source on GitHub ↗
(String json)

Source from the content-addressed store, hash-verified

3354 }
3355
3356 @TypeConverter
3357 public static Address[] decodeAddresses(String json) {
3358 if (json == null)
3359 return null;
3360
3361 List<Address> result = new ArrayList<>();
3362 try {
3363 JSONArray jroot = new JSONArray(json);
3364 for (int i = 0; i < jroot.length(); i++) {
3365 Object item = jroot.get(i);
3366 if (jroot.get(i) instanceof JSONArray)
3367 for (int j = 0; j < ((JSONArray) item).length(); j++)
3368 result.add(InternetAddressJson.from((JSONObject) ((JSONArray) item).get(j)));
3369 else
3370 result.add(InternetAddressJson.from((JSONObject) item));
3371 }
3372 } catch (JSONException ex) {
3373 Log.i(ex);
3374 } catch (Throwable ex) {
3375 // Compose can store invalid addresses
3376 Log.w(ex);
3377 }
3378 return result.toArray(new Address[0]);
3379 }
3380
3381 @TypeConverter
3382 public static EntityLog.Type toLogType(int ordinal) {

Callers 3

migrateMethod · 0.95
onExecuteMethod · 0.80
onCreateDialogMethod · 0.80

Calls 7

fromMethod · 0.95
iMethod · 0.95
wMethod · 0.95
toArrayMethod · 0.80
lengthMethod · 0.45
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected