本文整理匯總了Java中com.google.zxing.client.result.ParsedResult類的典型用法代碼示例。如果您正苦於以下問題:Java ParsedResult類的具體用法?Java ParsedResult怎麽用?Java ParsedResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ParsedResult類屬於com.google.zxing.client.result包,在下文中一共展示了ParsedResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AddressBookResultHandler
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
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++;
}
}
}
示例2: fillInCustomSearchURL
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
final String fillInCustomSearchURL(String text) {
if (customProductSearch == null) {
return text; // ?
}
try {
text = URLEncoder.encode(text, "UTF-8");
} catch (UnsupportedEncodingException e) {
// can't happen; UTF-8 is always supported. Continue, I guess, without encoding
}
String url = customProductSearch.replace("%s", text);
if (rawResult != null) {
url = url.replace("%f", rawResult.getBarcodeFormat().toString());
if (url.contains("%t")) {
ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
url = url.replace("%t", parsedResultAgain.getType().toString());
}
}
return url;
}
示例3: fillInCustomSearchURL
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
final String fillInCustomSearchURL(String text) {
if (customProductSearch == null) {
return text; // ?
}
try {
text = URLEncoder.encode(text, "UTF-8");
} catch (UnsupportedEncodingException e) {
// can't happen; UTF-8 is always supported. Continue, I guess, without encoding
}
String url = customProductSearch;
if (rawResult != null) {
// Replace %f but only if it doesn't seem to be a hex escape sequence. This remains
// problematic but avoids the more surprising problem of breaking escapes
url = url.replaceFirst("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString());
if (url.contains("%t")) {
ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
url = url.replace("%t", parsedResultAgain.getType().toString());
}
}
// Replace %s last as it might contain itself %f or %t
return url.replace("%s", text);
}
示例4: AddressBookResultHandler
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
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++;
}
}
}
示例5: fillInCustomSearchURL
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
final String fillInCustomSearchURL(String text) {
if (customProductSearch == null) {
return text; // ?
}
try {
text = URLEncoder.encode(text, "UTF-8");
} catch (UnsupportedEncodingException e) {
// can't happen; UTF-8 is always supported. Continue, I guess, without encoding
}
String url = customProductSearch;
if (rawResult != null) {
// Replace %f but only if it doesn't seem to be a hex escape sequence. This remains
// problematic but avoids the more surprising problem of breaking escapes
url = url.replaceFirst("%f(?![0-9a-f])", rawResult.getBarcodeFormat().toString());
if (url.contains("%t")) {
ParsedResult parsedResultAgain = ResultParser.parseResult(rawResult);
url = url.replace("%t", parsedResultAgain.getType().toString());
}
}
// Replace %s last as it might contain itself %f or %t
return url.replace("%s", text);
}
示例6: AddressBookResultHandler
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
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++;
}
}
}
示例7: encodeFromStreamExtra
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
private void encodeFromStreamExtra(Intent intent) throws WriterException {
format = BarcodeFormat.QR_CODE;
Bundle bundle = intent.getExtras();
if (bundle == null) {
throw new WriterException("No extras");
}
Uri uri = bundle.getParcelable(Intent.EXTRA_STREAM);
if (uri == null) {
throw new WriterException("No EXTRA_STREAM");
}
byte[] vcard;
String vcardString;
try {
InputStream stream = activity.getContentResolver().openInputStream(uri);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[2048];
int bytesRead;
while ((bytesRead = stream.read(buffer)) > 0) {
baos.write(buffer, 0, bytesRead);
}
vcard = baos.toByteArray();
vcardString = new String(vcard, 0, vcard.length, "UTF-8");
} catch (IOException ioe) {
throw new WriterException(ioe);
}
Log.d(TAG, "Encoding share intent content:");
Log.d(TAG, vcardString);
Result result = new Result(vcardString, vcard, null, BarcodeFormat.QR_CODE);
ParsedResult parsedResult = ResultParser.parseResult(result);
if (!(parsedResult instanceof AddressBookParsedResult)) {
throw new WriterException("Result was not an address");
}
encodeQRCodeContents((AddressBookParsedResult) parsedResult);
if (contents == null || contents.isEmpty()) {
throw new WriterException("No content to encode");
}
}
示例8: getProductIDFromResult
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
private static String getProductIDFromResult(ParsedResult rawResult) {
if (rawResult instanceof ProductParsedResult) {
return ((ProductParsedResult) rawResult).getNormalizedProductID();
}
if (rawResult instanceof ExpandedProductParsedResult) {
return ((ExpandedProductParsedResult) rawResult).getRawText();
}
throw new IllegalArgumentException(rawResult.getClass().toString());
}
示例9: getDisplayContents
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
@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();
}
示例10: getDisplayContents
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
@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();
}
示例11: makeResultHandler
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
public static ResultHandler makeResultHandler(CaptureActivity activity, Result rawResult) {
ParsedResult result = parseResult(rawResult);
switch (result.getType()) {
case ADDRESSBOOK:
return new AddressBookResultHandler(activity, result);
case EMAIL_ADDRESS:
return new EmailAddressResultHandler(activity, result);
case PRODUCT:
return new ProductResultHandler(activity, result, rawResult);
case URI:
return new URIResultHandler(activity, result);
case WIFI:
return new WifiResultHandler(activity, result);
case GEO:
return new GeoResultHandler(activity, result);
case TEL:
return new TelResultHandler(activity, result);
case SMS:
return new SMSResultHandler(activity, result);
case CALENDAR:
return new CalendarResultHandler(activity, result);
case ISBN:
return new ISBNResultHandler(activity, result, rawResult);
default:
return new TextResultHandler(activity, result, rawResult);
}
}
示例12: getDisplayContents
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
@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();
}
示例13: makeResultHandler
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
public static ResultHandler makeResultHandler(SweepActivity activity, Result rawResult) {
ParsedResult result = parseResult(rawResult);
if (result.getType() == ParsedResultType.URI) {
return new URIResultHandler(activity, result);
}
return new TextResultHandler(activity, result, rawResult);
}
示例14: getProductIDFromResult
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
private static String getProductIDFromResult(ParsedResult rawResult) {
if (rawResult instanceof ProductParsedResult) {
return ((ProductParsedResult) rawResult).getNormalizedProductID();
}
if (rawResult instanceof ExpandedProductParsedResult) {
return ((ExpandedProductParsedResult) rawResult).getRawText();
}
throw new IllegalArgumentException(rawResult.getClass().toString());
}
示例15: makeResultHandler
import com.google.zxing.client.result.ParsedResult; //導入依賴的package包/類
public static ResultHandler makeResultHandler(QrCodeScannerActivity activity, Result rawResult) {
ParsedResult result = parseResult(rawResult);
switch (result.getType()) {
case ADDRESSBOOK:
return new AddressBookResultHandler(activity, result);
case EMAIL_ADDRESS:
return new EmailAddressResultHandler(activity, result);
case PRODUCT:
return new ProductResultHandler(activity, result, rawResult);
case URI:
return new URIResultHandler(activity, result);
case WIFI:
return new WifiResultHandler(activity, result);
case GEO:
return new GeoResultHandler(activity, result);
case TEL:
return new TelResultHandler(activity, result);
case SMS:
return new SMSResultHandler(activity, result);
case CALENDAR:
return new CalendarResultHandler(activity, result);
case ISBN:
return new ISBNResultHandler(activity, result, rawResult);
default:
return new TextResultHandler(activity, result, rawResult);
}
}