InvisibleRecipientChip.java revision 194d427ebcfc2133bda410e0e4c399250d9a6066
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.Paint;
21import android.graphics.Rect;
22import android.text.style.ReplacementSpan;
23
24import com.android.ex.chips.RecipientEntry;
25
26/**
27 * RecipientChip defines a span that contains information relevant to a
28 * particular recipient.
29 */
30public class InvisibleRecipientChip extends ReplacementSpan implements DrawableRecipientChip {
31    private final SimpleRecipientChip mDelegate;
32
33    public InvisibleRecipientChip(final RecipientEntry entry) {
34        super();
35
36        mDelegate = new SimpleRecipientChip(entry);
37    }
38
39    @Override
40    public void setSelected(final boolean selected) {
41        mDelegate.setSelected(selected);
42    }
43
44    @Override
45    public boolean isSelected() {
46        return mDelegate.isSelected();
47    }
48
49    @Override
50    public CharSequence getDisplay() {
51        return mDelegate.getDisplay();
52    }
53
54    @Override
55    public CharSequence getValue() {
56        return mDelegate.getValue();
57    }
58
59    @Override
60    public long getContactId() {
61        return mDelegate.getContactId();
62    }
63
64    @Override
65    public long getDataId() {
66        return mDelegate.getDataId();
67    }
68
69    @Override
70    public RecipientEntry getEntry() {
71        return mDelegate.getEntry();
72    }
73
74    @Override
75    public void setOriginalText(final String text) {
76        mDelegate.setOriginalText(text);
77    }
78
79    @Override
80    public CharSequence getOriginalText() {
81        return mDelegate.getOriginalText();
82    }
83
84    @Override
85    public void draw(final Canvas canvas, final CharSequence text, final int start, final int end,
86            final float x, final int top, final int y, final int bottom, final Paint paint) {
87        // Do nothing.
88    }
89
90    @Override
91    public int getSize(final Paint paint, final CharSequence text, final int start, final int end,
92            final Paint.FontMetricsInt fm) {
93        return 0;
94    }
95
96    @Override
97    public Rect getBounds() {
98        return new Rect(0, 0, 0, 0);
99    }
100
101    @Override
102    public void draw(final Canvas canvas) {
103        // do nothing.
104    }
105}
106