Example usage for android.content.res TypedArray getIndex

List of usage examples for android.content.res TypedArray getIndex

Introduction

In this page you can find the example usage for android.content.res TypedArray getIndex.

Prototype

public int getIndex(int at) 

Source Link

Document

Returns an index in the array that has data.

Usage

From source file:com.googlecode.eyesfree.example.bargraph.BarGraphView.java

public BarGraphView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Load styled attributes.
    final int defStyleRes = (isInEditMode() ? 0 : R.style.BarGraph);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BarGraph, defStyle, defStyleRes);

    final int n = a.getIndexCount();
    for (int i = 0; i < n; i++) {
        final int attr = a.getIndex(i);

        switch (attr) {
        case R.styleable.BarGraph_barMargin:
            mBarMargin = a.getDimension(attr, mBarMargin);
            break;
        case R.styleable.BarGraph_barMinWidth:
            mBarMinHeight = a.getDimension(attr, mBarMinHeight);
            break;
        case R.styleable.BarGraph_barMinHeight:
            mBarMinWidth = a.getDimension(attr, mBarMinWidth);
            break;
        case R.styleable.BarGraph_title:
            setTitle(a.getText(attr));//from w w w  . j av  a  2s  .c  o  m
            break;
        case R.styleable.BarGraph_titleSize:
            mTitleSize = a.getDimension(attr, mTitleSize);
            break;
        case R.styleable.BarGraph_values:
            if (!isInEditMode()) {
                setData(context.getResources().getIntArray(a.getResourceId(attr, 0)));
            }
            break;
        }
    }

    a.recycle();

    if (isInEditMode()) {
        // Special considerations for edit mode.
        mBarGraphAccessHelper = null;
        setData(new int[] { 1, 1, 2, 3, 5, 8 });
        setSelection(3);
    } else {
        // Set up accessibility helper class.
        mBarGraphAccessHelper = new BarGraphAccessHelper(this);
        ViewCompat.setAccessibilityDelegate(this, mBarGraphAccessHelper);
    }
}

From source file:com.wit.and.dialog.EditDialog.java

/**
 *//*from   w w  w  .j a v  a 2 s.  c  om*/
@Override
protected void onStyleDialog(View dialogView, TypedArray parsedArray) {
    final Context context = getActivity();

    Log.d(TAG, "onStyleDialog() START");

    final int editDialogStyle = parsedArray.getResourceId(R.styleable.And_Theme_Dialog_editDialogStyle,
            R.style.And_Dialog_EditDialog);
    final TypedArray dialogArray = context.obtainStyledAttributes(editDialogStyle,
            R.styleable.And_Theme_Dialog_EditDialog);
    if (dialogArray != null) {
        final int n = dialogArray.getIndexCount();
        for (int i = 0; i < n; i++) {
            int attr = dialogArray.getIndex(i);
            /**
             * Obtain edit dialog sub-dialog style.
             */
            if (attr == R.styleable.And_Theme_Dialog_EditDialog_dialogStyle) {
                /**
                 * Let super to process edit dialog sub-dialog style.
                 */
                super.onStyleDialog(dialogView, dialogArray.getResourceId(attr, R.style.And_Dialog_Dialog));
            }
            // Set up edit dialog edit.
            else if (attr == R.styleable.And_Theme_Dialog_EditDialog_android_editTextStyle) {
                final int editStyle = dialogArray.getResourceId(attr, R.style.And_Dialog_EditText);
                EDIT_STYLER.performStyling(editStyle, mEdit);
            }
        }
        dialogArray.recycle();
    }

    Log.d(TAG, "onStyleDialog() set up edit style from options");

    // Set up edit text.
    if (mEditStyle > 0) {
        Log.d(TAG, "onStyleDialog() edit style(" + mEditStyle + ")");

        EDIT_STYLER.performStyling(mEditStyle, mEdit);
    }
    if (mHint != null) {
        mEdit.setHint(mHint);
    }

    /**
     * Set type face to text views.
     */
    Typeface typeface = obtainTypeface(editDialogStyle);
    if (typeface != null) {
        applyTypeface(typeface, mEdit);
    }

    Log.d(TAG, "onStyleDialog() FINISH");
}

From source file:org.xbmc.kore.ui.AbstractInfoFragment.java

/**
 * Call this when you are ready to provide the titleTextView, undertitle, details, descriptionExpandableTextView, etc. etc.
 */// w  w  w. j  a  v  a2 s .c o m
protected void updateView(DataHolder dataHolder) {
    titleTextView.setText(dataHolder.getTitle());
    underTitleTextView.setText(dataHolder.getUnderTitle());
    detailsRightTextView.setText(dataHolder.getDetails());

    if (!TextUtils.isEmpty(dataHolder.getDescription())) {
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme
                .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse });
        final int iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0),
                R.drawable.ic_expand_less_white_24dp);
        final int iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(1),
                R.drawable.ic_expand_more_white_24dp);
        styledAttributes.recycle();
        descriptionContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                descriptionExpandableTextView.toggle();
                expansionImage.setImageResource(
                        descriptionExpandableTextView.isExpanded() ? iconCollapseResId : iconExpandResId);
            }
        });
        descriptionExpandableTextView.setText(dataHolder.getDescription());
        if (expandDescription) {
            descriptionExpandableTextView.expand();
            expansionImage.setImageResource(iconExpandResId);
        }
        descriptionContainer.setVisibility(View.VISIBLE);
    } else {
        descriptionContainer.setVisibility(GONE);
    }

    // Images
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    Resources resources = getActivity().getResources();

    if (dataHolder.getPosterUrl() != null) {
        int posterWidth;
        int posterHeight;
        if (dataHolder.getSquarePoster()) {
            posterWidth = resources.getDimensionPixelOffset(R.dimen.detail_poster_width_square);
            posterHeight = resources.getDimensionPixelOffset(R.dimen.detail_poster_height_square);
        } else {
            posterWidth = resources.getDimensionPixelOffset(R.dimen.detail_poster_width_nonsquare);
            posterHeight = resources.getDimensionPixelOffset(R.dimen.detail_poster_height_nonsquare);
        }

        UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, dataHolder.getPosterUrl(),
                dataHolder.getTitle(), posterImageView, posterWidth, posterHeight);
    } else {
        posterImageView.setVisibility(GONE);
        int padding = getActivity().getResources().getDimensionPixelSize(R.dimen.default_padding);
        titleTextView.setPadding(padding, padding, 0, 0);
        underTitleTextView.setPadding(padding, padding, 0, 0);
    }

    int artHeight = resources.getDimensionPixelOffset(R.dimen.detail_art_height);
    int artWidth = displayMetrics.widthPixels;

    UIUtils.loadImageIntoImageview(hostManager,
            TextUtils.isEmpty(dataHolder.getFanArtUrl()) ? dataHolder.getPosterUrl()
                    : dataHolder.getFanArtUrl(),
            artImageView, artWidth, artHeight);

    if (dataHolder.getRating() > 0) {
        ratingTextView.setText(String.format(Locale.getDefault(), "%01.01f", dataHolder.getRating()));
        if (dataHolder.getMaxRating() > 0) {
            maxRatingTextView.setText(
                    String.format(getString(R.string.max_rating), String.valueOf(dataHolder.getMaxRating())));
        }
        if (dataHolder.getVotes() > 0) {
            ratingVotesTextView
                    .setText(String.format(getString(R.string.votes), String.valueOf(dataHolder.getVotes())));
        }
        ratingContainer.setVisibility(View.VISIBLE);
    } else if (TextUtils.isEmpty(dataHolder.getDetails())) {
        mediaDetailsContainer.setVisibility(View.GONE);
    }
}

From source file:com.albedinsky.android.setting.SettingSelectionDialogPreference.java

/**
 *//*from   w  ww .jav  a  2 s  . co  m*/
@Override
@SuppressWarnings("ResourceType")
protected void onConfigureDialogOptions(@NonNull SelectionDialog.SelectionOptions options,
        @NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr,
        @StyleRes int defStyleRes) {
    super.onConfigureDialogOptions(options, context, attrs, defStyleAttr, defStyleRes);
    final TypedArray typedArray = context.obtainStyledAttributes(attrs,
            R.styleable.Ui_Settings_SelectionDialogPreference, defStyleAttr, defStyleRes);
    for (int i = 0; i < typedArray.getIndexCount(); i++) {
        final int index = typedArray.getIndex(i);
        if (index == R.styleable.Ui_Settings_SelectionDialogPreference_dialogSelectionMode) {
            options.selectionMode(typedArray.getInt(index, options.selectionMode()));
        } else if (index == R.styleable.Ui_Settings_SelectionDialogPreference_dialogEmptySelectionAllowed) {
            options.emptySelectionAllowed(typedArray.getBoolean(index, options.shouldAllowEmptySelection()));
        }
    }
    typedArray.recycle();
}

From source file:org.xbmc.kore.ui.sections.audio.AlbumDetailsFragment.java

/**
 * Display the album details/*from   www . java  2  s  .  c  o  m*/
 *
 * @param cursor Cursor with the data
 */
private void displayAlbumDetails(Cursor cursor) {
    final Resources resources = getActivity().getResources();

    cursor.moveToFirst();
    albumTitle = cursor.getString(AlbumDetailsQuery.TITLE);
    albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST);
    mediaTitle.setText(albumTitle);
    mediaUndertitle.setText(albumDisplayArtist);

    setMediaYear(cursor.getString(AlbumDetailsQuery.GENRE), cursor.getInt(AlbumDetailsQuery.YEAR));

    double rating = cursor.getDouble(AlbumDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        setMediaRating(rating);
    } else {
        mediaRating.setVisibility(View.GONE);
        mediaMaxRating.setVisibility(View.GONE);
    }

    String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION);
    if (!TextUtils.isEmpty(description)) {
        mediaDescription.setVisibility(View.VISIBLE);
        mediaDescription.setText(description);

        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme
                .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse });
        final int iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0),
                R.drawable.ic_expand_less_white_24dp);
        final int iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(1),
                R.drawable.ic_expand_more_white_24dp);
        styledAttributes.recycle();
        mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mediaDescription.toggle();
                mediaShowAll
                        .setImageResource(mediaDescription.isExpanded() ? iconCollapseResId : iconExpandResId);
            }
        });
    } else {
        mediaDescriptionContainer.setVisibility(View.GONE);
    }

    // Images
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    String fanart = cursor.getString(AlbumDetailsQuery.FANART),
            poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL);

    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
            artWidth = displayMetrics.widthPixels;
    int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, albumTitle, mediaPoster,
            posterWidth, posterHeight);
    UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth,
            artHeight);
}

From source file:org.xbmc.kore.ui.RemoteFragment.java

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

    if (hostManager.getHostInfo().getUseEventServer() && (eventServerConnection != null)) {
        // Setup d-pad to use EventServer
        setupEventServerButton(leftButton, ButtonCodes.REMOTE_LEFT);
        setupEventServerButton(rightButton, ButtonCodes.REMOTE_RIGHT);
        setupEventServerButton(upButton, ButtonCodes.REMOTE_UP);
        setupEventServerButton(downButton, ButtonCodes.REMOTE_DOWN);
        //setupEventServerButton(selectButton, ButtonCodes.REMOTE_SELECT);
    } else {/*from   ww  w. j ava 2 s.co m*/
        // Otherwise, use json-rpc
        setupRepeatButton(leftButton, new Input.Left());
        setupRepeatButton(rightButton, new Input.Right());
        setupRepeatButton(upButton, new Input.Up());
        setupRepeatButton(downButton, new Input.Down());
    }
    setupDefaultButton(selectButton, new Input.Select(), null);

    // Other buttons
    setupDefaultButton(backButton, new Input.Back(), null);
    setupDefaultButton(infoButton, new Input.ExecuteAction(Input.ExecuteAction.INFO),
            new Input.ExecuteAction(Input.ExecuteAction.CODECINFO));
    setupDefaultButton(osdButton, new Input.ExecuteAction(Input.ExecuteAction.OSD), null);
    setupDefaultButton(contextButton, new Input.ExecuteAction(Input.ExecuteAction.CONTEXTMENU), null);

    adjustRemoteButtons();

    TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes(
            new int[] { R.attr.iconFastForward, R.attr.iconRewind, R.attr.iconNext, R.attr.iconPrevious });
    fastForwardIcon = styledAttributes.getResourceId(styledAttributes.getIndex(0),
            R.drawable.ic_fast_forward_white_24dp);
    rewindIcon = styledAttributes.getResourceId(styledAttributes.getIndex(1),
            R.drawable.ic_fast_rewind_white_24dp);
    skipNextIcon = styledAttributes.getResourceId(styledAttributes.getIndex(2),
            R.drawable.ic_skip_next_white_24dp);
    skipPreviousIcon = styledAttributes.getResourceId(styledAttributes.getIndex(3),
            R.drawable.ic_skip_previous_white_24dp);
    styledAttributes.recycle();

    //        // Pad main content view to account for bottom system bar
    //        UIUtils.setPaddingForSystemBars(getActivity(), root, false, false, true);

    // No clipping
    //        root.setClipToPadding(false);

    return root;
}

From source file:org.xbmc.kore.ui.sections.video.TVShowDetailsFragment.java

/**
 * Display the tv show details//from   w  w w  .ja  va2s  . c  o  m
 *
 * @param cursor Cursor with the data
 */
private void displayTVShowDetails(Cursor cursor) {
    LogUtils.LOGD(TAG, "displayTVShowDetails");
    cursor.moveToFirst();
    tvshowTitle = cursor.getString(TVShowDetailsQuery.TITLE);
    mediaTitle.setText(tvshowTitle);
    int numEpisodes = cursor.getInt(TVShowDetailsQuery.EPISODE),
            watchedEpisodes = cursor.getInt(TVShowDetailsQuery.WATCHEDEPISODES);
    setMediaUndertitle(numEpisodes, watchedEpisodes);

    setMediaPremiered(cursor.getString(TVShowDetailsQuery.PREMIERED),
            cursor.getString(TVShowDetailsQuery.STUDIO));

    mediaGenres.setText(cursor.getString(TVShowDetailsQuery.GENRES));

    setMediaRating(cursor.getDouble(TVShowDetailsQuery.RATING));

    mediaDescription.setText(cursor.getString(TVShowDetailsQuery.PLOT));

    Resources resources = getActivity().getResources();
    TypedArray styledAttributes = getActivity().getTheme()
            .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse });
    final int iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0),
            R.drawable.ic_expand_less_white_24dp);
    final int iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(1),
            R.drawable.ic_expand_more_white_24dp);
    styledAttributes.recycle();
    mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mediaDescription.toggle();
            mediaShowAll.setImageResource(mediaDescription.isExpanded() ? iconCollapseResId : iconExpandResId);
        }
    });

    //        // IMDB button
    //        imdbButton.setTag(cursor.getString(TVShowDetailsQuery.IMDBNUMBER));

    // Images
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_poster_height);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), getHostManager(),
            cursor.getString(TVShowDetailsQuery.THUMBNAIL), tvshowTitle, mediaPoster, posterWidth,
            posterHeight);
    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height);
    UIUtils.loadImageIntoImageview(getHostManager(), cursor.getString(TVShowDetailsQuery.FANART), mediaArt,
            displayMetrics.widthPixels, artHeight);
}

From source file:org.xbmc.kore.ui.AlbumDetailsFragment.java

/**
 * Display the album details/*from  www .j  a  va 2 s.  c om*/
 *
 * @param cursor Cursor with the data
 */
private void displayAlbumDetails(Cursor cursor) {
    final Resources resources = getActivity().getResources();

    cursor.moveToFirst();
    albumTitle = cursor.getString(AlbumDetailsQuery.TITLE);
    albumDisplayArtist = cursor.getString(AlbumDetailsQuery.DISPLAYARTIST);
    mediaTitle.setText(albumTitle);
    mediaUndertitle.setText(albumDisplayArtist);

    setMediaYear(cursor.getString(AlbumDetailsQuery.GENRE), cursor.getInt(AlbumDetailsQuery.YEAR));

    double rating = cursor.getDouble(AlbumDetailsQuery.RATING);
    if (rating > 0) {
        mediaRating.setVisibility(View.VISIBLE);
        mediaMaxRating.setVisibility(View.VISIBLE);
        setMediaRating(rating);
    } else {
        mediaRating.setVisibility(View.GONE);
        mediaMaxRating.setVisibility(View.GONE);
    }

    String description = cursor.getString(AlbumDetailsQuery.DESCRIPTION);
    if (!TextUtils.isEmpty(description)) {
        mediaDescription.setVisibility(View.VISIBLE);
        mediaDescription.setText(description);
        final int maxLines = resources.getInteger(R.integer.description_max_lines);
        Resources.Theme theme = getActivity().getTheme();
        TypedArray styledAttributes = theme
                .obtainStyledAttributes(new int[] { R.attr.iconExpand, R.attr.iconCollapse });
        final int iconCollapseResId = styledAttributes.getResourceId(styledAttributes.getIndex(0),
                R.drawable.ic_expand_less_white_24dp);
        final int iconExpandResId = styledAttributes.getResourceId(styledAttributes.getIndex(1),
                R.drawable.ic_expand_more_white_24dp);
        styledAttributes.recycle();

        mediaDescriptionContainer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!isDescriptionExpanded) {
                    mediaDescription.setMaxLines(Integer.MAX_VALUE);
                    mediaShowAll.setImageResource(iconExpandResId);
                } else {
                    mediaDescription.setMaxLines(maxLines);
                    mediaShowAll.setImageResource(iconCollapseResId);
                }
                isDescriptionExpanded = !isDescriptionExpanded;
            }
        });
    } else {
        mediaDescriptionContainer.setVisibility(View.GONE);
    }

    // Images
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);

    String fanart = cursor.getString(AlbumDetailsQuery.FANART),
            poster = cursor.getString(AlbumDetailsQuery.THUMBNAIL);

    int artHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_art_height),
            artWidth = displayMetrics.widthPixels;
    int posterWidth = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.albumdetail_poster_heigth);
    UIUtils.loadImageWithCharacterAvatar(getActivity(), hostManager, poster, albumTitle, mediaPoster,
            posterWidth, posterHeight);
    UIUtils.loadImageIntoImageview(hostManager, TextUtils.isEmpty(fanart) ? poster : fanart, mediaArt, artWidth,
            artHeight);
}

From source file:com.edgar.banner.BannerPagerView.java

private void init(AttributeSet attrs, int defStyle) {
    Context context = getContext();
    Resources resource = context.getResources();
    LayoutInflater.from(getContext()).inflate(R.layout.banner_layout, this, true);
    mViewPage = (LoopViewPager) findViewById(R.id.carouse_viewpager);
    setBannerScroller(new BannerScroller(getContext()));
    mViewPage.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mViewPage.setOnPageChangeListener(mCarousePageListener);
    mBannerPageAdapter = new DefaultBannerPageViewAdapter();
    mIndicatorParams.gravity = Gravity.BOTTOM;
    mPointPadding = resource.getDimensionPixelOffset(R.dimen.point_margin);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BannerPagerView, defStyle, 0);
    int N = a.getIndexCount();
    for (int i = 0; i < N; i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.BannerPagerView_bannerAnimation) {
            int transformerType = a.getInt(attr, 0);
            setBannerPageTransformer(true, TransformerType.convert(transformerType));
        } else if (attr == R.styleable.BannerPagerView_enableAutoPlayer) {
            setEnableAutoPlay(a.getBoolean(attr, false));
        } else if (attr == R.styleable.BannerPagerView_indicatorStyle) {
            mIndicatorStyle = a.getInt(attr, IndicatorStyle.CIRCLE_INDICATOR);
        } else if (attr == R.styleable.BannerPagerView_indicatorLayout) {
            int resId = a.getResourceId(attr, 0);
            if (resId != 0) {
                View indicatorView = LayoutInflater.from(context).inflate(resId, this, false);
                if (!(indicatorView instanceof BannerIndicator)) {
                    throw new IllegalArgumentException("Your indicator must implements BannerIndicator.");
                }/*from w  ww .j  a  v  a  2 s.  c o m*/
                mIndicatorView = indicatorView;
                mBannerIndicator = (BannerIndicator) indicatorView;
                addView(mIndicatorView);
            }
        } else if (attr == R.styleable.BannerPagerView_unSelectDrawable) {
            mUnSelectedDrawable = a.getDrawable(attr);
        } else if (attr == R.styleable.BannerPagerView_selectedDrawable) {
            mSelectedDrawable = a.getDrawable(attr);
        } else if (attr == R.styleable.BannerPagerView_indicatorGravity) {
            mIndicatorGravity = a.getInt(attr, Gravity.CENTER);
        } else if (attr == R.styleable.BannerPagerView_pointPadding) {
            mPointPadding = a.getDimensionPixelOffset(attr, mPointPadding);
        } else if (attr == R.styleable.BannerPagerView_indicatorBackground) {
            mIndicatorBackground = a.getDrawable(attr);
        }
    }

    if (mUnSelectedDrawable == null) {
        mUnSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_normal_background);
    }
    if (mSelectedDrawable == null) {
        mSelectedDrawable = ContextCompat.getDrawable(context, R.drawable.def_circle_selected_background);
    }
    if (mIndicatorBackground == null) {
        mIndicatorBackground = new ColorDrawable(resource.getColor(R.color.indicator_background));
    }
    if (mBannerIndicator == null) {
        setIndicatorStyle(mIndicatorStyle);
    }

    a.recycle();
}

From source file:org.xbmc.kore.ui.RemoteFragment.java

@TargetApi(21)
private void adjustRemoteButtons() {
    Resources.Theme theme = getActivity().getTheme();
    TypedArray styledAttributes = theme.obtainStyledAttributes(
            new int[] { R.attr.remoteButtonColorFilter, R.attr.contentBackgroundColor });
    //                R.attr.remoteBackgroundColorFilter});
    Resources resources = getResources();
    int remoteButtonsColor = styledAttributes.getColor(styledAttributes.getIndex(0),
            resources.getColor(R.color.white)),
            remoteBackgroundColor = styledAttributes.getColor(styledAttributes.getIndex(1),
                    resources.getColor(R.color.dark_content_background_dim_70pct));
    styledAttributes.recycle();/*from  w ww  .  j  a  v a  2  s .co m*/

    leftButton.setColorFilter(remoteButtonsColor);
    rightButton.setColorFilter(remoteButtonsColor);
    upButton.setColorFilter(remoteButtonsColor);
    downButton.setColorFilter(remoteButtonsColor);

    selectButton.setColorFilter(remoteButtonsColor);
    backButton.setColorFilter(remoteButtonsColor);
    infoButton.setColorFilter(remoteButtonsColor);
    osdButton.setColorFilter(remoteButtonsColor);
    contextButton.setColorFilter(remoteButtonsColor);

    // On ICS the remote background isn't shown as the tinting isn't supported
    //int backgroundResourceId = R.drawable.remote_background_square_black_alpha;
    int backgroundResourceId = R.drawable.remote_background_square_black;
    if (Utils.isLollipopOrLater()) {
        remotePanel.setBackgroundTintList(ColorStateList.valueOf(remoteBackgroundColor));
        remotePanel.setBackgroundResource(backgroundResourceId);
    } else if (Utils.isJellybeanOrLater()) {
        BitmapDrawable background = new BitmapDrawable(getResources(),
                BitmapFactory.decodeResource(getResources(), backgroundResourceId));
        background.setColorFilter(new PorterDuffColorFilter(remoteBackgroundColor, PorterDuff.Mode.SRC_IN));
        remotePanel.setBackground(background);
    }
}