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 
     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 getDirectoryId() {
     66         return mDelegate.getDirectoryId();
     67     }
     68 
     69     @Override
     70     public String getLookupKey() {
     71         return mDelegate.getLookupKey();
     72     }
     73 
     74     @Override
     75     public long getDataId() {
     76         return mDelegate.getDataId();
     77     }
     78 
     79     @Override
     80     public RecipientEntry getEntry() {
     81         return mDelegate.getEntry();
     82     }
     83 
     84     @Override
     85     public void setOriginalText(final String text) {
     86         mDelegate.setOriginalText(text);
     87     }
     88 
     89     @Override
     90     public CharSequence getOriginalText() {
     91         return mDelegate.getOriginalText();
     92     }
     93 
     94     @Override
     95     public void draw(final Canvas canvas, final CharSequence text, final int start, final int end,
     96             final float x, final int top, final int y, final int bottom, final Paint paint) {
     97         // Do nothing.
     98     }
     99 
    100     @Override
    101     public int getSize(final Paint paint, final CharSequence text, final int start, final int end,
    102             final Paint.FontMetricsInt fm) {
    103         return 0;
    104     }
    105 
    106     @Override
    107     public Rect getBounds() {
    108         return new Rect(0, 0, 0, 0);
    109     }
    110 
    111     @Override
    112     public void draw(final Canvas canvas) {
    113         // do nothing.
    114     }
    115 }
    116