Example usage for android.graphics PixelFormat OPAQUE

List of usage examples for android.graphics PixelFormat OPAQUE

Introduction

In this page you can find the example usage for android.graphics PixelFormat OPAQUE.

Prototype

int OPAQUE

To view the source code for android.graphics PixelFormat OPAQUE.

Click Source Link

Document

System chooses an opaque format (no alpha bits required)

Usage

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);//  ww w  . ja va 2 s . com
    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.bingoogolapple.swipebacklayout.BGASwipeBackLayout.java

private static boolean viewIsOpaque(View v) {
    if (v.isOpaque()) {
        return true;
    }//from  ww  w  .ja v a  2  s .co m

    // 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:lollipop.iconics.IconicsDrawable.java

@Override
public int getOpacity() {
    return PixelFormat.OPAQUE;
}

From source file:com.mikepenz.iconics.IconicsDrawable.java

@Override
public int getOpacity() {
    if (mTintFilter != null || mIconPaint.getColorFilter() != null) {
        return PixelFormat.TRANSLUCENT;
    }//from w w  w  .ja v a  2s. c om
    switch (getAlpha()) {
    case 255:
        return PixelFormat.OPAQUE;
    case 0:
        return PixelFormat.TRANSPARENT;
    }
    return PixelFormat.TRANSLUCENT;
}

From source file:com.sonymobile.android.media.testmediaplayer.MainActivity.java

public void reset() {
    mSeekBarUpdater.deactivate();//from   w w w  .j  a v a 2 s .  c om
    mTimeTracker.stopUpdating();
    mMediaPlayer.reset();
    mHolder.setFormat(PixelFormat.TRANSPARENT);
    mHolder.setFormat(PixelFormat.OPAQUE);
    mMediaPlayer.setScreenOnWhilePlaying(true);
    mMediaPlayer.setDisplay(mHolder);
    mBottomControls.setVisibility(View.INVISIBLE);
    mSeekbar.setVisibility(View.GONE);
    mTimeLayout.setVisibility(View.GONE);
    mDecorView.setOnSystemUiVisibilityChangeListener(this);
    mMediaPlayer.setOnCompletionListener(this);
    mMediaPlayer.setOnPreparedListener(this);
    mMediaPlayer.setOnInfoListener(this);
    mMediaPlayer.setOnSeekCompleteListener(this);
    mMediaPlayer.setOnSubtitleDataListener(this);
    mSeekbar.setOnSeekBarChangeListener(new OwnOnSeekBarChangeListener(mMediaPlayer));
    mSeekBarUpdater = new SeekbarUpdater(mSeekbar, mMediaPlayer);
    mTimeTracker.setMediaPlayer(mMediaPlayer);
    mSubtitleRenderer.stopRendering();
    RelativeLayout browsingL = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout);
    RelativeLayout debugLayout = (RelativeLayout) findViewById(R.id.activity_main_debug_view);
    LinearLayout debugLinearLayout = (LinearLayout) debugLayout.findViewById(R.id.activity_main_debug_linear);
    mFileBrowser = new MediaBrowser(this,
            (ExpandableListView) browsingL.findViewById(R.id.file_browsing_exp_list_view),
            (ListView) browsingL.findViewById(R.id.file_browsing_listview), mMediaPlayer, (MainActivity) this,
            mDrawerLayout, debugLinearLayout);
    mAudioPos = 0;
    mSubPos = 0;
    mMediaPlayer.setOnOutputControlListener(this);
}

From source file:android.car.ui.provider.CarDrawerLayout.java

private static boolean hasOpaqueBackground(View v) {
    final Drawable bg = v.getBackground();
    return bg != null && bg.getOpacity() == PixelFormat.OPAQUE;
}

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  w w. j a va  2  s.  c o m
 * 
 * @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: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;
    }//w  w w .  j  a v  a 2s. co  m
    return false;
}

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)}/* w  ww . j a  v a2s  .c  om*/
 * 
 * @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();
}

From source file:org.bangbang.support.v4.widget.HListView.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)}
     *//  ww w  .j  a  v  a2s . co m
     * @param divider The drawable to use.
     */
    public void setDivider(Drawable divider) {
        if (divider != null) {
            mDividerWidth = divider.getIntrinsicHeight();
            mClipDivider = divider instanceof ColorDrawable;
        } else {
            mDividerWidth = 0;
            mClipDivider = false;
        }
        mDivider = divider;
        mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
        requestLayoutIfNecessary();
    }