• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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 package com.android.contacts.list;
17 
18 import com.android.common.widget.CompositeCursorAdapter;
19 
20 import android.provider.ContactsContract.Directory;
21 
22 /**
23  * Model object for a {@link Directory} row.
24  */
25 public final class DirectoryPartition extends CompositeCursorAdapter.Partition {
26 
27     public static final int STATUS_NOT_LOADED = 0;
28     public static final int STATUS_LOADING = 1;
29     public static final int STATUS_LOADED = 2;
30 
31     private long mDirectoryId;
32     private String mDirectoryType;
33     private String mDisplayName;
34     private int mStatus;
35     private boolean mPriorityDirectory;
36     private boolean mPhotoSupported;
37 
DirectoryPartition(boolean showIfEmpty, boolean hasHeader)38     public DirectoryPartition(boolean showIfEmpty, boolean hasHeader) {
39         super(showIfEmpty, hasHeader);
40     }
41 
42     /**
43      * Directory ID, see {@link Directory}.
44      */
getDirectoryId()45     public long getDirectoryId() {
46         return mDirectoryId;
47     }
48 
setDirectoryId(long directoryId)49     public void setDirectoryId(long directoryId) {
50         this.mDirectoryId = directoryId;
51     }
52 
53     /**
54      * Directory type resolved from {@link Directory#PACKAGE_NAME} and
55      * {@link Directory#TYPE_RESOURCE_ID};
56      */
getDirectoryType()57     public String getDirectoryType() {
58         return mDirectoryType;
59     }
60 
setDirectoryType(String directoryType)61     public void setDirectoryType(String directoryType) {
62         this.mDirectoryType = directoryType;
63     }
64 
65     /**
66      * See {@link Directory#DISPLAY_NAME}.
67      */
getDisplayName()68     public String getDisplayName() {
69         return mDisplayName;
70     }
71 
setDisplayName(String displayName)72     public void setDisplayName(String displayName) {
73         this.mDisplayName = displayName;
74     }
75 
getStatus()76     public int getStatus() {
77         return mStatus;
78     }
79 
setStatus(int status)80     public void setStatus(int status) {
81         mStatus = status;
82     }
83 
isLoading()84     public boolean isLoading() {
85         return mStatus == STATUS_NOT_LOADED || mStatus == STATUS_LOADING;
86     }
87 
88     /**
89      * Returns true if this directory should be loaded before non-priority directories.
90      */
isPriorityDirectory()91     public boolean isPriorityDirectory() {
92         return mPriorityDirectory;
93     }
94 
setPriorityDirectory(boolean priorityDirectory)95     public void setPriorityDirectory(boolean priorityDirectory) {
96         mPriorityDirectory = priorityDirectory;
97     }
98 
99     /**
100      * Returns true if this directory supports photos.
101      */
isPhotoSupported()102     public boolean isPhotoSupported() {
103         return mPhotoSupported;
104     }
105 
setPhotoSupported(boolean flag)106     public void setPhotoSupported(boolean flag) {
107         this.mPhotoSupported = flag;
108     }
109 }
110