Example usage for android.graphics BitmapFactory BitmapFactory

List of usage examples for android.graphics BitmapFactory BitmapFactory

Introduction

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

Prototype

BitmapFactory

Source Link

Usage

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();//  w  ww  . jav a  2 s  .  c o m
    byte[] raw = obj.getRaw();

    if (raw == null) {
        Pair<JSONObject, byte[]> p = splitRaw(content);
        content = p.first;
        raw = p.second;
    }

    LinearLayout inner = new LinearLayout(context);
    inner.setLayoutParams(CommonLayouts.FULL_WIDTH);
    inner.setOrientation(LinearLayout.HORIZONTAL);
    frame.addView(inner);

    ImageView imageView = new ImageView(context);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    BitmapFactory bf = new BitmapFactory();
    imageView.setImageBitmap(bf.decodeByteArray(raw, 0, raw.length));
    inner.addView(imageView);

    ImageView iconView = new ImageView(context);
    iconView.setImageResource(R.drawable.play);
    iconView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    inner.addView(iconView);
}