protected void onChildSetup(int i, View v) { // TODO: page number in landscape if (SearchTaskResult.get() != null && SearchTaskResult.get().pageNumber == i) { ((MuPDFView) v).setSearchBoxes(SearchTaskResult.get().searchBoxes); ((MuPDFView) v).setSearchBoxesPrim(SearchTaskResult.get().searchBoxesPrim); } else { ((MuPDFView) v).setSearchBoxes(null); ((MuPDFView) v).setSearchBoxesPrim(null); } ((MuPDFView) v).setLinkHighlighting(mLinksHighlighted); ((MuPDFView) v) .setChangeReporter( new Runnable() { public void run() { applyToChildren( new ViewMapper() { @Override void applyToView(View view) { ((MuPDFView) view).update(); } }); } }); }
private void search(int direction) { hideKeyboard(); int displayPage = mDocView.getDisplayedViewIndex(); SearchTaskResult r = SearchTaskResult.get(); int searchPage = r != null ? r.pageNumber : -1; mSearchTask.go(mSearchText.getText().toString(), direction, displayPage, searchPage); }
private void searchModeOff() { if (mTopBarMode == TopBarMode.Search) { mTopBarMode = TopBarMode.Main; hideKeyboard(); mTopBarSwitcher.setDisplayedChild(mTopBarMode.ordinal()); SearchTaskResult.set(null); // Make the ReaderView act on the change to mSearchTaskResult // via overridden onChildSetup method. mDocView.resetupChildren(); } }
protected void onChildSetup(int i, View v) { if (SearchTaskResult.get() != null && SearchTaskResult.get().pageNumber == i) ((MuPDFView) v).setSearchBoxes(SearchTaskResult.get().searchBoxes); else ((MuPDFView) v).setSearchBoxes(null); ((MuPDFView) v).setLinkHighlighting(mLinksEnabled); ((MuPDFView) v) .setChangeReporter( new Runnable() { public void run() { applyToChildren( new ViewMapper() { @Override public void applyToView(View view) { ((MuPDFView) view).update(); } }); } }); }
protected void onMoveToChild(int i) { if (SearchTaskResult.get() != null && SearchTaskResult.get().pageNumber != i) { SearchTaskResult.set(null); resetupChildren(); } }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); mAlertBuilder = new AlertDialog.Builder(this); gAlertBuilder = mAlertBuilder; // keep a static copy of this that other classes can use if (core == null) { core = (MuPDFCore) getLastNonConfigurationInstance(); if (savedInstanceState != null && savedInstanceState.containsKey("FileName")) { mFileName = savedInstanceState.getString("FileName"); } } if (core == null) { Intent intent = getIntent(); byte buffer[] = null; if (Intent.ACTION_VIEW.equals(intent.getAction())) { Uri uri = intent.getData(); System.out.println("URI to open is: " + uri); if (uri.toString().startsWith("content://")) { String reason = null; try { InputStream is = getContentResolver().openInputStream(uri); int len = is.available(); buffer = new byte[len]; is.read(buffer, 0, len); is.close(); } catch (java.lang.OutOfMemoryError e) { System.out.println("Out of memory during buffer reading"); reason = e.toString(); } catch (Exception e) { System.out.println("Exception reading from stream: " + e); // Handle view requests from the Transformer Prime's file manager // Hopefully other file managers will use this same scheme, if not // using explicit paths. // I'm hoping that this case below is no longer needed...but it's // hard to test as the file manager seems to have changed in 4.x. try { Cursor cursor = getContentResolver().query(uri, new String[] {"_data"}, null, null, null); if (cursor.moveToFirst()) { String str = cursor.getString(0); if (str == null) { reason = "Couldn't parse data in intent"; } else { uri = Uri.parse(str); } } } catch (Exception e2) { System.out.println("Exception in Transformer Prime file manager code: " + e2); reason = e2.toString(); } } if (reason != null) { buffer = null; Resources res = getResources(); AlertDialog alert = mAlertBuilder.create(); setTitle(String.format(res.getString(R.string.cannot_open_document_Reason), reason)); alert.setButton( AlertDialog.BUTTON_POSITIVE, getString(R.string.dismiss), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); alert.show(); return; } } if (buffer != null) { core = openBuffer(buffer, intent.getType()); } else { String path = Uri.decode(uri.getEncodedPath()); if (path == null) { path = uri.toString(); } core = openFile(path); } SearchTaskResult.set(null); } if (core != null && core.needsPassword()) { requestPassword(savedInstanceState); return; } if (core != null && core.countPages() == 0) { core = null; } } if (core == null) { AlertDialog alert = mAlertBuilder.create(); alert.setTitle(R.string.cannot_open_document); alert.setButton( AlertDialog.BUTTON_POSITIVE, getString(R.string.dismiss), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); } }); alert.setOnCancelListener( new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }); alert.show(); return; } createUI(savedInstanceState); // hide the proof button if this file can't be proofed if (!core.canProof()) { mProofButton.setVisibility(View.INVISIBLE); } if (isProofing()) { // start the activity with a new array mSepEnabled = null; // show the separations button mSepsButton.setVisibility(View.VISIBLE); // hide some other buttons mLinkButton.setVisibility(View.INVISIBLE); mReflowButton.setVisibility(View.INVISIBLE); mOutlineButton.setVisibility(View.INVISIBLE); mSearchButton.setVisibility(View.INVISIBLE); mMoreButton.setVisibility(View.INVISIBLE); } else { // hide the separations button mSepsButton.setVisibility(View.INVISIBLE); } }