mirror of
https://github.com/etesync/android
synced 2025-02-16 17:42:03 +00:00
Read non-high-res photos, too (fixes #53 again); remove stale connection check because RetryStrategy should be enough
This commit is contained in:
parent
f298d9dcb6
commit
b8df91e12d
@ -306,22 +306,31 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void populatePhoto(Contact c) throws RemoteException {
|
protected void populatePhoto(Contact c) throws RemoteException {
|
||||||
Uri photoUri = Uri.withAppendedPath(
|
@Cleanup Cursor cursor = providerClient.query(dataURI(),
|
||||||
ContentUris.withAppendedId(RawContacts.CONTENT_URI, c.getLocalID()),
|
new String[] { Photo.PHOTO_FILE_ID, Photo.PHOTO },
|
||||||
RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
|
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
try {
|
new String[] { String.valueOf(c.getLocalID()), Photo.CONTENT_ITEM_TYPE }, null);
|
||||||
@Cleanup AssetFileDescriptor fd = providerClient.openAssetFile(photoUri, "r");
|
if (cursor != null && cursor.moveToNext()) {
|
||||||
@Cleanup InputStream is = fd.createInputStream();
|
if (!cursor.isNull(0)) {
|
||||||
c.setPhoto(IOUtils.toByteArray(is));
|
Uri photoUri = Uri.withAppendedPath(
|
||||||
} catch(IOException ex) {
|
ContentUris.withAppendedId(RawContacts.CONTENT_URI, c.getLocalID()),
|
||||||
Log.v(TAG, "Couldn't read contact photo", ex);
|
RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
|
||||||
|
try {
|
||||||
|
@Cleanup AssetFileDescriptor fd = providerClient.openAssetFile(photoUri, "r");
|
||||||
|
@Cleanup InputStream is = fd.createInputStream();
|
||||||
|
c.setPhoto(IOUtils.toByteArray(is));
|
||||||
|
} catch(IOException ex) {
|
||||||
|
Log.w(TAG, "Couldn't read high-res contact photo", ex);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
c.setPhoto(cursor.getBlob(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateOrganization(Contact c) throws RemoteException {
|
protected void populateOrganization(Contact c) throws RemoteException {
|
||||||
@Cleanup Cursor cursor = providerClient.query(dataURI(),
|
@Cleanup Cursor cursor = providerClient.query(dataURI(),
|
||||||
new String[] { Organization.COMPANY, Organization.DEPARTMENT, Organization.TITLE, Organization.JOB_DESCRIPTION },
|
new String[] { Organization.COMPANY, Organization.DEPARTMENT, Organization.TITLE, Organization.JOB_DESCRIPTION },
|
||||||
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
Organization.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
new String[] { String.valueOf(c.getLocalID()), Organization.CONTENT_ITEM_TYPE }, null);
|
new String[] { String.valueOf(c.getLocalID()), Organization.CONTENT_ITEM_TYPE }, null);
|
||||||
if (cursor != null && cursor.moveToNext()) {
|
if (cursor != null && cursor.moveToNext()) {
|
||||||
String company = cursor.getString(0),
|
String company = cursor.getString(0),
|
||||||
@ -345,7 +354,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
|
|
||||||
protected void populateIMPPs(Contact c) throws RemoteException {
|
protected void populateIMPPs(Contact c) throws RemoteException {
|
||||||
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Im.DATA, Im.TYPE, Im.LABEL, Im.PROTOCOL, Im.CUSTOM_PROTOCOL },
|
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Im.DATA, Im.TYPE, Im.LABEL, Im.PROTOCOL, Im.CUSTOM_PROTOCOL },
|
||||||
Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
Im.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
new String[] { String.valueOf(c.getLocalID()), Im.CONTENT_ITEM_TYPE }, null);
|
new String[] { String.valueOf(c.getLocalID()), Im.CONTENT_ITEM_TYPE }, null);
|
||||||
while (cursor != null && cursor.moveToNext()) {
|
while (cursor != null && cursor.moveToNext()) {
|
||||||
String handle = cursor.getString(0);
|
String handle = cursor.getString(0);
|
||||||
@ -411,7 +420,7 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
|
|
||||||
protected void populateNote(Contact c) throws RemoteException {
|
protected void populateNote(Contact c) throws RemoteException {
|
||||||
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Note.NOTE },
|
@Cleanup Cursor cursor = providerClient.query(dataURI(), new String[] { Note.NOTE },
|
||||||
Website.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
Note.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
new String[] { String.valueOf(c.getLocalID()), Note.CONTENT_ITEM_TYPE }, null);
|
new String[] { String.valueOf(c.getLocalID()), Note.CONTENT_ITEM_TYPE }, null);
|
||||||
if (cursor != null && cursor.moveToNext())
|
if (cursor != null && cursor.moveToNext())
|
||||||
c.setNote(cursor.getString(0));
|
c.setNote(cursor.getString(0));
|
||||||
@ -485,9 +494,9 @@ public class LocalAddressBook extends LocalCollection<Contact> {
|
|||||||
|
|
||||||
protected void populateSipAddress(Contact c) throws RemoteException {
|
protected void populateSipAddress(Contact c) throws RemoteException {
|
||||||
@Cleanup Cursor cursor = providerClient.query(dataURI(),
|
@Cleanup Cursor cursor = providerClient.query(dataURI(),
|
||||||
new String[] { CommonDataKinds.SipAddress.SIP_ADDRESS, CommonDataKinds.SipAddress.TYPE, CommonDataKinds.SipAddress.LABEL },
|
new String[] { SipAddress.SIP_ADDRESS, SipAddress.TYPE, SipAddress.LABEL },
|
||||||
Website.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
SipAddress.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
|
||||||
new String[] { String.valueOf(c.getLocalID()), CommonDataKinds.SipAddress.CONTENT_ITEM_TYPE }, null);
|
new String[] { String.valueOf(c.getLocalID()), SipAddress.CONTENT_ITEM_TYPE }, null);
|
||||||
if (cursor != null && cursor.moveToNext()) {
|
if (cursor != null && cursor.moveToNext()) {
|
||||||
Impp impp = new Impp("sip:" + cursor.getString(0));
|
Impp impp = new Impp("sip:" + cursor.getString(0));
|
||||||
switch (cursor.getInt(1)) {
|
switch (cursor.getInt(1)) {
|
||||||
|
@ -82,7 +82,9 @@ public class SyncManager {
|
|||||||
remotelyAdded.add(remoteResource);
|
remotelyAdded.add(remoteResource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try { Thread.sleep(2000); } catch (InterruptedException e) { }
|
||||||
|
|
||||||
// PHASE 3: pull remote changes from server
|
// PHASE 3: pull remote changes from server
|
||||||
syncResult.stats.numInserts = pullNew(remotelyAdded.toArray(new Resource[0]));
|
syncResult.stats.numInserts = pullNew(remotelyAdded.toArray(new Resource[0]));
|
||||||
syncResult.stats.numUpdates = pullChanged(remotelyUpdated.toArray(new Resource[0]));
|
syncResult.stats.numUpdates = pullChanged(remotelyUpdated.toArray(new Resource[0]));
|
||||||
|
@ -36,7 +36,7 @@ public class DavHttpClient {
|
|||||||
defaultRqConfig = RequestConfig.copy(RequestConfig.DEFAULT)
|
defaultRqConfig = RequestConfig.copy(RequestConfig.DEFAULT)
|
||||||
.setConnectTimeout(20*1000)
|
.setConnectTimeout(20*1000)
|
||||||
.setSocketTimeout(20*1000)
|
.setSocketTimeout(20*1000)
|
||||||
.setStaleConnectionCheckEnabled(true)
|
.setStaleConnectionCheckEnabled(false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// enable logging
|
// enable logging
|
||||||
|
Loading…
Reference in New Issue
Block a user