Example usage for android.widget RelativeLayout getResources

List of usage examples for android.widget RelativeLayout getResources

Introduction

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

Prototype

public Resources getResources() 

Source Link

Document

Returns the resources associated with this view.

Usage

From source file:com.ichi2.anki.widgets.DeckAdapter.java

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    // Update views for this node
    Sched.DeckDueTreeNode node = mDeckList.get(position);
    // Set the expander icon and padding according to whether or not there are any subdecks
    RelativeLayout deckLayout = holder.deckLayout;
    int rightPadding = (int) deckLayout.getResources().getDimension(R.dimen.deck_picker_right_padding);
    if (mHasSubdecks) {
        int smallPadding = (int) deckLayout.getResources().getDimension(R.dimen.deck_picker_left_padding_small);
        deckLayout.setPadding(smallPadding, 0, rightPadding, 0);
        holder.deckExpander.setVisibility(View.VISIBLE);
        // Create the correct expander for this deck
        setDeckExpander(holder.deckExpander, holder.indentView, node);
    } else {//from   www .j a v  a  2  s.com
        holder.deckExpander.setVisibility(View.GONE);
        int normalPadding = (int) deckLayout.getResources().getDimension(R.dimen.deck_picker_left_padding);
        deckLayout.setPadding(normalPadding, 0, rightPadding, 0);
    }

    if (node.children.size() > 0) {
        holder.deckExpander.setTag(node.did);
        holder.deckExpander.setOnClickListener(mDeckExpanderClickListener);
    } else {
        holder.deckExpander.setOnClickListener(null);
    }
    holder.deckLayout.setBackgroundResource(mRowCurrentDrawable);
    // Set background colour. The current deck has its own color
    if (node.did == mCol.getDecks().current().optLong("id")) {
        holder.deckLayout.setBackgroundResource(mRowCurrentDrawable);
    } else {
        CompatHelper.getCompat().setSelectableBackground(holder.deckLayout);
    }
    // Set deck name and colour. Filtered decks have their own colour
    holder.deckName.setText(node.names[0]);
    if (mCol.getDecks().isDyn(node.did)) {
        holder.deckName.setTextColor(mDeckNameDynColor);
    } else {
        holder.deckName.setTextColor(mDeckNameDefaultColor);
    }

    // Set the card counts and their colors
    holder.deckNew.setText(String.valueOf(node.newCount));
    holder.deckNew.setTextColor((node.newCount == 0) ? mZeroCountColor : mNewCountColor);
    holder.deckLearn.setText(String.valueOf(node.lrnCount));
    holder.deckLearn.setTextColor((node.lrnCount == 0) ? mZeroCountColor : mLearnCountColor);
    holder.deckRev.setText(String.valueOf(node.revCount));
    holder.deckRev.setTextColor((node.revCount == 0) ? mZeroCountColor : mReviewCountColor);

    // Store deck ID in layout's tag for easy retrieval in our click listeners
    holder.deckLayout.setTag(node.did);
    holder.countsLayout.setTag(node.did);

    // Set click listeners
    holder.deckLayout.setOnClickListener(mDeckClickListener);
    holder.deckLayout.setOnLongClickListener(mDeckLongClickListener);
    holder.countsLayout.setOnClickListener(mCountsClickListener);
}