Java Code Examples for android.view.View#LAYER_TYPE_SOFTWARE

The following examples show how to use android.view.View#LAYER_TYPE_SOFTWARE . 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: CropOverlayView.java    From Android-Image-Cropper with 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 <= 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 File: ImageView.java    From Genius-Android with 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 3
Source File: Button.java    From Genius-Android with 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 4
Source File: UserListAdapter.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
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 5
Source File: UserListAdapter.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
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 6
Source File: CropOverlayView.java    From Lassi-Android with 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 7
Source File: FloatingActionButtonImpl.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
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 8
Source File: BrowserWeiboMsgCommentAndRepostAdapter.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
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 9
Source File: CropOverlayView.java    From timecat with 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 10
Source File: CropOverlayView.java    From giffun with 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 11
Source File: CircularFrameLayout.java    From pandroid with 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 12
Source File: FloatActionButton.java    From Genius-Android with Apache License 2.0 5 votes vote down vote up
@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 13
Source File: AbstractAppListAdapter.java    From iBeebo with GNU General Public License v3.0 5 votes vote down vote up
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 File: RevealAnimator.java    From fab-toolbar with MIT License 4 votes vote down vote up
RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 15
Source File: RevealAnimator.java    From PersistentSearchView with Apache License 2.0 4 votes vote down vote up
RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 16
Source File: CircularRevealAnimator.java    From Nibo with MIT License 4 votes vote down vote up
RevealFinishedIceCreamSandwich(CircularRevealAnimator target) {
    super(target);

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 17
Source File: RevealAnimator.java    From RecyclerView-Animation-Demo with Apache License 2.0 4 votes vote down vote up
RevealFinishedIceCreamSandwich(RevealAnimator target) {
    super(target);

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

    mLayerType = ((View) target).getLayerType();
    mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
 
Example 19
Source File: DMConversationAdapter.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
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
Source File: DMConversationAdapter.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
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);
        }

    }