List of usage examples for android.view View LAYER_TYPE_HARDWARE
int LAYER_TYPE_HARDWARE
To view the source code for android.view View LAYER_TYPE_HARDWARE.
Click Source Link
Indicates that the view has a hardware layer.
From source file:com.abct.tljr.news.widget.ZoomableImageView.java
@Override protected void onDraw(Canvas canvas) { // Check if the bitmap was ever set if (mBitmap != null && !mBitmap.isRecycled()) { // If the current version is above Gingerbread and the layer type is // hardware accelerated, the paint is no longer needed if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && getLayerType() == View.LAYER_TYPE_HARDWARE) { canvas.drawBitmap(mBitmap, mMatrix, null); } else {/*from w ww . ja v a2 s . c o m*/ // Check if the time between draws has been met and draw the bitmap if ((System.currentTimeMillis() - mLastDraw) > sPaintDelay) { canvas.drawBitmap(mBitmap, mMatrix, mPaint); mLastDraw = System.currentTimeMillis(); } // Otherwise draw the bitmap without the paint and resubmit a new request else { canvas.drawBitmap(mBitmap, mMatrix, null); removeCallbacks(mRefresh); postDelayed(mRefresh, sPaintDelay); } } } }
From source file:com.android.messaging.ui.conversationlist.ConversationListSwipeHelper.java
/** * Enable a hardware layer for the it view and build that layer. *///from w w w. ja v a 2s. c o m private void setHardwareAnimatingLayerType(final ConversationListItemView itemView, final boolean animating) { if (animating) { itemView.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (itemView.getWindowToken() != null) { itemView.buildLayer(); } } else { itemView.setLayerType(View.LAYER_TYPE_NONE, null); } }
From source file:com.mylikes.likes.etchasketch.Slate.java
@SuppressLint("NewApi") private void init() { // setWillNotCacheDrawing(true); // setDrawingCacheEnabled(false); mEmpty = true;//from w ww .j a v a 2s.com // setup brush bitmaps final ActivityManager am = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mMemClass = am.getLargeMemoryClass(); } else { mMemClass = am.getMemoryClass(); } mLowMem = (mMemClass <= 16); if (true || DEBUG) { Log.v(TAG, "Slate.init: memClass=" + mMemClass + (mLowMem ? " (LOW)" : "")); } final Resources res = getContext().getResources(); // mCircleBits = BitmapFactory.decodeResource(res, R.drawable.circle_1bpp); // if (mCircleBits == null) { Log.e(TAG, "SmoothStroker: Couldn't load circle bitmap"); } // mCircleBitsFrame = new Rect(0, 0, mCircleBits.getWidth(), mCircleBits.getHeight()); BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPreferredConfig = Bitmap.Config.ALPHA_8; if (mLowMem) { // let's see how this works in practice opts.inSampleSize = 4; } mAirbrushBits = BitmapFactory.decodeResource(res, R.drawable.airbrush_light, opts); if (mAirbrushBits == null) { Log.e(TAG, "SmoothStroker: Couldn't load airbrush bitmap"); } mAirbrushBitsFrame = new Rect(0, 0, mAirbrushBits.getWidth(), mAirbrushBits.getHeight()); //Log.v(TAG, "airbrush: " + mAirbrushBitsFrame.right + "x" + mAirbrushBitsFrame.bottom); mFountainPenBits = BitmapFactory.decodeResource(res, R.drawable.fountainpen, opts); if (mFountainPenBits == null) { Log.e(TAG, "SmoothStroker: Couldn't load fountainpen bitmap"); } mFountainPenBitsFrame = new Rect(0, 0, mFountainPenBits.getWidth(), mFountainPenBits.getHeight()); // set up individual strokers for each pointer mStrokes = new MarkersPlotter[MAX_POINTERS]; // TODO: don't bother unless hasSystemFeature(MULTITOUCH_DISTINCT) for (int i = 0; i < mStrokes.length; i++) { mStrokes[i] = new MarkersPlotter(); } mPressureCooker = new PressureCooker(getContext()); setFocusable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { if (HWLAYER) { setLayerType(View.LAYER_TYPE_HARDWARE, null); } else if (SWLAYER) { setLayerType(View.LAYER_TYPE_SOFTWARE, null); } else { setLayerType(View.LAYER_TYPE_NONE, null); } } mWorkspacePaint = new Paint(); mWorkspacePaint.setColor(0x40606060); mBlitPaint = new Paint(); if (true) { mDebugPaints[0] = new Paint(); mDebugPaints[0].setStyle(Paint.Style.STROKE); mDebugPaints[0].setStrokeWidth(2.0f); mDebugPaints[0].setARGB(255, 0, 255, 255); mDebugPaints[1] = new Paint(mDebugPaints[0]); mDebugPaints[1].setARGB(255, 255, 0, 128); mDebugPaints[2] = new Paint(mDebugPaints[0]); mDebugPaints[2].setARGB(255, 0, 255, 0); mDebugPaints[3] = new Paint(mDebugPaints[0]); mDebugPaints[3].setARGB(255, 30, 30, 255); mDebugPaints[4] = new Paint(); mDebugPaints[4].setStyle(Paint.Style.FILL); mDebugPaints[4].setARGB(255, 128, 128, 128); } }
From source file:org.chromium.chrome.browser.payments.ui.EditorView.java
@Override public void onShow(DialogInterface dialog) { assert mDialogInOutAnimator == null; // Hide keyboard and disable EditText views for animation efficiency. if (getCurrentFocus() != null) UiUtils.hideKeyboard(getCurrentFocus()); for (int i = 0; i < mEditableTextFields.size(); i++) { mEditableTextFields.get(i).setEnabled(false); }// ww w .ja v a 2 s . c o m mLayout.setLayerType(View.LAYER_TYPE_HARDWARE, null); mLayout.buildLayer(); Animator popUp = ObjectAnimator.ofFloat(mLayout, View.TRANSLATION_Y, mLayout.getHeight(), 0f); Animator fadeIn = ObjectAnimator.ofFloat(mLayout, View.ALPHA, 0f, 1f); AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(popUp, fadeIn); mDialogInOutAnimator = animatorSet; mDialogInOutAnimator.setDuration(DIALOG_ENTER_ANIMATION_MS); mDialogInOutAnimator.setInterpolator(new LinearOutSlowInInterpolator()); mDialogInOutAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mLayout.setLayerType(View.LAYER_TYPE_NONE, null); for (int i = 0; i < mEditableTextFields.size(); i++) { mEditableTextFields.get(i).setEnabled(true); } // Note that keyboard will not show for dropdown field since it's not necessary. if (getCurrentFocus() != null) UiUtils.showKeyboard(getCurrentFocus()); mDialogInOutAnimator = null; initFocus(); } }); mDialogInOutAnimator.start(); }
From source file:com.test.xujixiao.xjx.widget.view.BaseZoomableImageView.java
@SuppressLint("NewApi") @Override/*from w ww. ja v a 2s. c om*/ protected void onDraw(Canvas canvas) { // Check if the bitmap was ever set if (mBitmap != null && !mBitmap.isRecycled()) { // If the current version is above Gingerbread and the layer type is // hardware accelerated, the paint is no longer needed if (Build.VERSION.SDK_INT >= MIN_SDK_ENABLE_LAYER_TYPE_HARDWARE && getLayerType() == View.LAYER_TYPE_HARDWARE) { canvas.drawBitmap(mBitmap, mMatrix, null); } else { // Check if the time between draws has been met and draw the bitmap if ((System.currentTimeMillis() - mLastDraw) > sPaintDelay) { canvas.drawBitmap(mBitmap, mMatrix, mPaint); mLastDraw = System.currentTimeMillis(); } // Otherwise draw the bitmap without the paint and resubmit a new request else { canvas.drawBitmap(mBitmap, mMatrix, null); removeCallbacks(mRefresh); postDelayed(mRefresh, sPaintDelay); } } } }
From source file:cn.jmessage.android.uikit.pickerimage.view.BaseZoomableImageView.java
@SuppressLint("NewApi") @Override/* w w w. j av a2 s .c o m*/ protected void onDraw(Canvas canvas) { // Check if the bitmap was ever set if (mBitmap != null && !mBitmap.isRecycled()) { // If the current version is above Gingerbread and the layer type is // hardware accelerated, the paint is no longer needed if (Build.VERSION.SDK_INT >= MIN_SDK_ENABLE_LAYER_TYPE_HARDWARE && getLayerType() == View.LAYER_TYPE_HARDWARE) { canvas.drawBitmap(mBitmap, mMatrix, null); } else { // Check if the time between draws has been met and draw the bitmap if ((System.currentTimeMillis() - mLastDraw) > sPaintDelay) { canvas.drawBitmap(mBitmap, mMatrix, mPaint); mLastDraw = System.currentTimeMillis(); } // Otherwise draw the bitmap without the paint and resubmit a new request else { canvas.drawBitmap(mBitmap, mMatrix, null); removeCallbacks(mRefresh); postDelayed(mRefresh, sPaintDelay); } } } }
From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java
private AnimatorSet newOpenNavAnimator() { ObjectAnimator ncTransX = ObjectAnimator.ofFloat(navContainer, "translationX", -fullNavWidth, 0); ObjectAnimator tpTransX = ObjectAnimator.ofFloat(thingContainer, "translationX", 0, fullNavWidth); AnimatorSet as = new AnimatorSet(); as.setDuration(durationMs).play(ncTransX).with(tpTransX); as.addListener(new AnimatorListenerAdapter() { @Override//from w w w. j a va2s . c o m public void onAnimationStart(Animator animation) { navContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); navContainer.setVisibility(View.VISIBLE); thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); thingContainer.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) { navContainer.setLayerType(View.LAYER_TYPE_NONE, null); thingContainer.setLayerType(View.LAYER_TYPE_NONE, null); thingContainer.setVisibility(View.GONE); } }); return as; }
From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java
private AnimatorSet newCloseNavAnimator() { ObjectAnimator ncTransX = ObjectAnimator.ofFloat(navContainer, "translationX", 0, -leftWidth); AnimatorSet as = new AnimatorSet(); as.setDuration(durationMs).play(ncTransX); as.addListener(new AnimatorListenerAdapter() { @Override/*from ww w . java2 s. co m*/ public void onAnimationStart(Animator animation) { navContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); navContainer.setVisibility(View.VISIBLE); thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null); thingContainer.setVisibility(View.GONE); thingContainer.setTranslationX(0); } @Override public void onAnimationEnd(Animator animation) { navContainer.setLayerType(View.LAYER_TYPE_NONE, null); navContainer.setVisibility(View.GONE); thingContainer.setLayerType(View.LAYER_TYPE_NONE, null); thingContainer.setVisibility(View.VISIBLE); } }); return as; }
From source file:com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator.java
@SuppressLint("NewApi") public ObjectAnimator get() { if (hasView()) { Collection<PropertyValuesHolder> holders = mPropertyHoldersMap.values(); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mView.get(), holders.toArray(new PropertyValuesHolder[holders.size()])); if (mWithLayer) { animator.addListener(new AnimatorListenerAdapter() { int mCurrentLayerType = View.LAYER_TYPE_NONE; @Override/* ww w . j a v a2 s .c o m*/ public void onAnimationStart(Animator animation) { if (hasView()) { View view = mView.get(); mCurrentLayerType = view.getLayerType(); view.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (ViewCompat.isAttachedToWindow(view)) { view.buildLayer(); } } } @Override public void onAnimationEnd(Animator animation) { if (hasView()) { mView.get().setLayerType(mCurrentLayerType, null); } } }); } if (mStartDelay != -1) { animator.setStartDelay(mStartDelay); } if (mDuration != -1) { animator.setDuration(mDuration); } if (mInterpolator != null) { animator.setInterpolator(mInterpolator); } for (Animator.AnimatorListener listener : mListeners) { animator.addListener(listener); } if (mMarginListener != null) { animator.addUpdateListener(mMarginListener); } if (mDimensionListener != null) { animator.addUpdateListener(mDimensionListener); } if (mPaddingListener != null) { animator.addUpdateListener(mPaddingListener); } if (mScrollListener != null) { animator.addUpdateListener(mScrollListener); } if (mPercentListener != null) { animator.addUpdateListener(mPercentListener); } for (ValueAnimator.AnimatorUpdateListener listener : mUpdateListeners) { animator.addUpdateListener(listener); } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { for (Animator.AnimatorPauseListener listener : mPauseListeners) { animator.addPauseListener(listener); } } return animator; } return ObjectAnimator.ofFloat(null, View.ALPHA, 1, 1); }
From source file:com.owen.view.views.PieChart.java
private void setLayerToHW(View v) { if (!v.isInEditMode() && Build.VERSION.SDK_INT >= 11) { setLayerType(View.LAYER_TYPE_HARDWARE, null); } }