Example usage for android.support.v4.content.res ResourcesCompat getDrawable

List of usage examples for android.support.v4.content.res ResourcesCompat getDrawable

Introduction

In this page you can find the example usage for android.support.v4.content.res ResourcesCompat getDrawable.

Prototype

public static Drawable getDrawable(Resources resources, int i, Theme theme) throws NotFoundException 

Source Link

Usage

From source file:gsoc.google.com.byop.utils.PW.BeaconConfigFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_beacon_config, container, false);

    mEditCard = (LinearLayout) view.findViewById(R.id.edit_card);

    // Get handles to Status and Address views
    mEditCardAddress = (TextView) view.findViewById(R.id.edit_card_address);

    // Setup the URL Edit Text handler
    mEditCardUrl = (EditText) view.findViewById(R.id.edit_card_url);
    mEditCardUrl.setOnEditorActionListener(this);

    // Setup the animation
    mScanningStatus = (TextView) view.findViewById(R.id.textView_scanningStatus);
    mScanningAnimation = (AnimationDrawable) ResourcesCompat.getDrawable(getResources(),
            R.drawable.scanning_animation, null);
    mScanningStatus.setCompoundDrawablesWithIntrinsicBounds(null, mScanningAnimation, null, null);

    Button button = (Button) view.findViewById(R.id.edit_card_save);
    button.setOnClickListener(new View.OnClickListener() {
        @Override/*w  w w .ja va2 s.c o m*/
        public void onClick(View view) {
            saveEditCardUrlToBeacon();
        }
    });

    fileLink = getArguments() != null ? getArguments().getString(ARG_FILE_LINK) : "";

    return view;
}

From source file:nya.miku.wishmaster.chans.tbpchan.TBPchanModule.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_tbp, null);
}

From source file:com.squalala.tariki.ui.map.MapsActivity.java

@Override
protected void onStart() {
    super.onStart();
    updatableLocationSubscription = locationUpdatesObservable

            .subscribe(new Subscriber<Location>() {
                @Override/*from w w  w . j a v  a2  s .c  o m*/
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    e.printStackTrace();
                }

                @DebugLog
                @Override
                public void onNext(Location location) {
                    if (location != null) {
                        GeoPoint geoPoint = new GeoPoint(location.getLatitude(), location.getLongitude());
                        Drawable poiIcon = ResourcesCompat.getDrawable(getResources(), R.drawable.marker_male,
                                null);
                        myMarker.setPosition(geoPoint);
                        myMarker.setIcon(poiIcon);
                        myMarker.setTitle("Moi");
                        mapController.setZoom(18);
                        mapController.setCenter(geoPoint);
                    }
                }
            });

}

From source file:com.google.android.apps.santatracker.map.cardstream.CardAdapter.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setupTvCardIfNecessary(CardViewHolder holder) {
    if (mIsTv) {//from w ww  . ja  va 2s  .c  om

        if (mFocusHighlight == null) {
            mFocusHighlight = new TvFocusAnimator();
        }

        final Resources res = holder.itemView.getResources();

        TvFocusAnimator.FocusChangeListener listener = new TvFocusAnimator.FocusChangeListener(mFocusHighlight);

        holder.itemView.setFocusable(true);
        holder.itemView.setFocusableInTouchMode(false);
        holder.itemView.setOnFocusChangeListener(listener);
        holder.itemView.setElevation(res.getDimensionPixelOffset(R.dimen.toolbar_elevation));

        mFocusHighlight.onInitializeView(holder.itemView);

        if (holder.itemView.getBackground() == null) {
            holder.itemView.setBackground(ResourcesCompat.getDrawable(res, R.drawable.tv_tracker_card_selector,
                    holder.itemView.getContext().getTheme()));
        }
    }
}

From source file:uz.efir.alqalam.SurahActivity.java

private Drawable getSpecialImage(int surah, int ayat) {
    // Sajda icon
    for (int i = 0; i < Utils.NUMBER_OF_SAJDAS; i++) {
        if (Utils.SAJDA_INDEXES[i][0] == surah && Utils.SAJDA_INDEXES[i][1] == ayat)
            return ResourcesCompat.getDrawable(getResources(), R.drawable.sajdah, null);
    }/*from  w  w  w . j av  a  2s.c om*/
    // Juz icon
    for (int i = 0; i < Utils.NUMBER_OF_JUZZ; i++) {
        if (Utils.JUZZ_INDEXES[i][0] == surah && Utils.JUZZ_INDEXES[i][1] == ayat)
            return ResourcesCompat.getDrawable(getResources(), R.drawable.juzz, null);
    }

    return null;
}

From source file:com.nttec.everychan.chans.ponyach.PonyachModule.java

@Override
public Drawable getChanFavicon() {
    return ResourcesCompat.getDrawable(resources, R.drawable.favicon_ponyach, null);
}

From source file:com.mischivous.wormysharpyloggy.wsl.GameScreen.java

/**
 * Initialize a new Game instance of the selected game type.
 *
 * @param type The type of Game to initialize
 *///from w  w  w. j a  v a  2  s  .  c o m
@TargetApi(17)
private void StartGame(@NonNull GameType type) {
    if (type == null) {
        throw new IllegalArgumentException("Game type cannot be null.");
    }

    game = new Game(type, OptionsHelper.GetSetCount(this), OptionsHelper.GetMinDiff(this),
            OptionsHelper.GetMaxDiff(this));

    game.AddGameOverListener(this);
    ClearTilesSelected();

    for (int i = 0; i < tiles.length; i++) {
        Drawable d = game.GetTileAt(i).GetDrawable(this);
        if (d == null) {
            Log.e(TAG, String.format("Failed to get drawable for tile %d. Value is null.", i));
        } else {
            tiles[i].setImageDrawable(d);
            Log.d(TAG, String.format("Set tile image for tiles[%d]", i));
        }
    }

    // Initialize the blanks at the top for normal/time attack modes
    if (type == GameType.Normal || type == GameType.TimeAttack) {
        if (found.length > 3) {
            for (int set = 3; set < found.length; set++)
                for (int tile = 0; tile < found[set].length; tile++)
                    found[set][tile].setImageDrawable(
                            ResourcesCompat.getDrawable(getResources(), R.mipmap.tile_small_blank, null));
        }
        // Center the Found Sets string
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
                findViewById(R.id.foundSetsTitle).getLayoutParams());

        int id = getResources().getIdentifier(String.format("FoundSet%d_1", found.length), "id",
                getPackageName());

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            lp.addRule(RelativeLayout.ALIGN_END, id);
        } else {
            lp.addRule(RelativeLayout.ALIGN_RIGHT, id);
        }
        findViewById(R.id.foundSetsTitle).setLayoutParams(lp);
    } else {
        // Place the first join in the correct location
        int id = getResources().getIdentifier("joinImage", "id", getPackageName());

        ImageView iv = (ImageView) findViewById(id);
        if (iv == null) {
            Log.e(TAG, "Failed to set joinImage. Value is null.");
        } else {
            iv.setImageDrawable(game.GetNextJoin().GetDrawable(this));
        }
    }

    // Change elapsed time string to time remaining string for Time Attack
    if (type == GameType.TimeAttack) {
        ((TextView) findViewById(R.id.timeTitle)).setText(getString(R.string.remainingString));
    }
}

From source file:com.franmontiel.fullscreendialog.FullScreenDialogFragment.java

private void setThemeBackground(View view) {
    TypedValue a = new TypedValue();
    getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
    if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
        view.setBackgroundColor(a.data);
    } else {/*from  w w  w . j  av  a  2 s. co m*/
        try {
            Drawable d = ResourcesCompat.getDrawable(getActivity().getResources(), a.resourceId,
                    getActivity().getTheme());
            ViewCompat.setBackground(view, d);
        } catch (Resources.NotFoundException ignore) {
        }
    }
}

From source file:com.appeaser.sublimenavigationviewlibrary.SublimeThemer.java

public Drawable getGroupExpandDrawable() {
    if (mGroupExpandDrawable == null) {
        mGroupExpandDrawable = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.snv_expand,
                mContext.getTheme());/*from  w w w.  j a  va 2 s  . c o  m*/
    }

    // Return a new drawable since this method will be
    // called multiple times
    return mGroupExpandDrawable.getConstantState().newDrawable();
}

From source file:com.vnidens.clickableedittext.ClickableEditTextHelper.java

@Override
public void setStartButtonDrawable(@DrawableRes int drawable) {
    EditText et = viewWeakRef.get();/*from ww  w .j a  v a2s .c  o  m*/
    if (et != null) {
        setStartButtonDrawable(
                ResourcesCompat.getDrawable(et.getResources(), drawable, et.getContext().getTheme()));
    }
}