com.alibaba.weex.R Java Examples

The following examples show how to use com.alibaba.weex.R. 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: CaptureActivityHandler.java    From weex with Apache License 2.0 6 votes vote down vote up
public void quitSynchronously() {
  state = State.DONE;
  cameraManager.stopPreview();
  Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
  quit.sendToTarget();
  try {
    // Wait at most half a second; should be enough time, and onPause() will timeout quickly
    decodeThread.join(500L);
  } catch (InterruptedException e) {
    // continue
  }

  // Be absolutely sure we don't send any queued up messages
  removeMessages(R.id.decode_succeeded);
  removeMessages(R.id.decode_failed);
}
 
Example #2
Source File: CaptureActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
	if (handler != null) {
		handler.quitSynchronously();
		handler = null;
	}
	inactivityTimer.onPause();
	ambientLightManager.stop();
	beepManager.close();
	cameraManager.closeDriver();
	// historyManager = null; // Keep for onActivityResult
	if (!hasSurface) {
		SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
		SurfaceHolder surfaceHolder = surfaceView.getHolder();
		surfaceHolder.removeCallback(this);
	}
	super.onPause();
}
 
Example #3
Source File: WeexUiTestCaseTCAHrefStyle.java    From WeexOne with MIT License 6 votes vote down vote up
public void setUp() throws Exception{

        Log.e("TestScript_Guide", "setUp  test!!");
        setActivityInitialTouchMode(false);
        weappApplication = new WeappJsBaseTestCase();
        mInstrumentation = getInstrumentation();

        Intent intent = new Intent();
        intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
        launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
        waTestPageActivity = getActivity();
//        waTestPageActivity.getIntent().getData().toString();
        Log.e(TAG, "activity1=" + waTestPageActivity.toString());
        Thread.sleep(3000);

        mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
        setViewGroup(mViewGroup);

        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_");
        Thread.sleep(3000);
    }
 
Example #4
Source File: BookmarkAdapter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int index, View view, ViewGroup viewGroup) {
  View layout;
  if (view instanceof LinearLayout) {
    layout = view;
  } else {
    LayoutInflater factory = LayoutInflater.from(context);
    layout = factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false);
  }

  if (!cursor.isClosed()) {
    cursor.moveToPosition(index);
    CharSequence title = cursor.getString(BookmarkPickerActivity.TITLE_COLUMN);
    ((TextView) layout.findViewById(R.id.bookmark_title)).setText(title);
    CharSequence url = cursor.getString(BookmarkPickerActivity.URL_COLUMN);
    ((TextView) layout.findViewById(R.id.bookmark_url)).setText(url);
  } // Otherwise... just don't update as the object is shutting down
  return layout;
}
 
Example #5
Source File: WeexUiTestCaseTCAHrefUpdate.java    From WeexOne with MIT License 6 votes vote down vote up
public void setUp() throws Exception{

        Log.e("TestScript_Guide", "setUp  test!!");
        setActivityInitialTouchMode(false);
        weappApplication = new WeappJsBaseTestCase();
        mInstrumentation = getInstrumentation();

        Intent intent = new Intent();
        intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
        launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
        waTestPageActivity = getActivity();
//        waTestPageActivity.getIntent().getData().toString();
        Log.e(TAG, "activity1=" + waTestPageActivity.toString());
        Thread.sleep(3000);

        mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
        setViewGroup(mViewGroup);

        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_");
        Thread.sleep(2000);
    }
 
Example #6
Source File: WeexUiTestCaseTcInputType.java    From WeexOne with MIT License 6 votes vote down vote up
public void setUp() throws Exception{

        Log.e("TestScript_Guide", "setUp  test!!");
        setActivityInitialTouchMode(false);
        weappApplication = new WeappJsBaseTestCase();
        mInstrumentation = getInstrumentation();

        Intent intent = new Intent();
        intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
        launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
        waTestPageActivity = getActivity();
//        waTestPageActivity.getIntent().getData().toString();
        Log.e(TAG,"activity1=" + waTestPageActivity.toString() );
        Thread.sleep(3000);

        mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
        setViewGroup(mViewGroup);

        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_");
        Thread.sleep(3000);
    }
 
Example #7
Source File: CaptureActivity.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPause() {
	if (handler != null) {
		handler.quitSynchronously();
		handler = null;
	}
	inactivityTimer.onPause();
	ambientLightManager.stop();
	beepManager.close();
	cameraManager.closeDriver();
	// historyManager = null; // Keep for onActivityResult
	if (!hasSurface) {
		SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
		SurfaceHolder surfaceHolder = surfaceView.getHolder();
		surfaceHolder.removeCallback(this);
	}
	super.onPause();
}
 
Example #8
Source File: SearchBookContentsActivity.java    From weex with Apache License 2.0 6 votes vote down vote up
private void handleSearchResults(JSONObject json) {
  try {
    int count = json.getInt("number_of_results");
    headerView.setText(getString(R.string.msg_sbc_results) + " : " + count);
    if (count > 0) {
      JSONArray results = json.getJSONArray("search_results");
      SearchBookContentsResult.setQuery(queryTextView.getText().toString());
      List<SearchBookContentsResult> items = new ArrayList<>(count);
      for (int x = 0; x < count; x++) {
        items.add(parseResult(results.getJSONObject(x)));
      }
      resultListView.setOnItemClickListener(new BrowseBookListener(SearchBookContentsActivity.this, items));
      resultListView.setAdapter(new SearchBookContentsAdapter(SearchBookContentsActivity.this, items));
    } else {
      String searchable = json.optString("searchable");
      if ("false".equals(searchable)) {
        headerView.setText(R.string.msg_sbc_book_not_searchable);
      }
      resultListView.setAdapter(null);
    }
  } catch (JSONException e) {
    Log.w(TAG, "Bad JSON from book search", e);
    resultListView.setAdapter(null);
    headerView.setText(R.string.msg_sbc_failed);
  }
}
 
Example #9
Source File: CaptureActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
private void decodeOrStoreSavedBitmap(Bitmap bitmap, Result result) {
	// Bitmap isn't used yet -- will be used soon
	if (handler == null) {
		savedResultToShow = result;
	} else {
		if (result != null) {
			savedResultToShow = result;
		}
		if (savedResultToShow != null) {
			Message message = Message.obtain(handler,
					R.id.decode_succeeded, savedResultToShow);
			handler.sendMessage(message);
		}
		savedResultToShow = null;
	}
}
 
Example #10
Source File: WeexUiTestCaseTcDowngradeAppVTrue.java    From weex with Apache License 2.0 6 votes vote down vote up
public void setUp() throws Exception{

        Log.e("TestScript_Guide", "setUp  into!!");
        setActivityInitialTouchMode(false);
        mInstrumentation = getInstrumentation();

        Intent intent = new Intent();
        intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
        launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
        setActivity(WXPageActivity.wxPageActivityInstance);
        waTestPageActivity = getActivity();
//        waTestPageActivity.getIntent().getData().toString();
        Log.e(TAG,"activity1=" + waTestPageActivity.toString() );
        sleep(3000);

        mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_");
    }
 
Example #11
Source File: EncodeActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  int i = item.getItemId();
  if (i == R.id.menu_share) {
    share();
    return true;
  } else if (i == R.id.menu_encode) {
    Intent intent = getIntent();
    if (intent == null) {
      return false;
    }
    intent.putExtra(USE_VCARD_KEY, !qrCodeEncoder.isUseVCard());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    finish();
    return true;
  } else {
    return false;
  }
}
 
Example #12
Source File: TestFlow.java    From WeexOne with MIT License 6 votes vote down vote up
/**
 * get tc list
 * @throws InterruptedException
 */
@Before
public void setUp() throws InterruptedException {
    setActivityInitialTouchMode(false);
    weappApplication = new WeappJsBaseTestCase();
    mInstrumentation = getInstrumentation();

    if(mInstrumentation == null){

        mInstrumentation = this.getInstrumentation();
    }
    Intent intent = new Intent();
    intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
    launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
    waTestPageActivity = getActivity();
    Log.e(TAG, "activity1=" + waTestPageActivity.toString());
    Thread.sleep(3000);

    mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
    setViewGroup(mViewGroup);
    // 根据TC 获取TC 列表,默认“"TC_"”
    mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "AG_");
    Thread.sleep(3000);
}
 
Example #13
Source File: LoadPackagesAsyncTask.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostExecute(final List<AppInfo> results) {    
  ListAdapter listAdapter = new ArrayAdapter<AppInfo>(activity, 
                                                      R.layout.app_picker_list_item,
                                                      R.id.app_picker_list_item_label, 
                                                      results) {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = super.getView(position, convertView, parent);
      Drawable icon = results.get(position).getIcon();
      if (icon != null) {
        ((ImageView) view.findViewById(R.id.app_picker_list_item_icon)).setImageDrawable(icon);
      }
      return view;
    }
  };
  activity.setListAdapter(listAdapter);
}
 
Example #14
Source File: CaptureActivity.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	Intent intent = new Intent(Intent.ACTION_VIEW);
	intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
	int i = item.getItemId();
	if (i == R.id.menu_history) {
		intent.setClassName(this, HistoryActivity.class.getName());
		startActivityForResult(intent, HISTORY_REQUEST_CODE);

		// case R.id.menu_settings:
		// intent.setClassName(this, PreferencesActivity.class.getName());
		// startActivity(intent);
		// break;
		// case R.id.menu_help:
		// intent.setClassName(this, HelpActivity.class.getName());
		// startActivity(intent);
		// break;
	} else {
		return super.onOptionsItemSelected(item);
	}
	return true;
}
 
Example #15
Source File: EncodeActivity.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
  int i = item.getItemId();
  if (i == R.id.menu_share) {
    share();
    return true;
  } else if (i == R.id.menu_encode) {
    Intent intent = getIntent();
    if (intent == null) {
      return false;
    }
    intent.putExtra(USE_VCARD_KEY, !qrCodeEncoder.isUseVCard());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
    finish();
    return true;
  } else {
    return false;
  }
}
 
Example #16
Source File: QRCodeEncoder.java    From weex with Apache License 2.0 6 votes vote down vote up
private void encodeQRCodeContents(AddressBookParsedResult contact) {
  ContactEncoder encoder = useVCard ? new VCardContactEncoder() : new MECARDContactEncoder();
  String[] encoded = encoder.encode(toList(contact.getNames()),
                                    contact.getOrg(),
                                    toList(contact.getAddresses()),
                                    toList(contact.getPhoneNumbers()),
                                    null,
                                    toList(contact.getEmails()),
                                    toList(contact.getURLs()),
                                    null);
  // Make sure we've encoded at least one field.
  if (!encoded[1].isEmpty()) {
    contents = encoded[0];
    displayContents = encoded[1];
    title = activity.getString(R.string.contents_contact);
  }
}
 
Example #17
Source File: SearchBookContentsAdapter.java    From weex with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
  SearchBookContentsListItem listItem;

  if (view == null) {
    LayoutInflater factory = LayoutInflater.from(getContext());
    listItem = (SearchBookContentsListItem) factory.inflate(
        R.layout.search_book_contents_list_item, viewGroup, false);
  } else {
    if (view instanceof SearchBookContentsListItem) {
      listItem = (SearchBookContentsListItem) view;
    } else {
      return view;
    }
  }

  SearchBookContentsResult result = getItem(position);
  listItem.set(result);
  return listItem;
}
 
Example #18
Source File: WeexUiTestCaseTcElementOpt.java    From WeexOne with MIT License 6 votes vote down vote up
public void setUp() throws Exception{

        Log.e("TestScript_Guide", "setUp  test!!");
        setActivityInitialTouchMode(false);
        weappApplication = new WeappJsBaseTestCase();
        mInstrumentation = getInstrumentation();

        Intent intent = new Intent();
        intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
        launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
        waTestPageActivity = getActivity();
//        waTestPageActivity.getIntent().getData().toString();
        Log.e(TAG,"activity1=" + waTestPageActivity.toString() );
        Thread.sleep(3000);

        mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
        setViewGroup(mViewGroup);

        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_");
        Thread.sleep(3000);
    }
 
Example #19
Source File: WeexUiTestCaseTcColorUpdate.java    From weex with Apache License 2.0 6 votes vote down vote up
public void setUp() throws Exception{

        Log.e("TestScript_Guide", "setUp  test!!");
        setActivityInitialTouchMode(false);
        mInstrumentation = getInstrumentation();

        Intent intent = new Intent();
        intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
        launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
        waTestPageActivity = getActivity();
//        waTestPageActivity.getIntent().getData().toString();
        Log.e(TAG,"activity1=" + waTestPageActivity.toString() );
        Thread.sleep(3000);

        mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
        setViewGroup(mViewGroup);

        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_");    }
 
Example #20
Source File: WeexUiTestCaseTcInputEvent.java    From weex with Apache License 2.0 6 votes vote down vote up
public void setUp() throws Exception{

        Log.e("TestScript_Guide", "setUp  test!!");
        setActivityInitialTouchMode(false);
        weappApplication = new WeappJsBaseTestCase();
        mInstrumentation = getInstrumentation();

        Intent intent = new Intent();
        intent.putExtra("bundleUrl", Constants.BUNDLE_URL);
        launchActivityWithIntent("com.alibaba.weex", WXPageActivity.class, intent);
        waTestPageActivity = getActivity();
//        waTestPageActivity.getIntent().getData().toString();
        Log.e(TAG, "activity1=" + waTestPageActivity.toString());
        Thread.sleep(3000);

        mViewGroup = (ViewGroup) waTestPageActivity.findViewById(R.id.container);
        setViewGroup(mViewGroup);

mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, "TC_");    }
 
Example #21
Source File: SearchBookContentsAdapter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
  SearchBookContentsListItem listItem;

  if (view == null) {
    LayoutInflater factory = LayoutInflater.from(getContext());
    listItem = (SearchBookContentsListItem) factory.inflate(
        R.layout.search_book_contents_list_item, viewGroup, false);
  } else {
    if (view instanceof SearchBookContentsListItem) {
      listItem = (SearchBookContentsListItem) view;
    } else {
      return view;
    }
  }

  SearchBookContentsResult result = getItem(position);
  listItem.set(result);
  return listItem;
}
 
Example #22
Source File: SearchBookContentsActivity.java    From weex with Apache License 2.0 5 votes vote down vote up
private SearchBookContentsResult parseResult(JSONObject json) {

      String pageId;
      String pageNumber;
      String snippet;
      try {
        pageId = json.getString("page_id");
        pageNumber = json.optString("page_number");
        snippet = json.optString("snippet_text");        
      } catch (JSONException e) {
        Log.w(TAG, e);
        // Never seen in the wild, just being complete.
        return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false);
      }
      
      if (pageNumber == null || pageNumber.isEmpty()) {
        // This can happen for text on the jacket, and possibly other reasons.
        pageNumber = "";
      } else {
        pageNumber = getString(R.string.msg_sbc_page) + ' ' + pageNumber;
      }
      
      boolean valid = snippet != null && !snippet.isEmpty();
      if (valid) {
        // Remove all HTML tags and encoded characters.          
        snippet = TAG_PATTERN.matcher(snippet).replaceAll("");
        snippet = LT_ENTITY_PATTERN.matcher(snippet).replaceAll("<");
        snippet = GT_ENTITY_PATTERN.matcher(snippet).replaceAll(">");
        snippet = QUOTE_ENTITY_PATTERN.matcher(snippet).replaceAll("'");
        snippet = QUOT_ENTITY_PATTERN.matcher(snippet).replaceAll("\"");
      } else {
        snippet = '(' + getString(R.string.msg_sbc_snippet_unavailable) + ')';        
      }

      return new SearchBookContentsResult(pageId, pageNumber, snippet, valid);
    }
 
Example #23
Source File: DecodeHandler.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public void handleMessage(Message message) {
  if (!running) {
    return;
  }
  if (message.what == R.id.decode) {
    decode((byte[]) message.obj, message.arg1, message.arg2);

  } else if (message.what == R.id.quit) {
    running = false;
    Looper.myLooper().quit();

  }
}
 
Example #24
Source File: SearchBookContentsActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private void launchSearch() {
  String query = queryTextView.getText().toString();
  if (query != null && !query.isEmpty()) {
    AsyncTask<?,?,?> oldTask = networkTask;
    if (oldTask != null) {
      oldTask.cancel(true);
    }
    networkTask = new NetworkTask();
    networkTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query, isbn);
    headerView.setText(R.string.msg_sbc_searching_book);
    resultListView.setAdapter(null);
    queryTextView.setEnabled(false);
    queryButton.setEnabled(false);
  }
}
 
Example #25
Source File: HistoryItemAdapter.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
  View layout;
  if (view instanceof LinearLayout) {
    layout = view;
  } else {
    LayoutInflater factory = LayoutInflater.from(activity);
    layout = factory.inflate(R.layout.history_list_item, viewGroup, false);
  }

  HistoryItem item = getItem(position);
  Result result = item.getResult();

  CharSequence title;
  CharSequence detail;
  if (result != null) {
    title = result.getText();
    detail = item.getDisplayAndDetails();      
  } else {
    Resources resources = getContext().getResources();
    title = resources.getString(R.string.history_empty);
    detail = resources.getString(R.string.history_empty_detail);
  }

  ((TextView) layout.findViewById(R.id.history_title)).setText(title);    
  ((TextView) layout.findViewById(R.id.history_detail)).setText(detail);

  return layout;
}
 
Example #26
Source File: ResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
/**
 * Like {@link #rawLaunchIntent(Intent)} but will show a user dialog if nothing is available to handle.
 */
final void launchIntent(Intent intent) {
  try {
    rawLaunchIntent(intent);
  } catch (ActivityNotFoundException ignored) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.app_name);
    builder.setMessage(R.string.msg_intent_failed);
    builder.setPositiveButton(R.string.button_ok, null);
    builder.show();
  }
}
 
Example #27
Source File: DecodeHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
public void handleMessage(Message message) {
  if (!running) {
    return;
  }
  if (message.what == R.id.decode) {
    decode((byte[]) message.obj, message.arg1, message.arg2);

  } else if (message.what == R.id.quit) {
    running = false;
    Looper.myLooper().quit();

  }
}
 
Example #28
Source File: HelpActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle icicle) {
  super.onCreate(icicle);
  setContentView(R.layout.help);

  webView = (WebView) findViewById(R.id.help_contents);

  if (icicle == null) {
    webView.loadUrl(BASE_URL + "index.html");
  } else {
    webView.restoreState(icicle);
  }
}
 
Example #29
Source File: ViewfinderView.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
public ViewfinderView(Context context, AttributeSet attrs) {
  super(context, attrs);

  // Initialize these once for performance rather than calling them every time in onDraw().
  paint = new Paint(Paint.ANTI_ALIAS_FLAG);
  Resources resources = getResources();
  maskColor = resources.getColor(R.color.viewfinder_mask);
  resultColor = resources.getColor(R.color.result_view);
  laserColor = resources.getColor(R.color.viewfinder_laser);
  resultPointColor = resources.getColor(R.color.possible_result_points);
  scannerAlpha = 0;
  possibleResultPoints = new ArrayList<>(5);
  lastPossibleResultPoints = null;
}
 
Example #30
Source File: SearchBookContentsActivity.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
private SearchBookContentsResult parseResult(JSONObject json) {

      String pageId;
      String pageNumber;
      String snippet;
      try {
        pageId = json.getString("page_id");
        pageNumber = json.optString("page_number");
        snippet = json.optString("snippet_text");        
      } catch (JSONException e) {
        Log.w(TAG, e);
        // Never seen in the wild, just being complete.
        return new SearchBookContentsResult(getString(R.string.msg_sbc_no_page_returned), "", "", false);
      }
      
      if (pageNumber == null || pageNumber.isEmpty()) {
        // This can happen for text on the jacket, and possibly other reasons.
        pageNumber = "";
      } else {
        pageNumber = getString(R.string.msg_sbc_page) + ' ' + pageNumber;
      }
      
      boolean valid = snippet != null && !snippet.isEmpty();
      if (valid) {
        // Remove all HTML tags and encoded characters.          
        snippet = TAG_PATTERN.matcher(snippet).replaceAll("");
        snippet = LT_ENTITY_PATTERN.matcher(snippet).replaceAll("<");
        snippet = GT_ENTITY_PATTERN.matcher(snippet).replaceAll(">");
        snippet = QUOTE_ENTITY_PATTERN.matcher(snippet).replaceAll("'");
        snippet = QUOT_ENTITY_PATTERN.matcher(snippet).replaceAll("\"");
      } else {
        snippet = '(' + getString(R.string.msg_sbc_snippet_unavailable) + ')';        
      }

      return new SearchBookContentsResult(pageId, pageNumber, snippet, valid);
    }