mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Fix error when follow RSS product result to Google Shopper
git-svn-id: https://zxing.googlecode.com/svn/trunk@2793 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
556013145b
commit
061cdce0c3
|
@ -42,8 +42,7 @@ public final class ProductResultHandler extends ResultHandler {
|
||||||
showGoogleShopperButton(new View.OnClickListener() {
|
showGoogleShopperButton(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
ProductParsedResult productResult = (ProductParsedResult) getResult();
|
openGoogleShopper(getProductIDFromResult(getResult()));
|
||||||
openGoogleShopper(productResult.getNormalizedProductID());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -60,15 +59,7 @@ public final class ProductResultHandler extends ResultHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleButtonPress(int index) {
|
public void handleButtonPress(int index) {
|
||||||
ParsedResult rawResult = getResult();
|
String productID = getProductIDFromResult(getResult());
|
||||||
String productID;
|
|
||||||
if (rawResult instanceof ProductParsedResult) {
|
|
||||||
productID = ((ProductParsedResult) rawResult).getNormalizedProductID();
|
|
||||||
} else if (rawResult instanceof ExpandedProductParsedResult) {
|
|
||||||
productID = ((ExpandedProductParsedResult) rawResult).getRawText();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException(rawResult.getClass().toString());
|
|
||||||
}
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
openProductSearch(productID);
|
openProductSearch(productID);
|
||||||
|
@ -82,6 +73,16 @@ public final class ProductResultHandler extends ResultHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDisplayTitle() {
|
public int getDisplayTitle() {
|
||||||
return R.string.result_product;
|
return R.string.result_product;
|
||||||
|
|
Loading…
Reference in a new issue