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.Rect;
     21 import android.graphics.drawable.Drawable;
     22 
     23 import 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  */
     29 public class VisibleRecipientChip extends ReplacementDrawableSpan implements DrawableRecipientChip {
     30     private final SimpleRecipientChip mDelegate;
     31     private Rect mWarningIconBounds = new Rect(0, 0, 0, 0);
     32 
     33     public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
     34         super(drawable);
     35         mDelegate = new SimpleRecipientChip(entry);
     36     }
     37 
     38     @Override
     39     public void setSelected(final boolean selected) {
     40         mDelegate.setSelected(selected);
     41     }
     42 
     43     @Override
     44     public boolean isSelected() {
     45         return mDelegate.isSelected();
     46     }
     47 
     48     @Override
     49     public CharSequence getDisplay() {
     50         return mDelegate.getDisplay();
     51     }
     52 
     53     @Override
     54     public CharSequence getValue() {
     55         return mDelegate.getValue();
     56     }
     57 
     58     @Override
     59     public long getContactId() {
     60         return mDelegate.getContactId();
     61     }
     62 
     63     @Override
     64     public Long getDirectoryId() {
     65         return mDelegate.getDirectoryId();
     66     }
     67 
     68     @Override
     69     public String getLookupKey() {
     70         return mDelegate.getLookupKey();
     71     }
     72 
     73     @Override
     74     public long getDataId() {
     75         return mDelegate.getDataId();
     76     }
     77 
     78     @Override
     79     public RecipientEntry getEntry() {
     80         return mDelegate.getEntry();
     81     }
     82 
     83     @Override
     84     public void setOriginalText(final String text) {
     85         mDelegate.setOriginalText(text);
     86     }
     87 
     88     @Override
     89     public CharSequence getOriginalText() {
     90         return mDelegate.getOriginalText();
     91     }
     92 
     93     @Override
     94     public Rect getBounds() {
     95         return super.getBounds();
     96     }
     97 
     98     @Override
     99     public void draw(final Canvas canvas) {
    100         mDrawable.draw(canvas);
    101     }
    102 
    103     @Override
    104     public String toString() {
    105         return mDelegate.toString();
    106     }
    107 
    108     @Override
    109     public Rect getWarningIconBounds() {
    110         return mWarningIconBounds;
    111     }
    112 
    113     public void setWarningIconBounds(Rect warningIconBounds) {
    114         mWarningIconBounds = warningIconBounds;
    115     }
    116 }
    117