/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/ContactsCache.java

  • Committer: edam
  • Date: 2012-12-21 21:05:13 UTC
  • Revision ID: tim@ed.am-20121221210513-scyf50006hqadgjw
updated NEWS

Show diffs side-by-side

added added

removed removed

36
36
         */
37
37
        public static class CacheIdentifier
38
38
        {
39
 
                public enum Type {
40
 
                        NONE, NAME, ORGANISATION, PRIMARY_NUMBER, PRIMARY_EMAIL }
 
39
                public enum Type { NAME, ORGANISATION, PRIMARY_NUMBER, PRIMARY_EMAIL }
41
40
 
42
41
                private Type _type;
43
42
                private String _detail;
44
43
 
45
 
                protected CacheIdentifier()
46
 
                {
47
 
                        _type = Type.NONE;
48
 
                }
49
 
 
50
44
                /**
51
45
                 * Obtain a cache identifier.  This routine is designed to be as robust
52
46
                 * as possible (in terms of bad or null detail values), and to return
78
72
                 */
79
73
                public static CacheIdentifier factory( Importer.ContactData contact )
80
74
                {
81
 
                        CacheIdentifier ret = null;
 
75
                        CacheIdentifier identifier = null;
82
76
 
83
77
                        if( contact.hasName() )
84
 
                                ret = factory( CacheIdentifier.Type.NAME,
 
78
                                identifier = factory( CacheIdentifier.Type.NAME,
85
79
                                        contact.getName() );
86
 
                        if( ret == null && contact.hasPrimaryOrganisation() )
87
 
                                ret = factory( CacheIdentifier.Type.ORGANISATION,
 
80
                        if( identifier != null ) return identifier;
 
81
 
 
82
                        if( contact.hasPrimaryOrganisation() )
 
83
                                identifier = factory( CacheIdentifier.Type.ORGANISATION,
88
84
                                        contact.getPrimaryOrganisation() );
89
 
                        if( ret == null && contact.hasPrimaryNumber() )
90
 
                                ret = factory( CacheIdentifier.Type.PRIMARY_NUMBER,
 
85
                        if( identifier != null ) return identifier;
 
86
 
 
87
                        if( contact.hasPrimaryNumber() )
 
88
                                identifier = factory( CacheIdentifier.Type.PRIMARY_NUMBER,
91
89
                                        contact.getPrimaryNumber() );
92
 
                        if( ret == null && contact.hasPrimaryEmail() )
93
 
                                ret = factory( CacheIdentifier.Type.PRIMARY_EMAIL,
 
90
                        if( identifier != null ) return identifier;
 
91
 
 
92
                        if( contact.hasPrimaryEmail() )
 
93
                                identifier = factory( CacheIdentifier.Type.PRIMARY_EMAIL,
94
94
                                        contact.getPrimaryEmail() );
 
95
                        if( identifier != null ) return identifier;
95
96
 
96
 
                        return ret;
 
97
                        return null;
97
98
                }
98
99
 
99
100
                protected CacheIdentifier( Type type, String detail )