List of usage examples for android.view View getDrawingCache
@Deprecated
public Bitmap getDrawingCache()
Calling this method is equivalent to calling getDrawingCache(false)
.
From source file:com.example.zhaozhu.practisecustomview.customviewgroup.HSlidingPaneLayout2.java
@Override protected boolean drawChild(final Canvas canvas, final View child, final long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); boolean result; final int save = canvas.save(Canvas.CLIP_SAVE_FLAG); if (this.mCanSlide && !lp.slideable && (this.mSlideableView != null)) { // Clip against the slider; no sense drawing what will immediately // be covered. canvas.getClipBounds(this.mTmpRect); this.mTmpRect.right = Math.min(this.mTmpRect.right, this.mSlideableView.getLeft()); canvas.clipRect(this.mTmpRect); }/*from w ww . j ava 2 s . co m*/ if (Build.VERSION.SDK_INT >= 11) { // HC result = super.drawChild(canvas, child, drawingTime); } else { if (lp.dimWhenOffset && (this.mSlideOffset > 0)) { if (!child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } Bitmap cache = child.getDrawingCache(); if (cache != null && !cache.isRecycled()) { canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint); result = false; } else { Log.e(HSlidingPaneLayout2.TAG, "drawChild: child view " + child + " returned null drawing cache"); result = super.drawChild(canvas, child, drawingTime); } } else { if (child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(false); } result = super.drawChild(canvas, child, drawingTime); } } canvas.restoreToCount(save); return result; }
From source file:com.waz.zclient.pages.main.conversationpager.SlidingPaneLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); boolean result; final int save = canvas.save(Canvas.CLIP_SAVE_FLAG); if (canSlide && !lp.slideable && slideableView != null) { // Clip against the slider; no sense drawing what will immediately be covered. canvas.getClipBounds(tmpRect);/*from w ww . j a v a 2s. c om*/ if (isLayoutRtlSupport()) { tmpRect.left = Math.max(tmpRect.left, slideableView.getRight()); } else { tmpRect.right = Math.min(tmpRect.right, slideableView.getLeft()); } canvas.clipRect(tmpRect); } if (Build.VERSION.SDK_INT >= 11) { // HC result = super.drawChild(canvas, child, drawingTime); } else { if (lp.dimWhenOffset && slideOffset > 0) { if (!child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } final Bitmap cache = child.getDrawingCache(); if (cache != null) { canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint); result = false; } else { Timber.e("drawChild: child view %s returned null drawing cache", child); result = super.drawChild(canvas, child, drawingTime); } } else { if (child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(false); } result = super.drawChild(canvas, child, drawingTime); } } canvas.restoreToCount(save); return result; }
From source file:cn.zmdx.kaka.locker.widget.SlidingPaneLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); boolean result; final int save = canvas.save(Canvas.CLIP_SAVE_FLAG); if (mCanSlide && !lp.slideable && mSlideableView != null) { // Clip against the slider; no sense drawing what will immediately // be covered. canvas.getClipBounds(mTmpRect);//from www. ja v a 2 s . c om if (isLayoutRtlSupport()) { mTmpRect.left = Math.max(mTmpRect.left, mSlideableView.getRight()); } else { mTmpRect.right = Math.min(mTmpRect.right, mSlideableView.getLeft()); } canvas.clipRect(mTmpRect); } if (Build.VERSION.SDK_INT >= 11) { // HC result = super.drawChild(canvas, child, drawingTime); } else { if (lp.dimWhenOffset && mSlideOffset > 0) { if (!child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } final Bitmap cache = child.getDrawingCache(); if (cache != null) { canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint); result = false; } else { Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache"); result = super.drawChild(canvas, child, drawingTime); } } else { if (child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(false); } result = super.drawChild(canvas, child, drawingTime); } } canvas.restoreToCount(save); return result; }
From source file:com.mark.quick.ui.view.swipebacklayout.SwipeBackLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); boolean result; final int save = canvas.save(); if (mCanSlide && !lp.slideable && mSlideableView != null) { // Clip against the slider; no sense drawing what will immediately be covered. canvas.getClipBounds(mTmpRect);/*from w ww.ja v a 2 s. c o m*/ if (isLayoutRtlSupport()) { mTmpRect.left = Math.max(mTmpRect.left, mSlideableView.getRight()); } else { mTmpRect.right = Math.min(mTmpRect.right, mSlideableView.getLeft()); } canvas.clipRect(mTmpRect); } if (Build.VERSION.SDK_INT >= 11) { // HC result = super.drawChild(canvas, child, drawingTime); } else { if (lp.dimWhenOffset && mSlideOffset > 0) { if (!child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } final Bitmap cache = child.getDrawingCache(); if (cache != null) { canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint); result = false; } else { Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache"); result = super.drawChild(canvas, child, drawingTime); } } else { if (child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(false); } result = super.drawChild(canvas, child, drawingTime); } } canvas.restoreToCount(save); return result; }
From source file:cn.bingoogolapple.swipebacklayout.BGASwipeBackLayout.java
@Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); boolean result; final int save = canvas.save(Canvas.CLIP_SAVE_FLAG); if (mCanSlide && !lp.slideable && mSlideableView != null) { // Clip against the slider; no sense drawing what will immediately be covered. canvas.getClipBounds(mTmpRect);/*from w w w .j av a 2 s .c o m*/ if (isLayoutRtlSupport()) { mTmpRect.left = Math.max(mTmpRect.left, mSlideableView.getRight()); } else { mTmpRect.right = Math.min(mTmpRect.right, mSlideableView.getLeft()); } canvas.clipRect(mTmpRect); } if (Build.VERSION.SDK_INT >= 11) { // HC result = super.drawChild(canvas, child, drawingTime); } else { if (lp.dimWhenOffset && mSlideOffset > 0) { if (!child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(true); } final Bitmap cache = child.getDrawingCache(); if (cache != null) { canvas.drawBitmap(cache, child.getLeft(), child.getTop(), lp.dimPaint); result = false; } else { Log.e(TAG, "drawChild: child view " + child + " returned null drawing cache"); result = super.drawChild(canvas, child, drawingTime); } } else { if (child.isDrawingCacheEnabled()) { child.setDrawingCacheEnabled(false); } result = super.drawChild(canvas, child, drawingTime); } } canvas.restoreToCount(save); return result; }
From source file:com.app.blockydemo.ui.adapter.BrickAdapter.java
@Override public void onClick(final View view) { if (!viewSwitchLock.tryLock()) { return;/*from ww w. j ava2 s .c o m*/ } animatedBricks.clear(); final int itemPosition = calculateItemPositionAndTouchPointY(view); final List<CharSequence> items = new ArrayList<CharSequence>(); if (brickList.get(itemPosition) instanceof ScriptBrick) { int scriptIndex = getScriptIndexFromProject(itemPosition); ProjectManager.getInstance().setCurrentScript(sprite.getScript(scriptIndex)); } if (!(brickList.get(itemPosition) instanceof DeadEndBrick) && !(brickList.get(itemPosition) instanceof ScriptBrick)) { items.add(context.getText(R.string.brick_context_dialog_move_brick)); } if (brickList.get(itemPosition) instanceof NestingBrick) { items.add(context.getText(R.string.brick_context_dialog_animate_bricks)); } if (!(brickList.get(itemPosition) instanceof ScriptBrick)) { items.add(context.getText(R.string.brick_context_dialog_copy_brick)); items.add(context.getText(R.string.brick_context_dialog_delete_brick)); } else { items.add(context.getText(R.string.brick_context_dialog_edit_script_name)); items.add(context.getText(R.string.brick_context_dialog_delete_script)); } if (brickList.get(itemPosition) instanceof FormulaBrick) { items.add(context.getText(R.string.brick_context_dialog_formula_edit_brick)); } AlertDialog.Builder builder = new AlertDialog.Builder(context); boolean drawingCacheEnabled = view.isDrawingCacheEnabled(); view.setDrawingCacheEnabled(true); view.setDrawingCacheBackgroundColor(Color.TRANSPARENT); view.buildDrawingCache(true); if (view.getDrawingCache() != null) { Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache()); view.setDrawingCacheEnabled(drawingCacheEnabled); ImageView imageView = dragAndDropListView.getGlowingBorder(bitmap); builder.setCustomTitle(imageView); } builder.setItems(items.toArray(new CharSequence[items.size()]), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { CharSequence clickedItemText = items.get(item); if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_move_brick))) { view.performLongClick(); } else if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_copy_brick))) { copyBrickListAndProject(itemPosition); } else if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_delete_brick)) || clickedItemText.equals(context.getText(R.string.brick_context_dialog_delete_script))) { showConfirmDeleteDialog(itemPosition); } else if (clickedItemText.equals(context.getText(R.string.brick_context_dialog_animate_bricks))) { int itemPosition = calculateItemPositionAndTouchPointY(view); Brick brick = brickList.get(itemPosition); if (brick instanceof NestingBrick) { List<NestingBrick> list = ((NestingBrick) brick).getAllNestingBrickParts(true); for (Brick tempBrick : list) { animatedBricks.add(tempBrick); } } notifyDataSetChanged(); } else if (clickedItemText .equals(context.getText(R.string.brick_context_dialog_formula_edit_brick))) { if (brickList.get(itemPosition) instanceof FormulaBrick) { FormulaEditorFragment.showFragment(view, brickList.get(itemPosition), ((FormulaBrick) brickList.get(itemPosition)).getFormula()); } } else if (clickedItemText .equals(context.getText(R.string.brick_context_dialog_edit_script_name))) { ScriptNameDialog dialog2 = new ScriptNameDialog( ProjectManager.getInstance().getCurrentScript()); dialog2.show(((FragmentActivity) view.getContext()).getSupportFragmentManager(), ScriptNameDialog.DIALOG_FRAGMENT_TAG); initBrickList(); notifyDataSetChanged(); notifyDataSetInvalidated(); } } }); AlertDialog alertDialog = builder.create(); if ((selectMode == ListView.CHOICE_MODE_NONE)) { alertDialog.show(); } }
From source file:com.example.android_test.loopviewpager.LoopViewPager.java
Bitmap getViewBitmap(View v) { v.clearFocus();//from w ww.j ava 2s . com v.setPressed(false); // ?????????? boolean willNotCache = v.willNotCacheDrawing(); int color = v.getDrawingCacheBackgroundColor(); // ??????? v.setWillNotCacheDrawing(false); // ??????? v.setDrawingCacheBackgroundColor(0); // ???? if (color != 0) { v.destroyDrawingCache(); } // ?????? v.buildDrawingCache(); // ? Bitmap ? Bitmap cacheBitmap = v.getDrawingCache(); if (cacheBitmap == null) { Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException()); return null; } // ? Bitmap ???????? Bitmap ? Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // ?????????? v.destroyDrawingCache(); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; }
From source file:org.chinenv.onroad.loopview.LoopViewPager.java
Bitmap getViewBitmap(View v) { v.clearFocus();// w w w . jav a 2 s .c o m v.setPressed(false); // ?????????? boolean willNotCache = v.willNotCacheDrawing(); int color = v.getDrawingCacheBackgroundColor(); // ???????? v.setWillNotCacheDrawing(false); // ???????? v.setDrawingCacheBackgroundColor(0); // ????? if (color != 0) { v.destroyDrawingCache(); } // ?????? v.buildDrawingCache(); // ?Bitmap ?? Bitmap cacheBitmap = v.getDrawingCache(); if (cacheBitmap == null) { Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException()); return null; } // ?Bitmap ???????? Bitmap ? Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // ?????????? v.destroyDrawingCache(); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; }
From source file:com.baiiu.autoloopviewpager.loopvp.LoopViewPager.java
Bitmap getViewBitmap(View v) { v.clearFocus();//from w w w. ja v a 2 s . c om v.setPressed(false); // ?????????? boolean willNotCache = v.willNotCacheDrawing(); int color = v.getDrawingCacheBackgroundColor(); // ??????? v.setWillNotCacheDrawing(false); // ??????? v.setDrawingCacheBackgroundColor(0); // ???? if (color != 0) { v.destroyDrawingCache(); } // ?????? v.buildDrawingCache(); // ? Bitmap ? Bitmap cacheBitmap = v.getDrawingCache(); if (cacheBitmap == null) { if (DEBUG) Log.e(TAG, "failed getViewBitmap(" + v + ")", new RuntimeException()); return null; } // ? Bitmap ???????? Bitmap ? Bitmap bitmap = Bitmap.createBitmap(cacheBitmap); // ?????????? v.destroyDrawingCache(); v.setWillNotCacheDrawing(willNotCache); v.setDrawingCacheBackgroundColor(color); return bitmap; }
From source file:se.oort.clockify.widget.sgv.StaggeredGridView.java
private Bitmap createDraggedChildBitmap(View view) { view.setDrawingCacheEnabled(true);/*from w w w . j a v a2 s . co m*/ final Bitmap cache = view.getDrawingCache(); Bitmap bitmap = null; if (cache != null) { try { bitmap = cache.copy(Bitmap.Config.ARGB_8888, false); } catch (final OutOfMemoryError e) { Log.w(LOG_TAG, "Failed to copy bitmap from Drawing cache", e); bitmap = null; } } view.destroyDrawingCache(); view.setDrawingCacheEnabled(false); return bitmap; }