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