diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 4 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/utils/UIHelper.java | 12 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index cf3f72dc..90e9f20b 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -389,7 +389,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa final String action = intent == null ? null : intent.getAction(); if (action != null) { if (action.equals(ACTION_MERGE_PHONE_CONTACTS)) { - PhoneHelper.loadPhoneContacts(getApplicationContext(), new ArrayList<Bundle>(), this); + PhoneHelper.loadPhoneContacts(getApplicationContext(), new CopyOnWriteArrayList<Bundle>(), this); return START_STICKY; } else if (action.equals(Intent.ACTION_SHUTDOWN)) { logoutAndSave(); @@ -500,7 +500,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa this.databaseBackend.readRoster(account.getRoster()); } initConversations(); - PhoneHelper.loadPhoneContacts(getApplicationContext(),new ArrayList<Bundle>(), this); + PhoneHelper.loadPhoneContacts(getApplicationContext(),new CopyOnWriteArrayList<Bundle>(), this); getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver); this.fileObserver.startWatching(); diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index 2f1383b8..74f0d345 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -51,10 +51,18 @@ public class UIHelper { } private static boolean today(Date date) { + return sameDay(date,new Date(System.currentTimeMillis())); + } + + public static boolean sameDay(long timestamp1, long timestamp2) { + return sameDay(new Date(timestamp1),new Date(timestamp2)); + } + + private static boolean sameDay(Date a, Date b) { Calendar cal1 = Calendar.getInstance(); Calendar cal2 = Calendar.getInstance(); - cal1.setTime(date); - cal2.setTimeInMillis(System.currentTimeMillis()); + cal1.setTime(a); + cal2.setTime(b); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.DAY_OF_YEAR) == cal2 .get(Calendar.DAY_OF_YEAR); |