public static void maybeInvokeRetrieval(
     TextView textView, ParsedResult result, HistoryManager historyManager, Context context) {
   try {
     if (result instanceof URIParsedResult) {
       SupplementalInfoRetriever uriRetriever =
           new URIResultInfoRetriever(textView, (URIParsedResult) result, historyManager, context);
       uriRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
       SupplementalInfoRetriever titleRetriever =
           new TitleRetriever(textView, (URIParsedResult) result, historyManager);
       titleRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
     } else if (result instanceof ProductParsedResult) {
       ProductParsedResult productParsedResult = (ProductParsedResult) result;
       String productID = productParsedResult.getProductID();
       SupplementalInfoRetriever productRetriever =
           new ProductResultInfoRetriever(textView, productID, historyManager, context);
       productRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
     } else if (result instanceof ISBNParsedResult) {
       String isbn = ((ISBNParsedResult) result).getISBN();
       SupplementalInfoRetriever productInfoRetriever =
           new ProductResultInfoRetriever(textView, isbn, historyManager, context);
       productInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
       SupplementalInfoRetriever bookInfoRetriever =
           new BookResultInfoRetriever(textView, isbn, historyManager, context);
       bookInfoRetriever.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
     }
   } catch (RejectedExecutionException ree) {
     // do nothing
   }
 }
  // Put up our own UI for how to handle the decoded contents.
  private void handleDecodeInternally(
      Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    statusView.setVisibility(View.GONE);
    viewfinderView.setVisibility(View.GONE);
    resultView.setVisibility(View.VISIBLE);

    ImageView barcodeImageView = (ImageView) findViewById(fakeR.getId("id", "barcode_image_view"));
    if (barcode == null) {
      barcodeImageView.setImageBitmap(
          BitmapFactory.decodeResource(getResources(), fakeR.getId("drawable", "launcher_icon")));
    } else {
      barcodeImageView.setImageBitmap(barcode);
    }

    TextView formatTextView = (TextView) findViewById(fakeR.getId("id", "format_text_view"));
    formatTextView.setText(rawResult.getBarcodeFormat().toString());

    TextView typeTextView = (TextView) findViewById(fakeR.getId("id", "type_text_view"));
    typeTextView.setText(resultHandler.getType().toString());

    DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
    String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
    TextView timeTextView = (TextView) findViewById(fakeR.getId("id", "time_text_view"));
    timeTextView.setText(formattedTime);

    TextView metaTextView = (TextView) findViewById(fakeR.getId("id", "meta_text_view"));
    View metaTextViewLabel = findViewById(fakeR.getId("id", "meta_text_view_label"));
    metaTextView.setVisibility(View.GONE);
    metaTextViewLabel.setVisibility(View.GONE);
    Map<ResultMetadataType, Object> metadata = rawResult.getResultMetadata();
    if (metadata != null) {
      StringBuilder metadataText = new StringBuilder(20);
      for (Map.Entry<ResultMetadataType, Object> entry : metadata.entrySet()) {
        if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
          metadataText.append(entry.getValue()).append('\n');
        }
      }
      if (metadataText.length() > 0) {
        metadataText.setLength(metadataText.length() - 1);
        metaTextView.setText(metadataText);
        metaTextView.setVisibility(View.VISIBLE);
        metaTextViewLabel.setVisibility(View.VISIBLE);
      }
    }

    TextView contentsTextView = (TextView) findViewById(fakeR.getId("id", "contents_text_view"));
    CharSequence displayContents = resultHandler.getDisplayContents();
    contentsTextView.setText(displayContents);
    // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
    int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
    contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

    TextView supplementTextView =
        (TextView) findViewById(fakeR.getId("id", "contents_supplement_text_view"));
    supplementTextView.setText("");
    supplementTextView.setOnClickListener(null);
    if (PreferenceManager.getDefaultSharedPreferences(this)
        .getBoolean(PreferencesActivity.KEY_SUPPLEMENTAL, true)) {
      SupplementalInfoRetriever.maybeInvokeRetrieval(
          supplementTextView, resultHandler.getResult(), historyManager, this);
    }

    int buttonCount = resultHandler.getButtonCount();
    ViewGroup buttonView = (ViewGroup) findViewById(fakeR.getId("id", "result_button_view"));
    buttonView.requestFocus();
    for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
      TextView button = (TextView) buttonView.getChildAt(x);
      if (x < buttonCount) {
        button.setVisibility(View.VISIBLE);
        button.setText(resultHandler.getButtonText(x));
        button.setOnClickListener(new ResultButtonListener(resultHandler, x));
      } else {
        button.setVisibility(View.GONE);
      }
    }

    if (copyToClipboard && !resultHandler.areContentsSecure()) {
      ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
      if (displayContents != null) {
        clipboard.setText(displayContents);
      }
    }
  }