@Test public void testGetOpacity() throws Exception { BorderDrawable opaque = new BorderDrawable(); opaque.setColor(Color.GREEN); assertThat(opaque.getOpacity(), is(PixelFormat.OPAQUE)); BorderDrawable transparent = new BorderDrawable(); transparent.setColor(WXResourceUtils.getColor("#00ff0000")); assertThat(transparent.getOpacity(), is(PixelFormat.TRANSPARENT)); BorderDrawable half = new BorderDrawable(); half.setColor(WXResourceUtils.getColor("#aaff0000")); assertThat(half.getOpacity(), is(PixelFormat.TRANSLUCENT)); BorderDrawable changeAlpha = new BorderDrawable(); changeAlpha.setColor(Color.RED); changeAlpha.setAlpha(15); assertThat(changeAlpha.getOpacity(), is(PixelFormat.TRANSLUCENT)); }
@SuppressWarnings("WrongConstant") @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); }
BorderDrawable extends Drawable { @SuppressWarnings("WrongConstant") @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } }
BorderDrawable extends Drawable { @SuppressWarnings("WrongConstant") @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); }
BorderDrawable extends Drawable { @SuppressWarnings("WrongConstant") @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @SuppressWarnings("WrongConstant") @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(int position, float width); void setBorderRadius(int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(int position, int color); void setBorderStyle(int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); }
BorderDrawable extends Drawable { @SuppressWarnings("WrongConstant") @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @SuppressWarnings("WrongConstant") @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(int position, float width); void setBorderRadius(int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(int position, int color); void setBorderStyle(int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); static final int BORDER_TOP_LEFT_RADIUS; static final int BORDER_TOP_RIGHT_RADIUS; static final int BORDER_BOTTOM_RIGHT_RADIUS; static final int BORDER_BOTTOM_LEFT_RADIUS; static final int BORDER_RADIUS_ALL; }