public String getName() { return !TextUtils.isEmpty(name) ? name : getNumber(); }
public void syncCalendar(ConversionResult result) { enableSync(); if (result.type != DataType.CALLLOG) return; for (Map<String, String> m : result.getMapList()) { try { final int duration = Integer.parseInt(m.get(CallLog.Calls.DURATION)); final int callType = Integer.parseInt(m.get(CallLog.Calls.TYPE)); final String number = m.get(CallLog.Calls.NUMBER); final Date then = new Date(Long.valueOf(m.get(CallLog.Calls.DATE))); final PersonRecord record = personLookup.lookupPerson(number); // insert into calendar calendarAccessor.addEntry( calendarId, then, duration, callFormatter.callTypeString(callType, record.getName()), callFormatter.formatForCalendar(callType, record.getNumber(), duration)); } catch (NumberFormatException e) { Log.w(TAG, "error", e); } } }
public Address getAddress(AddressStyle style) { final String name; switch (style) { case NUMBER: name = getNumber(); break; case NAME_AND_NUMBER: name = getNameWithNumber(); break; case NAME: name = getName(); break; default: name = null; } return new Address(getEmail(), name, !isEmailUnknown()); }
@Test public void shouldSanitizeInputDataNumber() throws Exception { PersonRecord r = new PersonRecord(1, "foo\n\r\n", "foo\n@gmail.com", "\r\r1234"); assertThat(r.getNumber()).isEqualTo("1234"); }
@Test public void shouldReturnNumberForUnknown() throws Exception { PersonRecord record = new PersonRecord(1, null, null, "-1"); assertThat(record.getNumber()).isEqualTo("Unknown"); }
toInt(msgMap.get(CallLog.Calls.DURATION)); setBody(msg, new TextBody(callFormatter.format(callType, record.getNumber(), duration))); Date sentDate; try {