/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: Tim Marston
  • Date: 2013-07-19 15:55:07 UTC
  • Revision ID: tim@ed.am-20130719155507-qb78vx8m4s1ngyut
added suopport for birthdays

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * ContactsCache.java
3
3
 *
4
 
 * Copyright (C) 2011 to 2012 Tim Marston <tim@ed.am>
 
4
 * Copyright (C) 2011 to 2013 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Import Contacts program (hereafter referred
7
7
 * to as "this program").  For more information, see
137
137
                = new HashMap< Long, HashSet< String > >();
138
138
        private HashMap< Long, HashSet< String > > _contactNotes
139
139
                = new HashMap< Long, HashSet< String > >();
 
140
        private HashMap< Long, String > _contactBirthdays
 
141
                = new HashMap< Long, String >();
140
142
 
141
143
        public boolean canLookup( CacheIdentifier identifier )
142
144
        {
337
339
                set.add( note );
338
340
        }
339
341
 
 
342
        public boolean hasAssociatedBirthday( Long id, String birthday )
 
343
        {
 
344
                birthday = normaliseBirthday( birthday );
 
345
                if( birthday == null ) return false;
 
346
 
 
347
                String found = _contactBirthdays.get( id );
 
348
                return found != null && found.equalsIgnoreCase( birthday );
 
349
        }
 
350
 
 
351
        public void addAssociatedBirthday( Long id, String birthday )
 
352
        {
 
353
                birthday = normaliseBirthday( birthday );
 
354
                if( birthday == null ) return;
 
355
 
 
356
                _contactBirthdays.put( id, birthday );
 
357
        }
 
358
 
340
359
        static public String normaliseName( String name )
341
360
        {
342
361
                if( name == null ) return null;
378
397
                note = note.trim();
379
398
                return note.length() > 0? note : null;
380
399
        }
 
400
 
 
401
        static public String normaliseBirthday( String birthday )
 
402
        {
 
403
                if( birthday == null ) return null;
 
404
                birthday = birthday.trim();
 
405
                return birthday.length() > 0? birthday : null;
 
406
        }
381
407
}