Example usage for android.support.v4.content ContextCompat getDrawable

List of usage examples for android.support.v4.content ContextCompat getDrawable

Introduction

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

Prototype

public static final Drawable getDrawable(Context context, int i) 

Source Link

Usage

From source file:com.amsterdam.marktbureau.makkelijkemarkt.LoginFragment.java

/**
 * Set the login fragment layout and initialize the login logic
 * @param inflater inflater object to inflate the layout
 * @param container the parent view container
 * @param savedInstanceState fragment state bundle
 * @return the inflated view//from   ww  w . ja  v  a 2 s  . c o m
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // inflate the login fragment layout
    View mainView = inflater.inflate(R.layout.login_fragment, container, false);

    // bind the elements to the view
    ButterKnife.bind(this, mainView);

    if (savedInstanceState == null) {

        // check if there is a newer build of the app available
        Utility.checkForUpdate(getActivity(), UPDATE_FRAGMENT_TAG, true);

        // TODO: if there is no internet connection and accounts were never loaded: keep checking for an internet connection and try again

        // check time in hours since last fetched the accounts
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getContext());
        long diffInHours = getResources()
                .getInteger(R.integer.makkelijkemarkt_api_accounts_fetch_interval_hours);
        if (settings.contains(getContext().getString(R.string.sharedpreferences_key_accounts_last_fetched))) {
            long lastFetchTimestamp = settings
                    .getLong(getContext().getString(R.string.sharedpreferences_key_accounts_last_fetched), 0);
            long differenceMs = new Date().getTime() - lastFetchTimestamp;
            diffInHours = TimeUnit.MILLISECONDS.toHours(differenceMs);
        }

        // update the local accounts by reloading them from the api
        if (diffInHours >= getResources()
                .getInteger(R.integer.makkelijkemarkt_api_accounts_fetch_interval_hours)) {

            // show the progressbar
            mAccountsProgressBar.setVisibility(View.VISIBLE);

            // call the api
            ApiGetAccounts getAccounts = new ApiGetAccounts(getContext());
            if (!getAccounts.enqueue()) {
                mAccountsProgressBar.setVisibility(View.GONE);
            }
        }
    }

    // create an adapter for the account spinner
    mAccountsAdapter = new SimpleCursorAdapter(getContext(), android.R.layout.simple_list_item_activated_1,
            null, new String[] { MakkelijkeMarktProvider.Account.COL_NAAM }, new int[] { android.R.id.text1 },
            0);

    // attach the adapter to the account spinner
    mAccount.setAdapter(mAccountsAdapter);

    // initiate loading the accounts from the database
    getLoaderManager().initLoader(ACCOUNTS_LOADER, null, this);

    // disable all caps for the button title
    mLoginButton.setTransformationMethod(null);

    // create the login progress dialog
    mLoginProcessDialog = new ProgressDialog(getContext());
    mLoginProcessDialog.setIndeterminate(true);
    mLoginProcessDialog
            .setIndeterminateDrawable(ContextCompat.getDrawable(getContext(), R.drawable.progressbar_circle));
    mLoginProcessDialog.setMessage(getString(R.string.login) + "...");
    mLoginProcessDialog.setCancelable(false);

    return mainView;
}

From source file:com.google.firebase.codelab.friendlych.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mUsername = ANONYMOUS;/*from   w ww  .  j  a  va  2 s  . com*/

    // Initialize Firebase Auth
    mFirebaseAuth = FirebaseAuth.getInstance();
    mFirebaseUser = mFirebaseAuth.getCurrentUser();

    if (mFirebaseUser == null) {
        // Not signed in, launch the Sign In activity
        startActivity(new Intent(this, SignInActivity.class));
        finish();
        return;
    } else {
        mUsername = mFirebaseUser.getDisplayName();
        mPhotoUrl = mFirebaseUser.getPhotoUrl().toString();
    }

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API).build();

    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView);
    mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setStackFromEnd(true);

    mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference();
    mFirebaseAdapter = new FirebaseRecyclerAdapter<FriendlyMessage, MessageViewHolder>(FriendlyMessage.class,
            R.layout.item_message, MessageViewHolder.class, mFirebaseDatabaseReference.child(MESSAGES_CHILD)) {

        @Override
        protected void populateViewHolder(MessageViewHolder viewHolder, FriendlyMessage friendlyMessage,
                int position) {
            mProgressBar.setVisibility(ProgressBar.INVISIBLE);
            viewHolder.messageTextView.setText(friendlyMessage.getText());
            viewHolder.messengerTextView.setText(friendlyMessage.getName());
            if (friendlyMessage.getPhotoUrl() == null) {
                viewHolder.messengerImageView.setImageDrawable(
                        ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_account_circle_black_36dp));
            } else {
                Glide.with(MainActivity.this).load(friendlyMessage.getPhotoUrl())
                        .into(viewHolder.messengerImageView);
            }
        }
    };

    mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            super.onItemRangeInserted(positionStart, itemCount);
            int friendlyMessageCount = mFirebaseAdapter.getItemCount();
            int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition();
            // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll
            // to the bottom of the list to show the newly added message.
            if (lastVisiblePosition == -1 || (positionStart >= (friendlyMessageCount - 1)
                    && lastVisiblePosition == (positionStart - 1))) {
                mMessageRecyclerView.scrollToPosition(positionStart);
            }
        }
    });

    mMessageRecyclerView.setLayoutManager(mLinearLayoutManager);
    mMessageRecyclerView.setAdapter(mFirebaseAdapter);

    // Initialize Firebase Measurement.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    // Initialize Firebase Remote Config.
    mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();

    // Define Firebase Remote Config Settings.
    FirebaseRemoteConfigSettings firebaseRemoteConfigSettings = new FirebaseRemoteConfigSettings.Builder()
            .setDeveloperModeEnabled(true).build();

    // Define default config values. Defaults are used when fetched config values are not
    // available. Eg: if an error occurred fetching values from the server.
    Map<String, Object> defaultConfigMap = new HashMap<>();
    defaultConfigMap.put("friendly_msg_length", 10L);

    // Apply config settings and default values.
    mFirebaseRemoteConfig.setConfigSettings(firebaseRemoteConfigSettings);
    mFirebaseRemoteConfig.setDefaults(defaultConfigMap);

    // Fetch remote config.
    fetchConfig();

    mMessageEditText = (EditText) findViewById(R.id.messageEditText);
    mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
            mSharedPreferences.getInt(CodelabPreferences.FRIENDLY_MSG_LENGTH, DEFAULT_MSG_LENGTH_LIMIT)) });
    mMessageEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (charSequence.toString().trim().length() > 0) {
                mSendButton.setEnabled(true);
            } else {
                mSendButton.setEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    mSendButton = (Button) findViewById(R.id.sendButton);
    mSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            FriendlyMessage friendlyMessage = new FriendlyMessage(mMessageEditText.getText().toString(),
                    mUsername, mPhotoUrl);
            mFirebaseDatabaseReference.child(MESSAGES_CHILD).push().setValue(friendlyMessage);
            mMessageEditText.setText("");
            mFirebaseAnalytics.logEvent(MESSAGE_SENT_EVENT, null);
        }
    });
}

From source file:com.justplay1.shoppist.features.search.SearchFragment.java

private void updateNavigationIcon() {
    Context context = searchView.getContext();
    Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_arrow_back);
    drawable = DrawableCompat.wrap(drawable);
    DrawableCompat.setTint(drawable, ViewUtils.getThemeAttrColor(context, R.attr.colorControlNormal));
    searchView.setIcon(drawable);//from w  w w  .j  a v a  2s .  co m
}

From source file:com.iyaa.richat.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    mUsername = ANONYMOUS;/*from ww  w.  j ava 2  s  .  c om*/

    // Initialize Firebase Auth
    mFirebaseAuth = FirebaseAuth.getInstance();
    mFirebaseUser = mFirebaseAuth.getCurrentUser();

    if (mFirebaseUser == null) {
        // Not signed in, launch the Sign In activity
        startActivity(new Intent(this, SignInActivity.class));
        finish();
        return;
    } else {
        mUsername = mFirebaseUser.getDisplayName();
        if (mFirebaseUser.getPhotoUrl() != null) {
            mPhotoUrl = mFirebaseUser.getPhotoUrl().toString();
        }
    }

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API).build();

    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mMessageRecyclerView = (RecyclerView) findViewById(R.id.messageRecyclerView);
    mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setStackFromEnd(true);

    mFirebaseDatabaseReference = FirebaseDatabase.getInstance().getReference();
    mFirebaseAdapter = new FirebaseRecyclerAdapter<FriendlyMessage, MessageViewHolder>(FriendlyMessage.class,
            R.layout.item_message, MessageViewHolder.class, mFirebaseDatabaseReference.child(MESSAGES_CHILD)) {

        @Override
        protected void populateViewHolder(MessageViewHolder viewHolder, FriendlyMessage friendlyMessage,
                int position) {
            mProgressBar.setVisibility(ProgressBar.INVISIBLE);
            viewHolder.messageTextView.setText(friendlyMessage.getText());
            viewHolder.messengerTextView.setText(friendlyMessage.getName());
            if (friendlyMessage.getPhotoUrl() == null) {
                viewHolder.messengerImageView.setImageDrawable(
                        ContextCompat.getDrawable(MainActivity.this, R.drawable.ic_account_circle_black_36dp));
            } else {
                Glide.with(MainActivity.this).load(friendlyMessage.getPhotoUrl())
                        .into(viewHolder.messengerImageView);
            }
        }
    };

    mFirebaseAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onItemRangeInserted(int positionStart, int itemCount) {
            super.onItemRangeInserted(positionStart, itemCount);
            int friendlyMessageCount = mFirebaseAdapter.getItemCount();
            int lastVisiblePosition = mLinearLayoutManager.findLastCompletelyVisibleItemPosition();
            // If the recycler view is initially being loaded or the user is at the bottom of the list, scroll
            // to the bottom of the list to show the newly added message.
            if (lastVisiblePosition == -1 || (positionStart >= (friendlyMessageCount - 1)
                    && lastVisiblePosition == (positionStart - 1))) {
                mMessageRecyclerView.scrollToPosition(positionStart);
            }
        }
    });

    mMessageRecyclerView.setLayoutManager(mLinearLayoutManager);
    mMessageRecyclerView.setAdapter(mFirebaseAdapter);

    // Initialize Firebase Measurement.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);

    // Initialize Firebase Remote Config.
    mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();

    // Define Firebase Remote Config Settings.
    FirebaseRemoteConfigSettings firebaseRemoteConfigSettings = new FirebaseRemoteConfigSettings.Builder()
            .setDeveloperModeEnabled(true).build();

    // Define default config values. Defaults are used when fetched config values are not
    // available. Eg: if an error occurred fetching values from the server.
    Map<String, Object> defaultConfigMap = new HashMap<>();
    defaultConfigMap.put("friendly_msg_length", 80L);

    // Apply config settings and default values.
    mFirebaseRemoteConfig.setConfigSettings(firebaseRemoteConfigSettings);
    mFirebaseRemoteConfig.setDefaults(defaultConfigMap);

    // Fetch remote config.
    fetchConfig();

    mMessageEditText = (EditText) findViewById(R.id.messageEditText);
    mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(
            mSharedPreferences.getInt(CodelabPreferences.FRIENDLY_MSG_LENGTH, DEFAULT_MSG_LENGTH_LIMIT)) });
    mMessageEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (charSequence.toString().trim().length() > 0) {
                mSendButton.setEnabled(true);
            } else {
                mSendButton.setEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    mSendButton = (Button) findViewById(R.id.sendButton);
    mSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            FriendlyMessage friendlyMessage = new FriendlyMessage(mMessageEditText.getText().toString(),
                    mUsername, mPhotoUrl);
            mFirebaseDatabaseReference.child(MESSAGES_CHILD).push().setValue(friendlyMessage);
            mMessageEditText.setText("");
            mFirebaseAnalytics.logEvent(MESSAGE_SENT_EVENT, null);
        }
    });
}

From source file:com.jrummyapps.busybox.fragments.ScriptsFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final ShellScript script = adapter.getItem(position);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        // hack to get the popupmenu color working on Android 6.0+ for custom color schemes
        ContextCompat.getDrawable(getActivity(), R.drawable.bg_popup_dark);
        ContextCompat.getDrawable(getActivity(), R.drawable.bg_popup_light);
    }/*from   ww w  .j a  v  a 2s.  c  o m*/

    PopupMenu popupMenu = new PopupMenu(getActivity(), view);

    popupMenu.getMenu().add(0, 1, 0, R.string.run).setIcon(R.drawable.ic_play_white_24dp);
    popupMenu.getMenu().add(0, 2, 0, R.string.edit).setIcon(R.drawable.ic_edit_white_24dp);
    popupMenu.getMenu().add(0, 3, 0, R.string.info).setIcon(R.drawable.ic_information_white_24dp);
    popupMenu.getMenu().add(0, 4, 0, R.string.delete).setIcon(R.drawable.ic_delete_white_24dp);

    getRadiant().tint(popupMenu.getMenu()).forceIcons().apply(getActivity());

    Analytics.newEvent("clicked script").put("script_name", script.name).put("script_file", script.path).log();

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case 1: { // run
                Intent intent = new Intent(getActivity(), ScriptExecutorActivity.class);
                intent.putExtra(FileIntents.INTENT_EXTRA_PATH, script.path);
                startActivity(intent);
                return true;
            }
            case 2: { // edit
                Intent intent = new Intent(getActivity(), TextEditorActivity.class);
                intent.putExtra(FileIntents.INTENT_EXTRA_PATH, script.path);
                startActivity(intent);
                return true;
            }
            case 3: { // info
                Intent intent = new Intent(getActivity(), FilePropertiesActivity.class);
                intent.putExtra(FileIntents.INTENT_EXTRA_FILE, new File(script.path));
                intent.putExtra(FilePropertiesActivity.EXTRA_DESCRIPTION, script.info);
                startActivity(intent);
                return true;
            }
            case 4: { // delete
                ShellScriptTable table = Database.getInstance().getTable(ShellScriptTable.NAME);
                boolean deleted = table.delete(script) != 0;
                if (deleted) {
                    adapter.scripts.remove(script);
                    adapter.notifyDataSetChanged();
                    new File(script.path).delete();
                }
                return true;
            }
            default:
                return false;
            }
        }
    });

    popupMenu.show();
}

From source file:com.amazon.android.tv.tenfoot.ui.fragments.ContentSearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = super.onCreateView(inflater, container, savedInstanceState);

    if (view != null) {
        // Set background color and drawable.
        view.setBackgroundColor(ContextCompat.getColor(getActivity(), android.R.color.transparent));
        view.setBackground(ContextCompat.getDrawable(getActivity(), R.drawable.search_background));

        final SearchBar searchBar = (SearchBar) view.findViewById(R.id.lb_search_bar);
        if (searchBar != null) {

            // Set the left margin of the search bar.
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) searchBar
                    .getLayoutParams();/*  www.  j a v a2s  .c om*/

            layoutParams.setMarginStart((int) getResources().getDimension(R.dimen.search_bar_margin_left));

            searchBar.setLayoutParams(layoutParams);

            // Move the search bar items next to the search icon.
            RelativeLayout searchBarItems = (RelativeLayout) searchBar.findViewById(R.id.lb_search_bar_items);

            if (searchBarItems != null) {

                RelativeLayout.LayoutParams searchBarItemsLayoutParams = (RelativeLayout.LayoutParams) searchBarItems
                        .getLayoutParams();

                searchBarItemsLayoutParams.setMarginStart(
                        (int) getResources().getDimension(R.dimen.search_bar_items_margin_left));

                searchBarItems.setLayoutParams(searchBarItemsLayoutParams);

                // Set the search bar items background selector.
                searchBarItems.setBackground(ContextCompat.getDrawable(getActivity(),
                        R.drawable.search_edit_text_bg_color_selector));
            }

            // Set speech orb icon.
            mSpeechOrbView = (SpeechOrbView) searchBar.findViewById(R.id.lb_search_bar_speech_orb);

            if (mSpeechOrbView != null) {
                mSpeechOrbView.setOrbIcon(ContextCompat.getDrawable(getActivity(), R.drawable.search_icon));
            }

            final SearchEditText searchEditText = (SearchEditText) searchBar
                    .findViewById(R.id.lb_search_text_editor);

            if (searchEditText != null) {

                mSearchEditText = searchEditText;

                // Handle keyboard being dismissed to prevent focus going to SearchOrb
                // If user presses back from keyboard, you don't get KeyboardDismissListener
                // so handle that here.
                searchEditText.setOnEditorActionListener((textView, actionId, keyEvent) -> {

                    // Track search if keyboard is closed with IME_ACTION_PREVIOUS or
                    // if IME_ACTION_SEARCH occurs.
                    if (actionId == EditorInfo.IME_ACTION_SEARCH
                            || actionId == EditorInfo.IME_ACTION_PREVIOUS) {

                        if (mQuery != null) {
                            AnalyticsHelper.trackSearchQuery(mQuery);
                        }
                    }

                    if (actionId == EditorInfo.IME_ACTION_PREVIOUS) {

                        // Prevent highlighting SearchOrb
                        mSpeechOrbView.setFocusable(false);
                        mSpeechOrbView.clearFocus();
                        // If there are results allow first result to be selected
                        if (mHasResults) {
                            mSearchEditText.clearFocus();
                        }

                        // Hide keyboard since we are handling the action
                        if (isAdded()) {
                            // Ensure we are added before calling getActivity
                            InputMethodManager inputManager = (InputMethodManager) getActivity()
                                    .getSystemService(Context.INPUT_METHOD_SERVICE);
                            if (inputManager != null) {
                                inputManager.hideSoftInputFromWindow(
                                        getActivity().getCurrentFocus().getWindowToken(),
                                        InputMethodManager.HIDE_NOT_ALWAYS);
                            }
                        } else {
                            Log.e(TAG, "Cannot find activity, can't dismiss keyboard");
                            // Couldn't handle action.
                            // Will expose other focus issues potentially.
                            return false;
                        }
                        // No more processing of this action.
                        return true;
                    }
                    // Someone else needs to handle this action.
                    return false;
                });

                // Override the dismiss listener to get around keyboard issue where dismissing
                // keyboard takes user into first search result's
                // content_details_activity_layout page.
                searchEditText.setOnKeyboardDismissListener(() -> {
                    // If search returns results, focus on the first item in the result list.
                    // If search doesn't have results, this will focus on searchEditText again.
                    mSpeechOrbView.setFocusable(false);
                    mSpeechOrbView.clearFocus();
                    // We don't need to clearFocus on SearchEditText here, the first
                    // result will be selected already.
                });
            }
        }
    }
    return view;
}

From source file:com.goforer.base.ui.helper.RecyclerItemTouchHelperCallback.java

private void init() {
    mBackground = new ColorDrawable(mBgColor);
    mDeleteIcon = ContextCompat.getDrawable(mContext, R.drawable.ic_delete_item);
    mDeleteIconMargin = (int) mContext.getResources().getDimension(R.dimen.helper_icon_clear_margin);
    mInitiated = true;/*from   w  w w.  jav a 2  s . co  m*/
}

From source file:com.example.matt.bingeList.viewControllers.fragments.shows.TVShowBrowseSeasonFragment.java

public void updateSeasonRecyclerView(ArrayList<TVShowSeasonResult> seasons) {
    final SeasonAdapter myItemAdapter = new SeasonAdapter(seasons, vibrantColor, mutedColor);

    mWrappedAdapter = mRecyclerViewExpandableItemManager.createWrappedAdapter(myItemAdapter); // wrap for expanding

    final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();

    // Change animations are enabled by default since support-v7-recyclerview v22.
    // Need to disable them when using animation indicator.
    animator.setSupportsChangeAnimations(false);

    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter
    mRecyclerView.setItemAnimator(animator);
    mRecyclerView.setHasFixedSize(false);

    // additional decorations
    //noinspection StatementWithEmptyBody
    if (supportsViewElevation()) {
        // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {/*from  w ww .  jav a2 s  .c o  m*/
        mRecyclerView.addItemDecoration(new ItemShadowDecorator(
                (NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
    }
    mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(
            ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
    mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}

From source file:com.bilibili.magicasakura.widgets.AppCompatForegroundHelper.java

@Override
public void tint() {
    if (mForegroundTintResId == 0 || !setSupportForegroundTint(mForegroundTintResId)) {
        Drawable drawable = mTintManager.getDrawable(mForegroundResId);
        if (drawable == null) {
            drawable = mForegroundResId == 0 ? null
                    : ContextCompat.getDrawable(mView.getContext(), mForegroundResId);
        }/*from  w w w.  j  ava 2s.c  om*/
        setForegroundDrawable(drawable);
    }
}

From source file:com.google.samples.apps.topeka.adapter.CategoryAdapter.java

/**
 * Loads and tints a drawable.//from ww w .  j  a v a  2s. c  om
 *
 * @param category The category providing the tint color
 * @param categoryImageResource The image resource to tint
 * @return The tinted resource
 */
private Drawable loadTintedCategoryDrawable(Category category, int categoryImageResource) {
    final Drawable categoryIcon = ContextCompat.getDrawable(mActivity, categoryImageResource).mutate();
    return wrapAndTint(categoryIcon, category.getTheme().getPrimaryColor());
}