@Override public void execute(final Activity activity, final ViewPager pager) { // find textview String position = C.spKey(pager.getCurrentItem()); View current = pager.findViewWithTag(position); TextView text = (TextView) current.findViewById(R.id.text); // hide keyboard InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(text.getWindowToken(), 0); // create bitmap from screen capture text.setCursorVisible(false); pager.setDrawingCacheEnabled(true); Bitmap bitmap = Bitmap.createBitmap(pager.getDrawingCache()); pager.setDrawingCacheEnabled(false); text.setCursorVisible(true); new CaptureAsyncTask(activity, bitmap).execute(); }
public BookView(Context context, AttributeSet attributes) { super(context, attributes); this.listeners = new HashSet<BookViewListener>(); this.childView = new TextView(context) { protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); restorePosition(); int tableWidth = (int) (this.getWidth() * 0.9); tableHandler.setTableWidth(tableWidth); } public boolean dispatchKeyEvent(KeyEvent event) { return BookView.this.dispatchKeyEvent(event); } @Override protected void onSelectionChanged(int selStart, int selEnd) { // TODO Auto-generated method stub super.onSelectionChanged(selStart, selEnd); LOG.debug("Got text selection from " + selStart + " to " + selEnd); } }; childView.setCursorVisible(false); childView.setLongClickable(true); this.setVerticalFadingEdgeEnabled(false); childView.setFocusable(true); childView.setLinksClickable(true); childView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); MovementMethod m = childView.getMovementMethod(); if ((m == null) || !(m instanceof LinkMovementMethod)) { if (childView.getLinksClickable()) { childView.setMovementMethod(LinkMovementMethod.getInstance()); } } this.setSmoothScrollingEnabled(false); this.addView(childView); this.anchors = new HashMap<String, Integer>(); this.tableHandler = new TableHandler(); }