1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.support.v7.internal.widget; 18 19import android.content.res.Resources; 20import android.graphics.drawable.Drawable; 21import android.support.v7.appcompat.R; 22 23/** 24 * This class allows us to intercept calls so that we can tint resources (if applicable). 25 * 26 * @hide 27 */ 28class TintResources extends ResourcesWrapper { 29 30 private final TintManager mTintManager; 31 32 public TintResources(Resources resources, TintManager tintManager) { 33 super(resources); 34 mTintManager = tintManager; 35 } 36 37 /** 38 * We intercept this call so that we tint the result (if applicable). This is needed for things 39 * like {@link DrawableContainer}s which retrieve their children via this method. 40 */ 41 @Override 42 public Drawable getDrawable(int id) throws NotFoundException { 43 Drawable d = super.getDrawable(id); 44 if (d != null) { 45 mTintManager.tintDrawable(id, d); 46 } 47 return d; 48 } 49} 50