Example usage for android.view ViewGroup getResources

List of usage examples for android.view ViewGroup getResources

Introduction

In this page you can find the example usage for android.view ViewGroup getResources.

Prototype

public Resources getResources() 

Source Link

Document

Returns the resources associated with this view.

Usage

From source file:com.felkertech.n.tv.presenters.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    mContext = parent.getContext();/*  www.  ja  v  a 2 s  . c o  m*/
    sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
    sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);

    ImageCardView cardView = new ImageCardView(mContext);

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);
    return new ViewHolder(cardView);
}

From source file:com.fastbootmobile.encore.app.tv.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    sDefaultBackgroundColor = parent.getResources().getColor(R.color.primary_dark);
    sSelectedBackgroundColor = parent.getResources().getColor(R.color.primary);

    mContext = parent.getContext();/*  w  w  w .ja  v  a  2s  . c  om*/
    mDefaultCardImage = mContext.getResources().getDrawable(R.drawable.album_placeholder);

    ImageCardView cardView = new ImageCardView(mContext) {
        @Override
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);

    return new ViewHolder(cardView);
}

From source file:com.example.cassi.hal.adapter.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    Log.d(TAG, "onCreateViewHolder");

    sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
    sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
    mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie);

    ImageCardView cardView = new ImageCardView(parent.getContext()) {
        @Override/*www .  ja v  a 2 s . c om*/
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);
    return new ViewHolder(cardView);
}

From source file:com.aengbee.android.leanback.presenter.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    mDefaultBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.default_background);
    mSelectedBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.selected_background);
    mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie, null);

    ImageCardView cardView = new ImageCardView(parent.getContext()) {
        @Override/*from   www . j ava  2 s  .  co m*/
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);
    return new ViewHolder(cardView);
}

From source file:net.reichholf.dreamdroid.tv.presenter.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    mDefaultBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.primary_dreamdroid);
    mSelectedBackgroundColor = ContextCompat.getColor(parent.getContext(), R.color.primary_material_dark);
    mDefaultCardImage = parent.getResources().getDrawable(R.drawable.dreamdroid_logo_simple, null);

    ImageCardView cardView = new ImageCardView(parent.getContext()) {
        @Override/*from   w ww  . jav  a2  s .  co  m*/
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);
    return new ViewHolder(cardView);
}

From source file:com.ibm.techathon.elven.smartpool.cards.SuggestedCard.java

@Override
public void setupInnerViewElements(ViewGroup parent, View viewImage) {
    if (viewImage != null) {

        if (parent != null && parent.getResources() != null) {
            DisplayMetrics metrics = parent.getResources().getDisplayMetrics();

            int base = 100;

            if (metrics != null) {
                viewImage.getLayoutParams().width = (int) (base * metrics.density);
                viewImage.getLayoutParams().height = (int) (base * metrics.density);
            } else {
                viewImage.getLayoutParams().width = 200;
                viewImage.getLayoutParams().height = 200;
            }//from w  w  w  .j  a v  a  2  s. c o m
        }
    }
}

From source file:org.sufficientlysecure.keychain.ui.adapter.KeyListSecretAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // let the adapter handle setting up the row views
    View v = super.getView(position, convertView, parent);

    /**/* w w  w .j  a  va 2  s. com*/
     * Change color for multi-selection
     */
    // default color
    v.setBackgroundColor(Color.TRANSPARENT);
    if (mSelection.get(position) != null) {
        // this is a selected position, change color!
        v.setBackgroundColor(parent.getResources().getColor(R.color.emphasis));
    }
    return v;
}

From source file:org.sufficientlysecure.keychain.ui.adapter.KeyListPublicAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // let the adapter handle setting up the row views
    View v = super.getView(position, convertView, parent);

    /**//  w w  w. j  a  v  a 2 s  . com
     * Change color for multi-selection
     */
    // default color
    v.setBackgroundColor(Color.TRANSPARENT);
    if (mSelection.get(position) != null && mSelection.get(position).booleanValue()) {
        // this is a selected position, change color!
        v.setBackgroundColor(parent.getResources().getColor(R.color.emphasis));
    }
    return v;
}

From source file:de.gebatzens.sia.SchoolListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView == null ? c.getLayoutInflater().inflate(R.layout.school_item, parent, false)
            : convertView;//from  w ww . j a va  2 s .com

    School school = list.get(position);

    ((TextView) v.findViewById(R.id.school_name)).setText(school.name);

    ((TextView) v.findViewById(R.id.school_city)).setText(school.city);

    ((GradientDrawable) v.findViewById(R.id.school_firstletter_text).getBackground())
            .setColor(school.getColor());

    ((TextView) v.findViewById(R.id.school_firstletter_text)).setText("" + school.name.charAt(0));

    ((TextView) v.findViewById(R.id.school_user_number))
            .setText(school.users + " " + parent.getResources().getString(R.string.user));

    return v;
}

From source file:android.support.v17.leanback.app.ErrorSupportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.lb_error_fragment, container, false);

    mErrorFrame = (ViewGroup) root.findViewById(R.id.error_frame);
    updateBackground();/*from   w  w  w.j a v a2s.co  m*/

    installTitleView(inflater, mErrorFrame, savedInstanceState);

    mImageView = (ImageView) root.findViewById(R.id.image);
    updateImageDrawable();

    mTextView = (TextView) root.findViewById(R.id.message);
    updateMessage();

    mButton = (Button) root.findViewById(R.id.button);
    updateButton();

    FontMetricsInt metrics = getFontMetricsInt(mTextView);
    int underImageBaselineMargin = container.getResources()
            .getDimensionPixelSize(R.dimen.lb_error_under_image_baseline_margin);
    setTopMargin(mTextView, underImageBaselineMargin + metrics.ascent);

    int underMessageBaselineMargin = container.getResources()
            .getDimensionPixelSize(R.dimen.lb_error_under_message_baseline_margin);
    setTopMargin(mButton, underMessageBaselineMargin - metrics.descent);

    return root;
}