Example usage for android.graphics.drawable Drawable getOpacity

List of usage examples for android.graphics.drawable Drawable getOpacity

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable getOpacity.

Prototype

public abstract @PixelFormat.Opacity int getOpacity();

Source Link

Document

Return the opacity/transparency of this Drawable.

Usage

From source file:com.example.zhaozhu.practisecustomview.customviewgroup.HSlidingPaneLayout.java

private static boolean viewIsOpaque(final View v) {
    //if (ViewCompat.isOpaque(v))
    //{/*from  w  w  w  . ja v  a  2  s .c om*/
    //   return true;
    //}

    // View#isOpaque didn't take all valid opaque scrollbar modes into
    // account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque
    // above and return false
    // here. On older devices, check the view's background drawable directly
    // as a fallback.
    if (Build.VERSION.SDK_INT >= 18) {
        return false;
    }

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}

From source file:name.teze.layout.lib.SlidingPaneLayout.java

public static boolean isOpaque(View view) {
    final Drawable bg = view.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }/*from   w  ww .  j a  va2  s . c  o  m*/
    return false;
}

From source file:name.teze.layout.lib.SlidingPaneLayout.java

private static boolean viewIsOpaque(View v) {
    if (isOpaque(v))
        return true;// hack by Fooyou

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18)
        return false;

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }//w  w w.jav  a 2 s. c  o  m
    return false;
}

From source file:com.polyvi.xface.extension.XAppExt.java

private String drawableToBase64(Drawable drawable) {
    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();
    Bitmap bitmap = Bitmap.createBitmap(width, height,
            drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, width, height);
    drawable.draw(canvas);//from  ww w .ja  v  a2 s  .c  om
    String result = null;
    ByteArrayOutputStream baos = null;
    try {
        if (bitmap != null) {
            baos = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
            baos.flush();
            baos.close();
            byte[] bitmapBytes = baos.toByteArray();
            result = XBase64.encodeToString(bitmapBytes, Base64.DEFAULT);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            if (baos != null) {
                baos.flush();
                baos.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return result;
}

From source file:cn.zmdx.kaka.locker.widget.SlidingPaneLayout.java

private static boolean viewIsOpaque(View v) {
    if (ViewCompat.isOpaque(v))
        return true;

    // View#isOpaque didn't take all valid opaque scrollbar modes into
    // account/*  w w  w.  j  a va 2s. c o  m*/
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque
    // above and return false
    // here. On older devices, check the view's background drawable directly
    // as a fallback.
    if (Build.VERSION.SDK_INT >= 18)
        return false;

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}

From source file:cn.bingoogolapple.swipebacklayout.BGASwipeBackLayout.java

private static boolean viewIsOpaque(View v) {
    if (v.isOpaque()) {
        return true;
    }/*  w  ww .ja  va 2s  . c om*/

    // View#isOpaque didn't take all valid opaque scrollbar modes into account
    // before API 18 (JB-MR2). On newer devices rely solely on isOpaque above and return false
    // here. On older devices, check the view's background drawable directly as a fallback.
    if (Build.VERSION.SDK_INT >= 18) {
        return false;
    }

    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }
    return false;
}

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

private static boolean hasOpaqueBackground(View v) {
    final Drawable bg = v.getBackground();
    if (bg != null) {
        return bg.getOpacity() == PixelFormat.OPAQUE;
    }//from   ww w  .java 2s. c  om
    return false;
}

From source file:com.yk.notification.util.BitmapUtil.java

/**
 * DrawableBitmap/* w w w  .j  a va 2  s  . c  om*/
 * 
 * @param drawable
 *            Drawable
 * @return Bitmap
 */
public static Bitmap getBitmapFromDrawable(Drawable drawable) {
    int width = drawable.getIntrinsicWidth();
    int height = drawable.getIntrinsicHeight();
    Bitmap bitmap = Bitmap.createBitmap(width, height,
            drawable.getOpacity() != PixelFormat.OPAQUE ? Config.ARGB_8888 : Config.RGB_565);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, width, height);
    drawable.draw(canvas);
    return bitmap;

}

From source file:com.huewu.pla.lib.internal.PLAListView.java

/**
 * Sets the drawable that will be drawn between each item in the list. If
 * the drawable does not have an intrinsic height, you should also call
 * {@link #setDividerHeight(int)}/*from w  ww  .  j a v  a 2s . c  om*/
 * 
 * @param divider The drawable to use.
 */
public void setDivider(final Drawable divider) {
    if (divider != null) {
        mDividerHeight = divider.getIntrinsicHeight();
        mClipDivider = divider instanceof ColorDrawable;
    } else {
        mDividerHeight = 0;
        mClipDivider = false;
    }
    mDivider = divider;
    mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
    requestLayoutIfNecessary();
}

From source file:com.huewu.pla.lib.internal.PLA_ListView.java

/**
 * Sets the drawable that will be drawn between each item in the list. If
 * the drawable does not have an intrinsic height, you should also call
 * {@link #setDividerHeight(int)}/*from  w w  w.j  a  va2s.  c o m*/
 * 
 * @param divider
 *            The drawable to use.
 */
public void setDivider(Drawable divider) {
    if (divider != null) {
        mDividerHeight = divider.getIntrinsicHeight();
        mClipDivider = divider instanceof ColorDrawable;
    } else {
        mDividerHeight = 0;
        mClipDivider = false;
    }
    mDivider = divider;
    mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
    requestLayoutIfNecessary();
}