1/*
2 * Copyright (C) 2011 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 com.android.ex.chips.recipientchip;
18
19import android.graphics.Canvas;
20import android.graphics.Rect;
21import android.graphics.drawable.Drawable;
22
23import com.android.ex.chips.RecipientEntry;
24
25/**
26 * VisibleRecipientChip defines a ReplacementSpan that contains information relevant to a
27 * particular recipient and renders a background asset to go with it.
28 */
29public class VisibleRecipientChip extends ReplacementDrawableSpan implements DrawableRecipientChip {
30    private final SimpleRecipientChip mDelegate;
31
32    public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
33        super(drawable);
34        mDelegate = new SimpleRecipientChip(entry);
35    }
36
37    @Override
38    public void setSelected(final boolean selected) {
39        mDelegate.setSelected(selected);
40    }
41
42    @Override
43    public boolean isSelected() {
44        return mDelegate.isSelected();
45    }
46
47    @Override
48    public CharSequence getDisplay() {
49        return mDelegate.getDisplay();
50    }
51
52    @Override
53    public CharSequence getValue() {
54        return mDelegate.getValue();
55    }
56
57    @Override
58    public long getContactId() {
59        return mDelegate.getContactId();
60    }
61
62    @Override
63    public Long getDirectoryId() {
64        return mDelegate.getDirectoryId();
65    }
66
67    @Override
68    public String getLookupKey() {
69        return mDelegate.getLookupKey();
70    }
71
72    @Override
73    public long getDataId() {
74        return mDelegate.getDataId();
75    }
76
77    @Override
78    public RecipientEntry getEntry() {
79        return mDelegate.getEntry();
80    }
81
82    @Override
83    public void setOriginalText(final String text) {
84        mDelegate.setOriginalText(text);
85    }
86
87    @Override
88    public CharSequence getOriginalText() {
89        return mDelegate.getOriginalText();
90    }
91
92    @Override
93    public Rect getBounds() {
94        return super.getBounds();
95    }
96
97    @Override
98    public void draw(final Canvas canvas) {
99        mDrawable.draw(canvas);
100    }
101
102    @Override
103    public String toString() {
104        return mDelegate.toString();
105    }
106}
107