Java Code Examples for android.view.View.LAYER_TYPE_HARDWARE

The following are Jave code examples for showing how to use LAYER_TYPE_HARDWARE of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ucar-weex-core   File: WXComponent.java   Source Code and License Vote up 6 votes
public void destroy() {
  ComponentObserver observer;
  if ((observer = getInstance().getComponentObserver()) != null) {
    observer.onPreDestory(this);
  }

  if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread");
  }
  if(mHost!= null && mHost.getLayerType()==View.LAYER_TYPE_HARDWARE && isLayerTypeEnabled()) {
    mHost.setLayerType(View.LAYER_TYPE_NONE, null);
  }
  removeAllEvent();
  removeStickyStyle();

  View view;
  if(mDomObj.isFixed() && (view = getHostView()) != null){
    getInstance().removeFixedView(view);
  }

  mDomObj = ImmutableDomObject.DESTROYED;
  mIsDestroyed = true;
}
 
Example 2
Project: JewelryUI   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void manageLayer(View v, boolean enableHardware) {
	if (!API_11) return;
	int layerType = enableHardware ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
	if (layerType != v.getLayerType())
		v.setLayerType(layerType, null);
}
 
Example 3
Project: xlight_android_native   File: SlidingMenu.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen) {
    if (Build.VERSION.SDK_INT < 11) return;

    boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
    final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;

    if (layerType != getContent().getLayerType()) {
        mHandler.post(new Runnable() {
            public void run() {
                Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
                getContent().setLayerType(layerType, null);
                getMenu().setLayerType(layerType, null);
                if (getSecondaryMenu() != null) {
                    getSecondaryMenu().setLayerType(layerType, null);
                }
            }
        });
    }
}
 
Example 4
Project: LiuAGeAndroid   File: SlidingMenu.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen) {
	if (Build.VERSION.SDK_INT < 11) return;

	boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
	final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;

	if (layerType != getContent().getLayerType()) {
		getHandler().post(new Runnable() {
			public void run() {
				Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
				getContent().setLayerType(layerType, null);
				getMenu().setLayerType(layerType, null);
				if (getSecondaryMenu() != null) {
					getSecondaryMenu().setLayerType(layerType, null);
				}
			}
		});
	}
}
 
Example 5
Project: JazzyViewPager   File: JazzyViewPager.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void manageLayer(View v, boolean enableHardware) {
	if (!API_11) return;
	int layerType = enableHardware ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
	if (layerType != v.getLayerType())
		v.setLayerType(layerType, null);
}
 
Example 6
Project: DailyZhiHu   File: SlidingMenu.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen) {
	if (Build.VERSION.SDK_INT < 11) return;

	boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
	final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;

	if (layerType != getContent().getLayerType()) {
		getHandler().post(new Runnable() {
			public void run() {
				Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
				getContent().setLayerType(layerType, null);
				getMenu().setLayerType(layerType, null);
				if (getSecondaryMenu() != null) {
					getSecondaryMenu().setLayerType(layerType, null);
				}
			}
		});
	}
}
 
Example 7
Project: weex-uikit   File: WXComponent.java   Source Code and License Vote up 6 votes
/********************************
 *  end hook Activity life cycle callback
 ********************************************************/


public void destroy() {
  if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread");
  }
  if(mHost!= null && mHost.getLayerType()==View.LAYER_TYPE_HARDWARE) {
    mHost.setLayerType(View.LAYER_TYPE_NONE, null);
  }
  removeAllEvent();
  removeStickyStyle();
  if (mDomObj != null) {
    mDomObj = null;
  }
}
 
Example 8
Project: WeatherStream   File: SlidingMenu.java   Source Code and License Vote up 6 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen) {
	if (Build.VERSION.SDK_INT < 11) return;

	boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
	final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;

	if (layerType != getContent().getLayerType()) {
		getHandler().post(new Runnable() {
			public void run() {
				Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
				getContent().setLayerType(layerType, null);
				getMenu().setLayerType(layerType, null);
				if (getSecondaryMenu() != null) {
					getSecondaryMenu().setLayerType(layerType, null);
				}
			}
		});
	}
}
 
Example 9
Project: GitHub   File: InfiniteCycleManager.java   Source Code and License Vote up 5 votes
private void enableHardwareLayer(final View v) {
    final int layerType = Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ?
            View.LAYER_TYPE_NONE : View.LAYER_TYPE_HARDWARE;
    if (v.getLayerType() != layerType) v.setLayerType(layerType, null);
}
 
Example 10
Project: weex-3d-map   File: WXComponent.java   Source Code and License Vote up 5 votes
public void destroy() {
  if (WXEnvironment.isApkDebugable() && !WXUtils.isUiThread()) {
    throw new WXRuntimeException("[WXComponent] destroy can only be called in main thread");
  }
  if(mHost!= null && mHost.getLayerType()==View.LAYER_TYPE_HARDWARE) {
    mHost.setLayerType(View.LAYER_TYPE_NONE, null);
  }
  removeAllEvent();
  removeStickyStyle();
  if (mDomObj != null) {
    mDomObj.destroy();
  }
}
 
Example 11
Project: MinimalismJotter   File: ZoomableImageView.java   Source Code and License Vote up 5 votes
@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{
			// 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);
			}
		}
	}
}
 
Example 12
Project: ChatExchange-old   File: SlidingMenu.java   Source Code and License Vote up 5 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen)
{
    if (Build.VERSION.SDK_INT < 11)
    {
        return;
    }

    boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
    final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;

    if (layerType != getContent().getLayerType())
    {
        getHandler().post(new Runnable()
        {
            public void run()
            {
                Log.v(TAG, "changing layerType. hardware? " + (layerType == View.LAYER_TYPE_HARDWARE));
                getContent().setLayerType(layerType, null);
                getMenu().setLayerType(layerType, null);
                if (getSecondaryMenu() != null)
                {
                    getSecondaryMenu().setLayerType(layerType, null);
                }
            }
        });
    }
}
 
Example 13
Project: decoy   File: BaseZoomableImageView.java   Source Code and License Vote up 5 votes
@SuppressLint("NewApi")
@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 >=  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);
			}
		}			
	}
}
 
Example 14
Project: android_additive_animations   File: AdditiveAnimationStateManager.java   Source Code and License Vote up 5 votes
void onAnimationApplierStart(AdditiveAnimationAccumulator applier) {
    // only now are we expecting updates from this applier
    if(mUseHardwareLayer && mAnimationTargetView instanceof View) {
        if(((View)mAnimationTargetView).getLayerType() != View.LAYER_TYPE_HARDWARE) {
            ((View)mAnimationTargetView).setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }
    }
}
 
Example 15
Project: JewelryUI   File: RevealAnimator.java   Source Code and License Vote up 4 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
RevealFinishedJellyBeanMr2(RevealAnimator target) {
    super(target);

    mFeaturedLayerType = View.LAYER_TYPE_HARDWARE;
}
 
Example 16
Project: Nibo   File: RevealAnimator.java   Source Code and License Vote up 4 votes
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
RevealFinishedJellyBeanMr2(RevealAnimator target) {
    super(target);

    mFeaturedLayerType = View.LAYER_TYPE_HARDWARE;
}