Home | History | Annotate | Download | only in directshare
      1 /*
      2  * Copyright (C) 2015 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.example.android.directshare;
     18 
     19 /**
     20  * Provides the list of dummy contacts. This sample implements this as constants, but real-life apps
     21  * should use a database and such.
     22  */
     23 public class Contact {
     24 
     25     /**
     26      * The list of dummy contacts.
     27      */
     28     public static final Contact[] CONTACTS = {
     29             new Contact("Tereasa"),
     30             new Contact("Chang"),
     31             new Contact("Kory"),
     32             new Contact("Clare"),
     33             new Contact("Landon"),
     34             new Contact("Kyle"),
     35             new Contact("Deana"),
     36             new Contact("Daria"),
     37             new Contact("Melisa"),
     38             new Contact("Sammie"),
     39     };
     40 
     41     /**
     42      * The contact ID.
     43      */
     44     public static final String ID = "contact_id";
     45 
     46     /**
     47      * Representative invalid contact ID.
     48      */
     49     public static final int INVALID_ID = -1;
     50 
     51     /**
     52      * The name of this contact.
     53      */
     54     private final String mName;
     55 
     56     /**
     57      * Instantiates a new {@link Contact}.
     58      *
     59      * @param name The name of the contact.
     60      */
     61     public Contact(String name) {
     62         mName = name;
     63     }
     64 
     65     /**
     66      * Finds a {@link Contact} specified by a contact ID.
     67      *
     68      * @param id The contact ID. This needs to be a valid ID.
     69      * @return A {@link Contact}
     70      */
     71     public static Contact byId(int id) {
     72         return CONTACTS[id];
     73     }
     74 
     75     /**
     76      * Gets the name of this contact.
     77      *
     78      * @return The name of this contact.
     79      */
     80     public String getName() {
     81         return mName;
     82     }
     83 
     84     /**
     85      * Gets the icon of this contact.
     86      *
     87      * @return The icon.
     88      */
     89     public int getIcon() {
     90         return R.mipmap.logo_avatar;
     91     }
     92 
     93 }
     94