Example usage for android.widget RelativeLayout getBackground

List of usage examples for android.widget RelativeLayout getBackground

Introduction

In this page you can find the example usage for android.widget RelativeLayout getBackground.

Prototype

public Drawable getBackground() 

Source Link

Document

Gets the background drawable

Usage

From source file:org.ounl.lifelonglearninghub.mediaplayer.cast.refplayer.NFCVideoBrowserActivity.java

@Override
public void onNewIntent(Intent intent) {
    setIntent(intent);// w  w w . j a  va  2 s  . c  o  m
    String sCommand = resolveIntent(intent);

    if (sCommand.contains(IParsedNdefCommand.COMMAND_FORWARD)) {
        VideoBrowserListFragment vblf = (VideoBrowserListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.browse);
        lvVideoBrowserList = vblf.getListView();
        int iNumRelativeLayouts = lvVideoBrowserList.getChildCount();
        int iSelectedItem = iNumRelativeLayouts - 1;
        for (int i = 0; i < iNumRelativeLayouts; i++) {
            RelativeLayout rl = (RelativeLayout) lvVideoBrowserList.getChildAt(i);
            int color = Color.TRANSPARENT;
            Drawable background = rl.getBackground();
            if (background instanceof ColorDrawable) {
                color = ((ColorDrawable) background).getColor();
                if (Color.parseColor(CastApplication.COLOR_ORANGE) == color) {
                    iSelectedItem = i;
                    Log.d(CLASSNAME, "Selected item [" + i + "]");
                }
            }
        }

        lvVideoBrowserList.getChildAt(iSelectedItem).setBackgroundColor(Color.WHITE);
        lvVideoBrowserList.getChildAt((iSelectedItem + 1) % iNumRelativeLayouts)
                .setBackgroundColor(Color.parseColor(CastApplication.COLOR_ORANGE));

    } else if (sCommand.contains(IParsedNdefCommand.COMMAND_CAST)) {
        VideoBrowserListFragment vblf = (VideoBrowserListFragment) getSupportFragmentManager()
                .findFragmentById(R.id.browse);
        lvVideoBrowserList = vblf.getListView();
        int iNumRelativeLayouts = lvVideoBrowserList.getChildCount();
        int iSelectedItem = iNumRelativeLayouts - 1;
        for (int i = 0; i < iNumRelativeLayouts; i++) {
            RelativeLayout rl = (RelativeLayout) lvVideoBrowserList.getChildAt(i);
            int color = Color.TRANSPARENT;
            Drawable background = rl.getBackground();
            if (background instanceof ColorDrawable) {
                color = ((ColorDrawable) background).getColor();
                if (Color.parseColor(CastApplication.COLOR_ORANGE) == color) {
                    iSelectedItem = i;
                    Log.d(CLASSNAME, "Selected item [" + i + "]");

                }
            }
        }
        vblf.onListItemClick(lvVideoBrowserList, (RelativeLayout) lvVideoBrowserList.getChildAt(iSelectedItem),
                iSelectedItem, iSelectedItem);

    }

}

From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java

/**
 * Pulls the bitmap image of the body part out of its RelativeLayout, colors it appropriatly,
 * and then tells the zoomLayout where it needs to zoom to. Also swaps the FRONT/BACK buttons
 * for the ADD/DELETE buttons./*from  w w w  .ja v  a 2  s .  c  o m*/
 *
 * @param image the body part the touch occured in.
 */
private void zoomOnImage(RelativeLayout image) {

    Bitmap bitm = ((BitmapDrawable) image.getBackground()).getBitmap();

    Bitmap temp = bitm.copy(bitm.getConfig(), true);
    int[] pixels = new int[temp.getHeight() * temp.getWidth()];

    temp.getPixels(pixels, 0, temp.getWidth(), 0, 0, temp.getWidth(), temp.getHeight());

    for (int i = 0; i < temp.getHeight() * temp.getWidth(); i++) {

        if (pixels[i] != 0) {

            int r, g, b;

            if (!blue) {
                r = Color.red(pixels[i]) + 100;
                if (r > 255) {
                    r = 255;
                }
                g = Color.green(pixels[i]) - 50;
                b = Color.blue(pixels[i]) - 50;
            } else {
                r = Color.red(pixels[i]) - 30;
                g = Color.green(pixels[i]) + 15;
                b = Color.blue(pixels[i]) + 100;
                if (b > 255) {
                    b = 255;
                }

            }
            pixels[i] = Color.argb(Color.alpha(pixels[i]), r, g, b);
        }
    }

    temp.setPixels(pixels, 0, temp.getWidth(), 0, 0, temp.getWidth(), temp.getHeight());
    image.setBackground(new BitmapDrawable(getResources(), temp));

    Rect rect = new Rect();
    image.getGlobalVisibleRect(rect);

    zoomLayout.zoomToRect(rect, 0, getYOffset());
    current = image;
    zoomed = true;
    swapButtons();

    placePointer(rect.centerX(), rect.centerY());

}