<commit_before>/*
 * Copyright (C) 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.doctoror.fuckoffmusicplayer.util;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;

/**
 * Created by <NAME> on 7/13/16.
 */
public final class DrawableUtils {

    private DrawableUtils() {

    }

    @Nullable
    public static Drawable getTintedDrawable(@NonNull final Context context,
            @DrawableRes final int res,
            @Nullable final ColorStateList tint) {
        final Drawable d = ResourcesCompat.getDrawable(context.getResources(), res,
                context.getTheme());
        return getTintedDrawable(d, tint);
    }

    @Nullable
    public static Drawable getTintedDrawable(@Nullable Drawable drawable,
            @Nullable final ColorStateList tint) {
        if (drawable != null && tint != null) {
            drawable = DrawableCompat.wrap(drawable);
            DrawableCompat.setTintList(drawable, tint);
        }
        return drawable;
    }
}<commit_msg>Now setTint() is called even if it's null. This fixes issue when cached drawable could have tint pre-set.<commit_after>/*
 * Copyright (C) 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.doctoror.fuckoffmusicplayer.util;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.graphics.drawable.DrawableCompat;

/**
 * Drawable utils
 */
public final class DrawableUtils {

    private DrawableUtils() {

    }

    @Nullable
    public static Drawable getTintedDrawable(@NonNull final Context context,
            @DrawableRes final int res,
            @Nullable final ColorStateList tint) {
        final Drawable d = ResourcesCompat.getDrawable(context.getResources(), res,
                context.getTheme());
        return getTintedDrawable(d, tint);
    }

    @Nullable
    public static Drawable getTintedDrawable(@Nullable Drawable drawable,
            @Nullable final ColorStateList tint) {
        if (drawable != null) {
            drawable = DrawableCompat.wrap(drawable);
            DrawableCompat.setTintList(drawable, tint);
        }
        return drawable;
    }
}
{'fraction_non_alphanumeric': 0.08455588156841824, 'fraction_numerical': 0.006668444918644972, 'mean_word_length': 3.4169611307420493, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1117881', 'n_tokens_mistral': 998, 'n_tokens_neox': 976, 'n_words': 330}