Java Code Examples for android.view.View#LAYER_TYPE_SOFTWARE

The following examples show how to use android.view.View#LAYER_TYPE_SOFTWARE . These examples are extracted from open source projects. 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 Project: Lassi-Android   File: CropOverlayView.java    License: MIT License 6 votes vote down vote up
/**
 * The shape of the cropping area - rectangle/circular.
 */
public void setCropShape(CropImageView.CropShape cropShape) {
    if (mCropShape != cropShape) {
        mCropShape = cropShape;
        if (Build.VERSION.SDK_INT <= 17) {
            if (mCropShape == CropImageView.CropShape.OVAL) {
                mOriginalLayerType = getLayerType();
                if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
                    // TURN off hardware acceleration
                    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
                } else {
                    mOriginalLayerType = null;
                }
            } else if (mOriginalLayerType != null) {
                // return hardware acceleration back
                setLayerType(mOriginalLayerType, null);
                mOriginalLayerType = null;
            }
        }
        invalidate();
    }
}
 
Example 2
Source Project: giffun   File: CropOverlayView.java    License: Apache License 2.0 6 votes vote down vote up
/** The shape of the cropping area - rectangle/circular. */
public void setCropShape(CropImageView.CropShape cropShape) {
  if (mCropShape != cropShape) {
    mCropShape = cropShape;
    if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 17) {
      if (mCropShape == CropImageView.CropShape.OVAL) {
        mOriginalLayerType = getLayerType();
        if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
          // TURN off hardware acceleration
          setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        } else {
          mOriginalLayerType = null;
        }
      } else if (mOriginalLayerType != null) {
        // return hardware acceleration back
        setLayerType(mOriginalLayerType, null);
        mOriginalLayerType = null;
      }
    }
    invalidate();
  }
}
 
Example 3
Source Project: timecat   File: CropOverlayView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The shape of the cropping area - rectangle/circular.
 */
public void setCropShape(CropImageView.CropShape cropShape) {
    if (mCropShape != cropShape) {
        mCropShape = cropShape;
        if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 17) {
            if (mCropShape == CropImageView.CropShape.OVAL) {
                mOriginalLayerType = getLayerType();
                if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
                    // TURN off hardware acceleration
                    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
                } else {
                    mOriginalLayerType = null;
                }
            } else if (mOriginalLayerType != null) {
                // return hardware acceleration back
                setLayerType(mOriginalLayerType, null);
                mOriginalLayerType = null;
            }
        }
        invalidate();
    }
}
 
Example 4
private void configLayerType(ViewHolder holder) {

        boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
        if (!disableHardAccelerated) {
            return;
        }

        int currentWidgetLayerType = holder.username.getLayerType();

        if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
            holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            if (holder.weiboTextContent != null) {
                holder.weiboTextContent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }

            if (holder.time != null) {
                holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }

        }

    }
 
Example 5
void updateFromViewRotation() {
  if (Build.VERSION.SDK_INT == 19) {
    // KitKat seems to have an issue with views which are rotated with angles which are
    // not divisible by 90. Worked around by moving to software rendering in these cases.
    if ((rotation % 90) != 0) {
      if (view.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
      }
    } else {
      if (view.getLayerType() != View.LAYER_TYPE_NONE) {
        view.setLayerType(View.LAYER_TYPE_NONE, null);
      }
    }
  }

  // Offset any View rotation
  if (shapeDrawable != null) {
    shapeDrawable.setShadowCompatRotation((int) rotation);
  }
}
 
Example 6
/** The shape of the cropping area - rectangle/circular. */
public void setCropShape(CropImageView.CropShape cropShape) {
  if (mCropShape != cropShape) {
    mCropShape = cropShape;
      if (Build.VERSION.SDK_INT <= 17) {
      if (mCropShape == CropImageView.CropShape.OVAL) {
        mOriginalLayerType = getLayerType();
        if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
          // TURN off hardware acceleration
          setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        } else {
          mOriginalLayerType = null;
        }
      } else if (mOriginalLayerType != null) {
        // return hardware acceleration back
        setLayerType(mOriginalLayerType, null);
        mOriginalLayerType = null;
      }
    }
    invalidate();
  }
}
 
Example 7
private void configLayerType(ViewHolder holder) {

        boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
        if (!disableHardAccelerated) {
            return;
        }

        int currentWidgetLayerType = holder.username.getLayerType();

        if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
            holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            if (holder.content != null) {
                holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }

        }

    }
 
Example 8
private void configLayerType(ViewHolder holder) {

        boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
        if (!disableHardAccelerated) {
            return;
        }

        int currentWidgetLayerType = holder.username.getLayerType();

        if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
            holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            if (holder.content != null) {
                holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }

        }

    }
 
Example 9
Source Project: Genius-Android   File: Button.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * In this, you can set TouchEffectDrawable,
 * to init TouchEffectDrawable.
 * <p>
 * If you not need touch effect,
 * you should set NULL.
 * <p>
 * But, if need it,
 * you should call {@link TouchEffectDrawable#setEffect(Effect)}
 *
 * @param touchDrawable TouchEffectDrawable
 */
public void setTouchDrawable(TouchEffectDrawable touchDrawable) {
    if (mTouchDrawable != touchDrawable) {
        if (mTouchDrawable != null) {
            mTouchDrawable.setCallback(null);
        }
        if (touchDrawable != null) {
            touchDrawable.setCallback(this);
            // We must set layer type is View.LAYER_TYPE_SOFTWARE,
            // to support Canvas.clipPath()
            // on Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
            if (getLayerType() != View.LAYER_TYPE_SOFTWARE)
                setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        mTouchDrawable = touchDrawable;
    }
}
 
Example 10
Source Project: Genius-Android   File: ImageView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * In this, you can set TouchEffectDrawable,
 * to init TouchEffectDrawable.
 * <p>
 * If you not need touch effect,
 * you should set NULL.
 * <p>
 * But, if need it,
 * you should call {@link TouchEffectDrawable#setEffect(Effect)}
 *
 * @param touchDrawable TouchEffectDrawable
 */
public void setTouchDrawable(TouchEffectDrawable touchDrawable) {
    if (mTouchDrawable != touchDrawable) {
        if (mTouchDrawable != null) {
            mTouchDrawable.setCallback(null);
        }
        if (touchDrawable != null) {
            touchDrawable.setCallback(this);
            // We must set layer type is View.LAYER_TYPE_SOFTWARE,
            // to support Canvas.clipPath()
            // on Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
            if (getLayerType() != View.LAYER_TYPE_SOFTWARE)
                setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        mTouchDrawable = touchDrawable;
    }
}
 
Example 11
@Override
public void setLayerType(int layerType, Paint paint) {
    // In this, to support Canvas.clipPath(),
    // must set layerType is View.LAYER_TYPE_SOFTWARE
    layerType = View.LAYER_TYPE_SOFTWARE;
    super.setLayerType(layerType, paint);
}
 
Example 12
Source Project: pandroid   File: CircularFrameLayout.java    License: Apache License 2.0 5 votes vote down vote up
public void setClipOutEnable(boolean clip) {
    if (mClipOutEnable != clip) {
        if (mLayerType != View.LAYER_TYPE_SOFTWARE) {
            setLayerType(clip ? View.LAYER_TYPE_SOFTWARE : mLayerType, null);
        }
        mClipOutEnable = clip;
        invalidate();
    }
}
 
Example 13
private void configLayerType(ViewHolder holder) {

        boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
        if (!disableHardAccelerated) {
            return;
        }

        int currentWidgetLayerType = holder.username.getLayerType();

        if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
            holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            if (holder.weiboTextContent != null) {
                holder.weiboTextContent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }
            if (holder.repost_content != null) {
                holder.repost_content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }
            if (holder.time != null) {
                holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }
            if (holder.repost_count != null) {
                holder.repost_count.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }
            if (holder.comment_count != null) {
                holder.comment_count.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }
        }

    }
 
Example 14
Source Project: Nibo   File: CircularRevealAnimator.java    License: MIT License 4 votes vote down vote up
RevealFinishedIceCreamSandwich(CircularRevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 15
Source Project: fab-toolbar   File: RevealAnimator.java    License: MIT License 4 votes vote down vote up
RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 16
RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 17
RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 18
Source Project: fab-transformation   File: RevealAnimator.java    License: MIT License 4 votes vote down vote up
RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 19
private void configLayerType(ViewHolder holder) {

        boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
        if (!disableHardAccelerated)
            return;

        int currentWidgetLayerType = holder.content.getLayerType();

        if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
            holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

            if (holder.time != null)
                holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }

    }
 
Example 20
private void configLayerType(ViewHolder holder) {

        boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
        if (!disableHardAccelerated)
            return;

        int currentWidgetLayerType = holder.content.getLayerType();

        if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
            holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

            if (holder.time != null)
                holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }

    }