Fixed no contacts label not visible and spinner always visible if no contacts
This commit is contained in:
parent
4ed7ea0fa5
commit
4d31d79c8d
2 changed files with 19 additions and 11 deletions
|
@ -128,7 +128,16 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
newContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0);
|
newContact.setEnabled(LinphoneManager.getLc().getCallsNb() == 0);
|
||||||
allContacts.setEnabled(onlyDisplayLinphoneContacts);
|
allContacts.setEnabled(onlyDisplayLinphoneContacts);
|
||||||
linphoneContacts.setEnabled(!allContacts.isEnabled());
|
linphoneContacts.setEnabled(!allContacts.isEnabled());
|
||||||
contactsFetchInProgress.setVisibility(View.VISIBLE);
|
|
||||||
|
if (!ContactsManager.getInstance().contactsFetchedOnce()) {
|
||||||
|
contactsFetchInProgress.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
if (!onlyDisplayLinphoneContacts && ContactsManager.getInstance().getContacts().size() == 0) {
|
||||||
|
noContact.setVisibility(View.VISIBLE);
|
||||||
|
} else if (onlyDisplayLinphoneContacts && ContactsManager.getInstance().getSIPContacts().size() == 0) {
|
||||||
|
noSipContact.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clearSearchField = view.findViewById(R.id.clearSearchField);
|
clearSearchField = view.findViewById(R.id.clearSearchField);
|
||||||
clearSearchField.setOnClickListener(new View.OnClickListener() {
|
clearSearchField.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -165,9 +174,6 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
dividerItemDecoration.setDrawable(getActivity().getResources().getDrawable(R.drawable.divider));
|
dividerItemDecoration.setDrawable(getActivity().getResources().getDrawable(R.drawable.divider));
|
||||||
contactsList.addItemDecoration(dividerItemDecoration);
|
contactsList.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
contactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
|
|
||||||
contactsFetchInProgress.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,9 +255,12 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
|
|
||||||
mContactAdapter.notifyDataSetChanged();
|
mContactAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
if (mContactAdapter.getItemCount() > 0) {
|
if (!onlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) {
|
||||||
contactsFetchInProgress.setVisibility(View.GONE);
|
noContact.setVisibility(View.VISIBLE);
|
||||||
|
} else if (onlyDisplayLinphoneContacts && mContactAdapter.getItemCount() == 0) {
|
||||||
|
noSipContact.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactsManager.getInstance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
|
ContactsManager.getInstance().setLinphoneContactsPrefered(onlyDisplayLinphoneContacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,10 +325,6 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
|
||||||
sipAddressToAdd = null;
|
sipAddressToAdd = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchField != null && searchField.getText().toString().length() > 0) {
|
|
||||||
if (contactsFetchInProgress != null) contactsFetchInProgress.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS_LIST);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACTS_LIST);
|
||||||
LinphoneActivity.instance().hideTabBar(false);
|
LinphoneActivity.instance().hideTabBar(false);
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private HashMap<String, LinphoneContact> mAndroidContactsCache;
|
private HashMap<String, LinphoneContact> mAndroidContactsCache;
|
||||||
private Bitmap defaultAvatar;
|
private Bitmap defaultAvatar;
|
||||||
|
private boolean mContactsFetchedOnce = false;
|
||||||
|
|
||||||
private static ArrayList<ContactsUpdatedListener> contactsUpdatedListeners;
|
private static ArrayList<ContactsUpdatedListener> contactsUpdatedListeners;
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contactsFetchedOnce() {
|
public boolean contactsFetchedOnce() {
|
||||||
return mContacts.size() > 0;
|
return mContactsFetchedOnce;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap getDefaultAvatarBitmap() {
|
public Bitmap getDefaultAvatarBitmap() {
|
||||||
|
@ -425,6 +426,8 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor c) {
|
public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor c) {
|
||||||
|
mContactsFetchedOnce = true;
|
||||||
|
|
||||||
Date contactsTime = new Date();
|
Date contactsTime = new Date();
|
||||||
List<LinphoneContact> contacts = new ArrayList<>();
|
List<LinphoneContact> contacts = new ArrayList<>();
|
||||||
List<LinphoneContact> sipContacts = new ArrayList<>();
|
List<LinphoneContact> sipContacts = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in a new issue