Java Code Examples for com.google.zxing.client.result.ParsedResult#maybeAppend()

The following examples show how to use com.google.zxing.client.result.ParsedResult#maybeAppend() . 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: CalendarResultHandler.java    From barterli_android with Apache License 2.0 6 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    CalendarParsedResult calResult = (CalendarParsedResult) getResult();
    StringBuilder result = new StringBuilder(100);
    ParsedResult.maybeAppend(calResult.getSummary(), result);
    Date start = calResult.getStart();
    String startString = start.toGMTString();
    appendTime(startString, result, false, false);

    Date end = calResult.getEnd();
    String endString = end.toGMTString();
    if (endString != null) {
        boolean sameStartEnd = startString.equals(endString);
        appendTime(endString, result, true, sameStartEnd);
    }

    ParsedResult.maybeAppend(calResult.getLocation(), result);
    ParsedResult.maybeAppend(calResult.getAttendees(), result);
    ParsedResult.maybeAppend(calResult.getDescription(), result);
    return result.toString();
}
 
Example 2
Source File: CalendarResultHandler.java    From android-apps with MIT License 6 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  CalendarParsedResult calResult = (CalendarParsedResult) getResult();
  StringBuilder result = new StringBuilder(100);
  ParsedResult.maybeAppend(calResult.getSummary(), result);
  String startString = calResult.getStart();
  appendTime(startString, result, false, false);

  String endString = calResult.getEnd();
  if (endString != null) {
    boolean sameStartEnd = startString.equals(endString);
    appendTime(endString, result, true, sameStartEnd);
  }

  ParsedResult.maybeAppend(calResult.getLocation(), result);
  ParsedResult.maybeAppend(calResult.getAttendee(), result);
  ParsedResult.maybeAppend(calResult.getDescription(), result);
  return result.toString();
}
 
Example 3
Source File: CalendarResultHandler.java    From android-quick-response-code with Apache License 2.0 6 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    CalendarParsedResult calResult = (CalendarParsedResult) getResult();
    StringBuilder result = new StringBuilder(100);
    ParsedResult.maybeAppend(calResult.getSummary(), result);
    Date start = calResult.getStart();
    String startString = start.toGMTString();
    appendTime(startString, result, false, false);

    Date end = calResult.getEnd();
    String endString = end.toGMTString();
    if (endString != null) {
        boolean sameStartEnd = startString.equals(endString);
        appendTime(endString, result, true, sameStartEnd);
    }

    ParsedResult.maybeAppend(calResult.getLocation(), result);
    ParsedResult.maybeAppend(calResult.getAttendees(), result);
    ParsedResult.maybeAppend(calResult.getDescription(), result);
    return result.toString();
}
 
Example 4
Source File: SMSResultHandler.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    SMSParsedResult smsResult = (SMSParsedResult) getResult();
    StringBuilder contents = new StringBuilder(50);
    String[] rawNumbers = smsResult.getNumbers();
    String[] formattedNumbers = new String[rawNumbers.length];
    for (int i = 0; i < rawNumbers.length; i++) {
        formattedNumbers[i] = PhoneNumberUtils.formatNumber(rawNumbers[i]);
    }
    ParsedResult.maybeAppend(formattedNumbers, contents);
    ParsedResult.maybeAppend(smsResult.getSubject(), contents);
    ParsedResult.maybeAppend(smsResult.getBody(), contents);
    return contents.toString();
}
 
Example 5
Source File: TextResultHandler.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    TextParsedResult result = (TextParsedResult) getResult();
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(result.getText(), contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example 6
Source File: WifiResultHandler.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    WifiParsedResult wifiResult = (WifiParsedResult) getResult();
    StringBuilder contents = new StringBuilder(50);
    String wifiLabel = parent.getString(R.string.wifi_ssid_label);
    ParsedResult.maybeAppend(wifiLabel + '\n' + wifiResult.getSsid(), contents);
    String typeLabel = parent.getString(R.string.wifi_type_label);
    ParsedResult.maybeAppend(typeLabel + '\n' + wifiResult.getNetworkEncryption(), contents);
    return contents.toString();
}
 
Example 7
Source File: SMSResultHandler.java    From reacteu-app with MIT License 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  SMSParsedResult smsResult = (SMSParsedResult) getResult();
  StringBuilder contents = new StringBuilder(50);
  String[] rawNumbers = smsResult.getNumbers();
  String[] formattedNumbers = new String[rawNumbers.length];
  for (int i = 0; i < rawNumbers.length; i++) {
    formattedNumbers[i] = PhoneNumberUtils.formatNumber(rawNumbers[i]);
  }
  ParsedResult.maybeAppend(formattedNumbers, contents);
  ParsedResult.maybeAppend(smsResult.getSubject(), contents);
  ParsedResult.maybeAppend(smsResult.getBody(), contents);
  return contents.toString();
}
 
Example 8
Source File: TextResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    TextParsedResult result = (TextParsedResult) getResult();
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(result.getText(), contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example 9
Source File: GeoResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    GeoParsedResult result = (GeoParsedResult) getResult();
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(result.getGeoURI(), contents);
    ParsedResult.maybeAppend(String.valueOf(result.getLatitude()), contents);
    ParsedResult.maybeAppend(String.valueOf(result.getLongitude()), contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example 10
Source File: ISBNResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    ISBNParsedResult result = (ISBNParsedResult) getResult();
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(result.getISBN(), contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example 11
Source File: ProductResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    ProductParsedResult result = (ProductParsedResult) getResult();
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(result.getNormalizedProductID(), contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example 12
Source File: SMSResultHandler.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  SMSParsedResult smsResult = (SMSParsedResult) getResult();
  String[] rawNumbers = smsResult.getNumbers();
  String[] formattedNumbers = new String[rawNumbers.length];
  for (int i = 0; i < rawNumbers.length; i++) {
    formattedNumbers[i] = PhoneNumberUtils.formatNumber(rawNumbers[i]);
  }
  StringBuilder contents = new StringBuilder(50);
  ParsedResult.maybeAppend(formattedNumbers, contents);
  ParsedResult.maybeAppend(smsResult.getSubject(), contents);
  ParsedResult.maybeAppend(smsResult.getBody(), contents);
  return contents.toString();
}
 
Example 13
Source File: SMSResultHandler.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  SMSParsedResult smsResult = (SMSParsedResult) getResult();
  String[] rawNumbers = smsResult.getNumbers();
  String[] formattedNumbers = new String[rawNumbers.length];
  for (int i = 0; i < rawNumbers.length; i++) {
    formattedNumbers[i] = PhoneNumberUtils.formatNumber(rawNumbers[i]);
  }
  StringBuilder contents = new StringBuilder(50);
  ParsedResult.maybeAppend(formattedNumbers, contents);
  ParsedResult.maybeAppend(smsResult.getSubject(), contents);
  ParsedResult.maybeAppend(smsResult.getBody(), contents);
  return contents.toString();
}
 
Example 14
Source File: URIResultHandler.java    From android-quick-response-code with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
    URIParsedResult uriResult = (URIParsedResult) getResult();
    String uri = uriResult.getURI().toLowerCase(Locale.ENGLISH);
    StringBuilder contents = new StringBuilder(100);
    ParsedResult.maybeAppend(uri, contents);
    contents.trimToSize();
    return contents.toString();
}
 
Example 15
Source File: SMSResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 5 votes vote down vote up
@Override
public CharSequence getDisplayContents() {
  SMSParsedResult smsResult = (SMSParsedResult) getResult();
  String[] rawNumbers = smsResult.getNumbers();
  String[] formattedNumbers = new String[rawNumbers.length];
  for (int i = 0; i < rawNumbers.length; i++) {
    formattedNumbers[i] = PhoneNumberUtils.formatNumber(rawNumbers[i]);
  }
  StringBuilder contents = new StringBuilder(50);
  ParsedResult.maybeAppend(formattedNumbers, contents);
  ParsedResult.maybeAppend(smsResult.getSubject(), contents);
  ParsedResult.maybeAppend(smsResult.getBody(), contents);
  return contents.toString();
}
 
Example 16
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 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 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 19
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 20
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();
  }
}