Java Code Examples for com.google.zxing.client.result.AddressBookParsedResult#getPhoneNumbers()

The following examples show how to use com.google.zxing.client.result.AddressBookParsedResult#getPhoneNumbers() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddressBookResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example 2
Source File: AddressBookResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example 3
Source File: AddressBookResultHandler.java    From zxingfragmentlib with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example 4
Source File: AddressBookResultHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example 5
Source File: AddressBookResultHandler.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example 6
Source File: AddressBookResultHandler.java    From android-quick-response-code with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
    super(activity, result);
    AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
    String[] addresses = addressResult.getAddresses();
    boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
    String[] phoneNumbers = addressResult.getPhoneNumbers();
    boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
    String[] emails = addressResult.getEmails();
    boolean hasEmailAddress = emails != null && emails.length > 0;

    fields = new boolean[4];
    fields[0] = true; // Add contact is always available
    fields[1] = hasAddress;
    fields[2] = hasPhoneNumber;
    fields[3] = hasEmailAddress;
}
 
Example 7
Source File: AddressBookResultHandler.java    From barcodescanner-lib-aar with MIT License 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  String[] emails = addressResult.getEmails();

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = addresses != null && addresses.length > 0 && addresses[0] != null && !addresses[0].isEmpty();
  fields[2] = phoneNumbers != null && phoneNumbers.length > 0;
  fields[3] = emails != null && emails.length > 0;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example 8
Source File: AddressBookResultHandler.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
    super(activity, result);
    AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
    String[] addresses = addressResult.getAddresses();
    boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
    String[] phoneNumbers = addressResult.getPhoneNumbers();
    boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
    String[] emails = addressResult.getEmails();
    boolean hasEmailAddress = emails != null && emails.length > 0;

    fields = new boolean[4];
    fields[0] = true; // Add contact is always available
    fields[1] = hasAddress;
    fields[2] = hasPhoneNumber;
    fields[3] = hasEmailAddress;
}
 
Example 9
Source File: AddressBookResultHandler.java    From android-apps with MIT License 6 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
  super(activity, result);
  AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
  String[] addresses = addressResult.getAddresses();
  boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
  String[] phoneNumbers = addressResult.getPhoneNumbers();
  boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
  String[] emails = addressResult.getEmails();
  boolean hasEmailAddress = emails != null && emails.length > 0;

  fields = new boolean[MAX_BUTTON_COUNT];
  fields[0] = true; // Add contact is always available
  fields[1] = hasAddress;
  fields[2] = hasPhoneNumber;
  fields[3] = hasEmailAddress;

  buttonCount = 0;
  for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
    if (fields[x]) {
      buttonCount++;
    }
  }
}
 
Example 10
Source File: AddressBookResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
public AddressBookResultHandler(Activity activity, ParsedResult result) {
   super(activity, result);
BUTTON_TEXTS = new int[]{
     fakeR.getId("string", "button_add_contact"),
     fakeR.getId("string", "button_show_map"),
     fakeR.getId("string", "button_dial"),
     fakeR.getId("string", "button_email"),
   };
   AddressBookParsedResult addressResult = (AddressBookParsedResult) result;
   String[] addresses = addressResult.getAddresses();
   boolean hasAddress = addresses != null && addresses.length > 0 && addresses[0].length() > 0;
   String[] phoneNumbers = addressResult.getPhoneNumbers();
   boolean hasPhoneNumber = phoneNumbers != null && phoneNumbers.length > 0;
   String[] emails = addressResult.getEmails();
   boolean hasEmailAddress = emails != null && emails.length > 0;

   fields = new boolean[MAX_BUTTON_COUNT];
   fields[0] = true; // Add contact is always available
   fields[1] = hasAddress;
   fields[2] = hasPhoneNumber;
   fields[3] = hasEmailAddress;

   buttonCount = 0;
   for (int x = 0; x < MAX_BUTTON_COUNT; x++) {
     if (fields[x]) {
       buttonCount++;
     }
   }
 }
 
Example 11
Source File: AddressBookResultHandler.java    From zxingfragmentlib with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && !pronunciation.isEmpty()) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      if (number != null) {
        ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
      }
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURLs(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && !birthday.isEmpty()) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}
 
Example 12
Source File: AddressBookResultHandler.java    From android-quick-response-code with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    AddressBookParsedResult result = (AddressBookParsedResult) getResult();
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(result.getNames(), contents);
    int namesLength = contents.length();

    String pronunciation = result.getPronunciation();
    if (pronunciation != null && pronunciation.length() > 0) {
        contents.append("\n(");
        contents.append(pronunciation);
        contents.append(')');
    }

    ParsedResult.maybeAppend(result.getTitle(), contents);
    ParsedResult.maybeAppend(result.getOrg(), contents);
    ParsedResult.maybeAppend(result.getAddresses(), contents);
    String[] numbers = result.getPhoneNumbers();
    if (numbers != null) {
        for (String number : numbers) {
            ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
        }
    }
    ParsedResult.maybeAppend(result.getEmails(), contents);
    ParsedResult.maybeAppend(result.getURLs(), contents);

    String birthday = result.getBirthday();
    if (birthday != null && birthday.length() > 0) {
        Date date = parseDate(birthday);
        if (date != null) {
            ParsedResult.maybeAppend(DateFormat.getDateInstance().format(date.getTime()), contents);
        }
    }
    ParsedResult.maybeAppend(result.getNote(), contents);

    if (namesLength > 0) {
        // Bold the full name to make it stand out a bit.
        Spannable styled = new SpannableString(contents.toString());
        styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
        return styled;
    }
    return contents.toString();
}
 
Example 13
Source File: AddressBookResultHandler.java    From barterli_android with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    AddressBookParsedResult result = (AddressBookParsedResult) getResult();
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(result.getNames(), contents);
    int namesLength = contents.length();

    String pronunciation = result.getPronunciation();
    if (pronunciation != null && pronunciation.length() > 0) {
        contents.append("\n(");
        contents.append(pronunciation);
        contents.append(')');
    }

    ParsedResult.maybeAppend(result.getTitle(), contents);
    ParsedResult.maybeAppend(result.getOrg(), contents);
    ParsedResult.maybeAppend(result.getAddresses(), contents);
    String[] numbers = result.getPhoneNumbers();
    if (numbers != null) {
        for (String number : numbers) {
            ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
        }
    }
    ParsedResult.maybeAppend(result.getEmails(), contents);
    ParsedResult.maybeAppend(result.getURL(), contents);

    String birthday = result.getBirthday();
    if (birthday != null && birthday.length() > 0) {
        Date date = parseDate(birthday);
        if (date != null) {
            ParsedResult.maybeAppend(DateFormat.getDateInstance().format(date.getTime()), contents);
        }
    }
    ParsedResult.maybeAppend(result.getNote(), contents);

    if (namesLength > 0) {
        // Bold the full name to make it stand out a bit.
        Spannable styled = new SpannableString(contents.toString());
        styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
        return styled;
    } else {
        return contents.toString();
    }
}
 
Example 14
Source File: AddressBookResultHandler.java    From android-apps with MIT License 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && pronunciation.length() > 0) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURL(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && birthday.length() > 0) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance().format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}
 
Example 15
Source File: AddressBookResultHandler.java    From reacteu-app with MIT License 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && pronunciation.length() > 0) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURL(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && birthday.length() > 0) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}
 
Example 16
Source File: AddressBookResultHandler.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && !pronunciation.isEmpty()) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      if (number != null) {
        ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
      }
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURLs(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && !birthday.isEmpty()) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}
 
Example 17
Source File: AddressBookResultHandler.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && !pronunciation.isEmpty()) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      if (number != null) {
        ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
      }
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURLs(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && !birthday.isEmpty()) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}
 
Example 18
Source File: AddressBookResultHandler.java    From weex with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && !pronunciation.isEmpty()) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      if (number != null) {
        ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
      }
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURLs(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && !birthday.isEmpty()) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}
 
Example 19
Source File: AddressBookResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && !pronunciation.isEmpty()) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      if (number != null) {
        ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
      }
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURLs(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && !birthday.isEmpty()) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}
 
Example 20
Source File: AddressBookResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 4 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  AddressBookParsedResult result = (AddressBookParsedResult) getResult();
  StringBuilder contents = new StringBuilder(100);
  ParsedResult.maybeAppend(result.getNames(), contents);
  int namesLength = contents.length();

  String pronunciation = result.getPronunciation();
  if (pronunciation != null && !pronunciation.isEmpty()) {
    contents.append("\n(");
    contents.append(pronunciation);
    contents.append(')');
  }

  ParsedResult.maybeAppend(result.getTitle(), contents);
  ParsedResult.maybeAppend(result.getOrg(), contents);
  ParsedResult.maybeAppend(result.getAddresses(), contents);
  String[] numbers = result.getPhoneNumbers();
  if (numbers != null) {
    for (String number : numbers) {
      if (number != null) {
        ParsedResult.maybeAppend(PhoneNumberUtils.formatNumber(number), contents);
      }
    }
  }
  ParsedResult.maybeAppend(result.getEmails(), contents);
  ParsedResult.maybeAppend(result.getURLs(), contents);

  String birthday = result.getBirthday();
  if (birthday != null && !birthday.isEmpty()) {
    Date date = parseDate(birthday);
    if (date != null) {
      ParsedResult.maybeAppend(DateFormat.getDateInstance(DateFormat.MEDIUM).format(date.getTime()), contents);
    }
  }
  ParsedResult.maybeAppend(result.getNote(), contents);

  if (namesLength > 0) {
    // Bold the full name to make it stand out a bit.
    Spannable styled = new SpannableString(contents.toString());
    styled.setSpan(new StyleSpan(Typeface.BOLD), 0, namesLength, 0);
    return styled;
  } else {
    return contents.toString();
  }
}