1 /* 2 * Copyright (C) 2016 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 package com.android.car.apps.common; 17 18 import android.content.res.Resources; 19 import android.graphics.Bitmap; 20 import android.graphics.drawable.BitmapDrawable; 21 22 /** 23 * RefcountBitmapDrawable class 24 * @hide 25 */ 26 public class RefcountBitmapDrawable extends BitmapDrawable { 27 28 private RefcountObject<Bitmap> mRefcountObject; 29 30 /** 31 * create initial drawable, this will not increase the refcount 32 */ 33 public RefcountBitmapDrawable(Resources res, RefcountObject<Bitmap> bitmap) { 34 super(res, bitmap.getObject()); 35 mRefcountObject = bitmap; 36 } 37 38 /** 39 * create the drawable from existing drawable, will not increase refcount 40 */ 41 public RefcountBitmapDrawable(Resources res, RefcountBitmapDrawable drawable) { 42 this(res, drawable.getRefcountObject()); 43 } 44 45 public RefcountObject<Bitmap> getRefcountObject() { 46 return mRefcountObject; 47 } 48 } 49