Java Code Examples for android.view.View#LAYER_TYPE_HARDWARE

The following examples show how to use android.view.View#LAYER_TYPE_HARDWARE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SlidingMenu.java    From appcan-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void manageLayers(float percentOpen) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && !isHardwareAccelerated()) {
        boolean layer = percentOpen > 0.0f && percentOpen < 1.0f;
        final int layerType = layer ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_SOFTWARE;

        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 2
Source File: SlidingMenu.java    From Moring-Alarm with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: SlidingMenu.java    From zen4android with MIT License 6 votes vote down vote up
@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 4
Source File: RunningAnimationsManager.java    From android_additive_animations with Apache License 2.0 6 votes vote down vote up
void onAnimationAccumulatorStart(AdditiveAnimationAccumulator accumulator) {
    Collection<AdditiveAnimation> animations = accumulator.getAnimations(mAnimationTarget);
    for (AdditiveAnimation animation : animations) {
        if (animation.getAssociatedAnimationState() == null) {
            continue;
        }
        if (animation.getAssociatedAnimationState().shouldRun(mCurrentState)) {
            if (animation.getAssociatedAnimationState().getAnimationStartAction() != null) {
                animation.getAssociatedAnimationState().getAnimationStartAction().onStart(mAnimationTarget);
            }
        } else {
            accumulator.removeAnimation(animation.getTag(), animation.getTarget());
        }
    }
    if (accumulator.getAnimations().isEmpty()) {
        mAdditiveAnimationAccumulators.remove(accumulator);
        removeStateManagerIfAccumulatorSetIsEmpty();
    } else {
        // only now are we expecting updates from this applier
        if (mUseHardwareLayer && mAnimationTarget instanceof View) {
            if (((View) mAnimationTarget).getLayerType() != View.LAYER_TYPE_HARDWARE) {
                ((View) mAnimationTarget).setLayerType(View.LAYER_TYPE_HARDWARE, null);
            }
        }
    }
}
 
Example 5
Source File: SlidingMenu.java    From wakao-app with MIT License 6 votes vote down vote up
@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 6
Source File: ReactViewGroup.java    From react-native-GPay with MIT License 6 votes vote down vote up
public void setBorderRadius(float borderRadius, int position) {
  ReactViewBackgroundDrawable backgroundDrawable = getOrCreateReactViewBackground();
  backgroundDrawable.setRadius(borderRadius, position);

  if (Build.VERSION_CODES.HONEYCOMB < Build.VERSION.SDK_INT
      && Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
    final int UPDATED_LAYER_TYPE =
        backgroundDrawable.hasRoundedBorders()
            ? View.LAYER_TYPE_SOFTWARE
            : View.LAYER_TYPE_HARDWARE;

    if (UPDATED_LAYER_TYPE != getLayerType()) {
      setLayerType(UPDATED_LAYER_TYPE, null);
    }
  }
}
 
Example 7
Source File: CameraAppUI.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onModeListClosed()
{
    // Convert hardware layers back to default layer types when animation stops
    // to prevent accidental artifacting.
    if (mModeOptionsToggle.getLayerType() == View.LAYER_TYPE_HARDWARE ||
            mShutterButton.getLayerType() == View.LAYER_TYPE_HARDWARE)
    {
        Log.v(TAG, "Disabling hardware layer for the Mode Options Toggle Button.");
        mModeOptionsToggle.setLayerType(View.LAYER_TYPE_NONE, null);
        Log.v(TAG, "Disabling hardware layer for the Shutter Button.");
        mShutterButton.setLayerType(View.LAYER_TYPE_NONE, null);
    }

    // Make sure the alpha on mode options ellipse is reset when mode drawer
    // is closed.
    mModeOptionsToggle.setAlpha(1f);
    mShutterButton.setAlpha(ShutterButton.ALPHA_WHEN_ENABLED);
}
 
Example 8
Source File: SlidingMenu.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@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
Source File: JazzyViewPager.java    From android-kernel-tweaker with GNU General Public License v3.0 5 votes vote down vote up
@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 10
Source File: JazzyViewPager.java    From JazzyViewPager with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: JazzyViewPager.java    From Contacts with MIT License 5 votes vote down vote up
@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 12
Source File: MovieRowView.java    From android-movies-demo with MIT License 5 votes vote down vote up
@Override
public void setUseHardwareLayers(boolean useHardwareLayers) {
	// TODO: While this helps performance, it does result in a spike when you first start sliding
	// Maybe there's some solution where some of the Views remain in a HW layer throughout?

	int toLayerType = useHardwareLayers ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
	if (mPosterView.getLayerType() != toLayerType) {
		mPosterView.setLayerType(toLayerType, null);
		mTitleView.setLayerType(toLayerType, null);
		mSubtitleView.setLayerType(toLayerType, null);
		mContentContainer.setLayerType(toLayerType, null);
	}
}
 
Example 13
Source File: Animer.java    From Animer with Apache License 2.0 5 votes vote down vote up
private void setHardwareAcceleration(boolean bool){

        if(HARDWAREACCELERATION_IS_ENABLED && mTarget !=null){
            if(bool){
                if(((View)mTarget).getLayerType() == View.LAYER_TYPE_NONE){
                    ((View)mTarget).setLayerType(View.LAYER_TYPE_HARDWARE,null);
                }
            }
            else{
                if(((View)mTarget).getLayerType() == View.LAYER_TYPE_HARDWARE){
                    ((View)mTarget).setLayerType(View.LAYER_TYPE_NONE,null);
                }
            }
        }
    }
 
Example 14
Source File: JazzyViewPager.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@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 15
Source File: SlidingRevealViewGroup.java    From android-movies-demo with MIT License 5 votes vote down vote up
public void setUseHardwareLayers(boolean useHardwareLayers) {
	// For subclasses to initialize hardware layers during animations

	int toLayerType = useHardwareLayers ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
	mSlideOverlayLeft.setLayerType(toLayerType, null);
	mSlideOverlayMiddle.setLayerType(toLayerType, null);
	mSlideOverlayRight.setLayerType(toLayerType, null);
}
 
Example 16
Source File: SdkCenteredViewPager.java    From Android-SDK-Demo with MIT License 5 votes vote down vote up
private void enableLayers(boolean enable)
{
    final int childCount = getChildCount();
    for ( int i = 0; i < childCount; i++ )
    {
        final int layerType = enable ?
                View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
        getChildAt( i ).setLayerType( layerType, null );
    }
}
 
Example 17
Source File: SdkCenteredViewPager.java    From Android-SDK-Demo with MIT License 5 votes vote down vote up
private void enableLayers(boolean enable)
{
    final int childCount = getChildCount();
    for ( int i = 0; i < childCount; i++ )
    {
        final int layerType = enable ?
                View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE;
        getChildAt( i ).setLayerType( layerType, null );
    }
}
 
Example 18
Source File: CircularRevealAnimator.java    From Nibo with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
RevealFinishedJellyBeanMr2(CircularRevealAnimator target) {
    super(target);

    mFeaturedLayerType = View.LAYER_TYPE_HARDWARE;
}
 
Example 19
Source File: RevealAnimator.java    From material-sheet-fab with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
RevealFinishedJellyBeanMr2(RevealAnimator target) {
    super(target);

    mFeaturedLayerType = View.LAYER_TYPE_HARDWARE;
}
 
Example 20
Source File: RevealAnimator.java    From fab-transformation with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
RevealFinishedJellyBeanMr2(RevealAnimator target) {
    super(target);

    mFeaturedLayerType = View.LAYER_TYPE_HARDWARE;
}