List of usage examples for android.view View setDrawingCacheEnabled
@Deprecated public void setDrawingCacheEnabled(boolean enabled)
Enables or disables the drawing cache.
From source file:com.awrtechnologies.valor.valorfireplace.hlistview.widget.HListView.java
/** * Add a view as a child and make sure it is measured (if necessary) and positioned properly. * * @param child/*from w w w .j a v a 2 s. com*/ * The view to add * @param position * The position of this child * @param x * The x position relative to which this view will be positioned * @param flowDown * If true, align left edge to x. If false, align right edge to x. * @param childrenTop * Top edge where children should be positioned * @param selected * Is this position selected? * @param recycled * Has this view been pulled from the recycle bin? If so it does not need to be remeasured. */ @TargetApi(11) private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, boolean selected, boolean recycled) { final boolean isSelected = selected && shouldShowSelector(); final boolean updateChildSelected = isSelected != child.isSelected(); final int mode = mTouchMode; final boolean isPressed = mode > TOUCH_MODE_DOWN && mode < TOUCH_MODE_SCROLL && mMotionPosition == position; final boolean updateChildPressed = isPressed != child.isPressed(); final boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested(); // Respect layout params that are already in the view. Otherwise make some up... // noinspection unchecked AbsHListView.LayoutParams p = (AbsHListView.LayoutParams) child.getLayoutParams(); if (p == null) { p = (AbsHListView.LayoutParams) generateDefaultLayoutParams(); } p.viewType = mAdapter.getItemViewType(position); if ((recycled && !p.forceAdd) || (p.recycledHeaderFooter && p.viewType == AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER)) { attachViewToParent(child, flowDown ? -1 : 0, p); } else { p.forceAdd = false; if (p.viewType == AdapterView.ITEM_VIEW_TYPE_HEADER_OR_FOOTER) { p.recycledHeaderFooter = true; } addViewInLayout(child, flowDown ? -1 : 0, p, true); } if (updateChildSelected) { child.setSelected(isSelected); } if (updateChildPressed) { child.setPressed(isPressed); } if (mChoiceMode != ListView.CHOICE_MODE_NONE && mCheckStates != null) { if (child instanceof Checkable) { ((Checkable) child).setChecked(mCheckStates.get(position, false)); } else if (android.os.Build.VERSION.SDK_INT >= 11) { child.setActivated(mCheckStates.get(position, false)); } } if (needToMeasure) { int childHeightSpec = ViewGroup.getChildMeasureSpec(mHeightMeasureSpec, mListPadding.top + mListPadding.bottom, p.height); int lpWidth = p.width; int childWidthSpec; if (lpWidth > 0) { childWidthSpec = View.MeasureSpec.makeMeasureSpec(lpWidth, View.MeasureSpec.EXACTLY); } else { childWidthSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); } child.measure(childWidthSpec, childHeightSpec); } else { cleanupLayoutState(child); } final int w = child.getMeasuredWidth(); final int h = child.getMeasuredHeight(); final int childLeft = flowDown ? x : x - w; if (needToMeasure) { final int childBottom = childrenTop + h; final int childRight = childLeft + w; child.layout(childLeft, childrenTop, childRight, childBottom); } else { child.offsetLeftAndRight(childLeft - child.getLeft()); child.offsetTopAndBottom(childrenTop - child.getTop()); } if (mCachingStarted && !child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } if (android.os.Build.VERSION.SDK_INT >= 11) { if (recycled && (((AbsHListView.LayoutParams) child.getLayoutParams()).scrappedFromPosition) != position) { child.jumpDrawablesToCurrentState(); } } }
From source file:com.zoffcc.applications.zanavi.Navit.java
static void take_map_screenshot(String dir_name, String name_base) { try {//from w w w .ja v a 2 s.co m View v1 = Navit.N_NavitGraphics.view; v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); v1.setDrawingCacheEnabled(true); Bitmap bm = v1.getDrawingCache(); FileOutputStream out = null; try { out = new FileOutputStream(dir_name + "/" + name_base + ".png"); bm.compress(Bitmap.CompressFormat.PNG, 100, out); } catch (Exception e) { e.printStackTrace(); System.out.println("TSCR:004 " + e.getMessage()); } finally { v1.setDrawingCacheEnabled(false); try { if (out != null) { out.close(); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e4) { } }
From source file:com.zoffcc.applications.zanavi.Navit.java
static void take_phone_screenshot(Activity a, String dir_name, String name_base) { try {//from ww w . ja v a2 s.c om View v1 = a.getWindow().getDecorView().getRootView(); v1.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); v1.setDrawingCacheEnabled(true); Bitmap bm = v1.getDrawingCache(); FileOutputStream out = null; try { out = new FileOutputStream(dir_name + "/" + name_base + ".png"); bm.compress(Bitmap.CompressFormat.PNG, 100, out); } catch (Exception e) { e.printStackTrace(); System.out.println("TSCR:004 " + e.getMessage()); } finally { v1.setDrawingCacheEnabled(false); try { if (out != null) { out.close(); } } catch (IOException e) { e.printStackTrace(); } } } catch (Exception e4) { } }