Do not refresh contacts when not required
This commit is contained in:
parent
8d65fab06c
commit
4193cefa60
4 changed files with 15 additions and 17 deletions
|
@ -104,7 +104,6 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
|
||||
public void changeDisplayedContact(LinphoneContact newContact) {
|
||||
contact = newContact;
|
||||
//contact.refresh();
|
||||
displayContact(inflater, view);
|
||||
}
|
||||
|
||||
|
@ -214,7 +213,6 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
|
||||
LinphoneActivity.instance().hideTabBar(false);
|
||||
}
|
||||
contact.refresh();
|
||||
if (contact.getFullName() == null || contact.getFullName().equals("")) {
|
||||
//Contact has been deleted, return
|
||||
LinphoneActivity.instance().displayContacts(false);
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ContactsManager {
|
|||
|
||||
for (LinphoneContact c: getContacts()) {
|
||||
for (LinphoneNumberOrAddress noa: c.getNumbersOrAddresses()) {
|
||||
if ((noa.isSIPAddress() && (noa.getValue().equals(sipUri) || noa.getValue().equals(sipUri.substring(4)))) || (!noa.isSIPAddress() && noa.getValue().equals(username))) {
|
||||
if ((noa.isSIPAddress() && noa.getValue().equals(sipUri)) || (!noa.isSIPAddress() && noa.getValue().equals(username))) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class ContactsManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
public synchronized void prepareContactsInBackground() {
|
||||
public synchronized void fetchContacts() {
|
||||
contacts = new ArrayList<LinphoneContact>();
|
||||
|
||||
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
||||
|
@ -137,15 +137,14 @@ public class ContactsManager {
|
|||
|
||||
Cursor c = Compatibility.getContactsCursor(contentResolver, null);
|
||||
if (c != null) {
|
||||
c.moveToFirst();
|
||||
do {
|
||||
while (c.moveToNext()) {
|
||||
String id = c.getString(c.getColumnIndex(Data.CONTACT_ID));
|
||||
LinphoneContact contact = new LinphoneContact();
|
||||
contact.setAndroidId(id);
|
||||
contact.refresh();
|
||||
contacts.add(contact);
|
||||
}
|
||||
while (c.moveToNext());
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,6 +125,7 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
private RelativeLayout sideMenuContent, quitLayout, defaultAccount;
|
||||
private ListView accountsList, sideMenuItemList;
|
||||
private ImageView menu;
|
||||
private boolean fetchedContactsOnce = false;
|
||||
|
||||
static final boolean isInstanciated() {
|
||||
return instance != null;
|
||||
|
@ -1233,9 +1234,10 @@ public class LinphoneActivity extends Activity implements OnClickListener, Conta
|
|||
startService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||
}
|
||||
|
||||
if (getPackageManager().checkPermission(Manifest.permission.READ_CONTACTS, getPackageName()) == PackageManager.PERMISSION_GRANTED){
|
||||
if (getPackageManager().checkPermission(Manifest.permission.READ_CONTACTS, getPackageName()) == PackageManager.PERMISSION_GRANTED && !fetchedContactsOnce) {
|
||||
ContactsManager.getInstance().enableContactsAccess();
|
||||
ContactsManager.getInstance().prepareContactsInBackground();
|
||||
ContactsManager.getInstance().fetchContacts();
|
||||
fetchedContactsOnce = true;
|
||||
} else {
|
||||
checkAndRequestPermission(Manifest.permission.READ_CONTACTS, PERMISSIONS_REQUEST_READ_CONTACTS);
|
||||
}
|
||||
|
|
|
@ -214,25 +214,24 @@ public final class LinphoneUtils {
|
|||
}
|
||||
|
||||
|
||||
public static void setImagePictureFromUri(Context c, ImageView view, Uri uri, Uri tUri) {
|
||||
if (uri == null) {
|
||||
public static void setImagePictureFromUri(Context c, ImageView view, Uri pictureUri, Uri thumbnailUri) {
|
||||
if (pictureUri == null) {
|
||||
view.setImageResource(R.drawable.avatar);
|
||||
return;
|
||||
}
|
||||
if (uri.getScheme().startsWith("http")) {
|
||||
Bitmap bm = downloadBitmap(uri);
|
||||
if (pictureUri.getScheme().startsWith("http")) {
|
||||
Bitmap bm = downloadBitmap(pictureUri);
|
||||
if (bm == null) view.setImageResource(R.drawable.avatar);
|
||||
view.setImageBitmap(bm);
|
||||
} else {
|
||||
Bitmap bm = null;
|
||||
try {
|
||||
bm = MediaStore.Images.Media.getBitmap(c.getContentResolver(),uri);
|
||||
bm = MediaStore.Images.Media.getBitmap(c.getContentResolver(), pictureUri);
|
||||
} catch (IOException e) {
|
||||
if (tUri != null) {
|
||||
if (thumbnailUri != null) {
|
||||
try {
|
||||
bm = MediaStore.Images.Media.getBitmap(c.getContentResolver(),tUri);
|
||||
bm = MediaStore.Images.Media.getBitmap(c.getContentResolver(), thumbnailUri);
|
||||
} catch (IOException ie) {
|
||||
view.setImageURI(tUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue