BorderDrawable extends Drawable { @Override public int getOpacity() { return WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); @Override void draw(Canvas canvas); void setBorderWidth(int position, float width); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); void setBorderRadius(int position, float radius); @Override void getOutline(@NonNull Outline outline); void setBorderColor(int position, int color); void setBorderStyle(int position, @NonNull String style); int getColor(); void setColor(int color); @NonNull Path getContentPath(int viewTopPadding,
                      int viewRightPadding,
                      int viewBottomPadding,
                      int viewLeftPadding,
                      @NonNull RectF contentBox); 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; }
@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)); }