Fixed a bug into getContact from ChatRoomAdapter.java, could cause a crash with create a new chatroom. Finished ChatCreationFragment part converting. TODO: GroupInfoFragment part to convert into RecyclerView.
This commit is contained in:
parent
dcfba09cf5
commit
d595653b12
5 changed files with 207 additions and 89 deletions
|
@ -144,7 +144,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/relativeLayout">
|
android:id="@+id/relativeLayout">
|
||||||
|
|
||||||
<ListView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/contactsList"
|
android:id="@+id/contactsList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.linphone.chat;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -60,9 +62,9 @@ import java.util.List;
|
||||||
|
|
||||||
import static android.content.Context.INPUT_METHOD_SERVICE;
|
import static android.content.Context.INPUT_METHOD_SERVICE;
|
||||||
|
|
||||||
public class ChatCreationFragment extends Fragment implements View.OnClickListener, AdapterView.OnItemClickListener, ContactsUpdatedListener {
|
public class ChatCreationFragment extends Fragment implements View.OnClickListener ,SearchContactsListAdapter.ViewHolder.ClickListener, ContactsUpdatedListener {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private ListView mContactsList;
|
private RecyclerView mContactsList;
|
||||||
private LinearLayout mContactsSelectedLayout;
|
private LinearLayout mContactsSelectedLayout;
|
||||||
private HorizontalScrollView mContactsSelectLayout;
|
private HorizontalScrollView mContactsSelectLayout;
|
||||||
private ArrayList<ContactAddress> mContactsSelected;
|
private ArrayList<ContactAddress> mContactsSelected;
|
||||||
|
@ -80,6 +82,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
View view = inflater.inflate(R.layout.chat_create, container, false);
|
View view = inflater.inflate(R.layout.chat_create, container, false);
|
||||||
|
|
||||||
|
@ -124,7 +127,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
|
mContactsFetchInProgress = view.findViewById(R.id.contactsFetchInProgress);
|
||||||
mContactsFetchInProgress.setVisibility(View.VISIBLE);
|
mContactsFetchInProgress.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
mSearchAdapter = new SearchContactsListAdapter(null, mInflater, mContactsFetchInProgress);
|
mSearchAdapter = new SearchContactsListAdapter(null, mInflater, mContactsFetchInProgress, this);
|
||||||
|
|
||||||
mSearchField = view.findViewById(R.id.searchField);
|
mSearchField = view.findViewById(R.id.searchField);
|
||||||
mSearchField.addTextChangedListener(new TextWatcher() {
|
mSearchField.addTextChangedListener(new TextWatcher() {
|
||||||
|
@ -145,9 +148,11 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
mSearchAdapter.searchContacts(mSearchField.getText().toString(), mContactsList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity().getApplicationContext());
|
||||||
mContactsList.setAdapter(mSearchAdapter);
|
mContactsList.setAdapter(mSearchAdapter);
|
||||||
mContactsList.setOnItemClickListener(this);
|
|
||||||
|
mContactsList.setLayoutManager(layoutManager);
|
||||||
|
// mContactsList.setOnItemClickListener(this);
|
||||||
if (savedInstanceState != null && savedInstanceState.getStringArrayList("mContactsSelected") != null) {
|
if (savedInstanceState != null && savedInstanceState.getStringArrayList("mContactsSelected") != null) {
|
||||||
mContactsSelectedLayout.removeAllViews();
|
mContactsSelectedLayout.removeAllViews();
|
||||||
// We need to get all contacts not only sip
|
// We need to get all contacts not only sip
|
||||||
|
@ -329,7 +334,7 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
|
|
||||||
private void removeContactFromSelection(ContactAddress ca) {
|
private void removeContactFromSelection(ContactAddress ca) {
|
||||||
updateContactsClick(ca, mSearchAdapter.getContactsSelectedList());
|
updateContactsClick(ca, mSearchAdapter.getContactsSelectedList());
|
||||||
mSearchAdapter.notifyDataSetInvalidated();
|
mSearchAdapter.notifyDataSetChanged();
|
||||||
updateListSelected();
|
updateListSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,8 +417,9 @@ public class ChatCreationFragment extends Fragment implements View.OnClickListen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
public void onItemClicked(int position) {
|
||||||
ContactAddress ca = mSearchAdapter.getContacts().get(i);
|
// public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
ContactAddress ca = mSearchAdapter.getContacts().get(position);
|
||||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
ProxyConfig lpc = lc.getDefaultProxyConfig();
|
ProxyConfig lpc = lc.getDefaultProxyConfig();
|
||||||
if (lpc == null || lpc.getConferenceFactoryUri() == null) {
|
if (lpc == null || lpc.getConferenceFactoryUri() == null) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatBubbleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public ChatBubbleViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View v = LayoutInflater.from(parent.getContext())
|
View v = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(this.itemResource, parent, false);
|
.inflate(this.itemResource, parent, false);
|
||||||
ChatBubbleViewHolder VH = new ChatBubbleViewHolder(this.mContext,v, clickListener);
|
ChatBubbleViewHolder VH = new ChatBubbleViewHolder(this.mContext,v, clickListener);
|
||||||
|
@ -144,7 +144,7 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ChatBubbleViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ChatBubbleViewHolder holder, int position) {
|
||||||
final EventLog event = this.mHistory.get(position);
|
final EventLog event = this.mHistory.get(position);
|
||||||
holder.eventLayout.setVisibility(View.GONE);
|
holder.eventLayout.setVisibility(View.GONE);
|
||||||
holder.bubbleLayout.setVisibility(View.GONE);
|
holder.bubbleLayout.setVisibility(View.GONE);
|
||||||
|
|
|
@ -35,8 +35,10 @@ import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneActivity;
|
import org.linphone.activities.LinphoneActivity;
|
||||||
import org.linphone.contacts.ContactsManager;
|
import org.linphone.contacts.ContactsManager;
|
||||||
import org.linphone.contacts.LinphoneContact;
|
import org.linphone.contacts.LinphoneContact;
|
||||||
|
import org.linphone.core.Address;
|
||||||
import org.linphone.core.ChatMessage;
|
import org.linphone.core.ChatMessage;
|
||||||
import org.linphone.core.ChatRoom;
|
import org.linphone.core.ChatRoom;
|
||||||
|
import org.linphone.core.ChatRoomCapabilities;
|
||||||
import org.linphone.core.ChatRoomListenerStub;
|
import org.linphone.core.ChatRoomListenerStub;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.EventLog;
|
import org.linphone.core.EventLog;
|
||||||
|
@ -125,14 +127,31 @@ public class ChatRoomsAdapter extends SelectableAdapter<ChatRoomsAdapter.ChatRoo
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getContact(ChatRoom mRoom) {
|
public String getContact(ChatRoom mRoom) {
|
||||||
LinphoneContact contact;
|
|
||||||
contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getLastMessageInHistory().getFromAddress());
|
|
||||||
if (contact != null) {
|
|
||||||
|
|
||||||
return (contact.getFullName());
|
Address contactAddress = mRoom.getPeerAddress();
|
||||||
|
if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt()) && mRoom.getParticipants().length > 0) {
|
||||||
|
contactAddress = mRoom.getParticipants()[0].getAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||||
|
LinphoneContact contact;
|
||||||
|
if (mRoom.getParticipants().length > 0) {
|
||||||
|
contact = ContactsManager.getInstance().findContactFromAddress(mRoom.getParticipants()[0].getAddress());
|
||||||
|
if (contact != null) {
|
||||||
|
return (contact.getFullName());
|
||||||
|
} else {
|
||||||
|
return (LinphoneUtils.getAddressDisplayName(mRoom.getParticipants()[0].getAddress()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
contact = ContactsManager.getInstance().findContactFromAddress(contactAddress);
|
||||||
|
if (contact != null) {
|
||||||
|
return (contact.getFullName());
|
||||||
|
} else {
|
||||||
|
return (LinphoneUtils.getAddressDisplayName(contactAddress));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return (LinphoneUtils.getAddressDisplayName(mRoom.getLastMessageInHistory().getFromAddress()));
|
return (mRoom.getSubject());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
package org.linphone.contacts;
|
package org.linphone.contacts;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -32,6 +34,7 @@ import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphoneUtils;
|
import org.linphone.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.activities.LinphoneActivity;
|
import org.linphone.activities.LinphoneActivity;
|
||||||
|
import org.linphone.chat.ChatBubbleViewHolder;
|
||||||
import org.linphone.core.Address;
|
import org.linphone.core.Address;
|
||||||
import org.linphone.core.Factory;
|
import org.linphone.core.Factory;
|
||||||
import org.linphone.core.ProxyConfig;
|
import org.linphone.core.ProxyConfig;
|
||||||
|
@ -40,22 +43,42 @@ import org.linphone.core.SearchResult;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SearchContactsListAdapter extends BaseAdapter {
|
public class SearchContactsListAdapter extends RecyclerView.Adapter<SearchContactsListAdapter.ViewHolder> {
|
||||||
|
//public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private static final String TAG = SearchContactsListAdapter.class.getSimpleName();
|
||||||
|
|
||||||
private class ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
public TextView name;
|
public TextView name;
|
||||||
public TextView address;
|
public TextView address;
|
||||||
public ImageView linphoneContact;
|
public ImageView linphoneContact;
|
||||||
public ImageView isSelect;
|
public ImageView isSelect;
|
||||||
public ImageView avatar;
|
public ImageView avatar;
|
||||||
|
|
||||||
public ViewHolder(View view) {
|
private ClickListener listener;
|
||||||
|
|
||||||
|
public ViewHolder(View view, ClickListener listener) {
|
||||||
|
super(view);
|
||||||
name = view.findViewById(R.id.contact_name);
|
name = view.findViewById(R.id.contact_name);
|
||||||
address = view.findViewById(R.id.contact_address);
|
address = view.findViewById(R.id.contact_address);
|
||||||
linphoneContact = view.findViewById(R.id.contact_linphone);
|
linphoneContact = view.findViewById(R.id.contact_linphone);
|
||||||
isSelect = view.findViewById(R.id.contact_is_select);
|
isSelect = view.findViewById(R.id.contact_is_select);
|
||||||
avatar = view.findViewById(R.id.contact_picture);
|
avatar = view.findViewById(R.id.contact_picture);
|
||||||
|
this.listener=listener;
|
||||||
|
view.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onItemClicked(getAdapterPosition());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public interface ClickListener {
|
||||||
|
public void onItemClicked(int position);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ContactAddress> contacts;
|
private List<ContactAddress> contacts;
|
||||||
|
@ -63,7 +86,8 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private boolean mOnlySipContact = false;
|
private boolean mOnlySipContact = false;
|
||||||
private View.OnClickListener listener;
|
private ViewHolder.ClickListener listener;
|
||||||
|
// private View.OnClickListener listener;
|
||||||
|
|
||||||
public List<ContactAddress> getContacts() {
|
public List<ContactAddress> getContacts() {
|
||||||
return contacts;
|
return contacts;
|
||||||
|
@ -73,17 +97,82 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
mOnlySipContact = enable;
|
mOnlySipContact = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListener(View.OnClickListener listener) {
|
public void setListener(ViewHolder.ClickListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchContactsListAdapter(List<ContactAddress> contactsList, LayoutInflater inflater, ProgressBar pB) {
|
public SearchContactsListAdapter(List<ContactAddress> contactsList, LayoutInflater inflater, ProgressBar pB, ViewHolder.ClickListener clickListener) {
|
||||||
|
this.listener=clickListener;
|
||||||
mInflater = inflater;
|
mInflater = inflater;
|
||||||
progressBar = pB;
|
progressBar = pB;
|
||||||
setContactsSelectedList(null);
|
setContactsSelectedList(null);
|
||||||
setContactsList(contactsList);
|
setContactsList(contactsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_contact_cell, parent, false);
|
||||||
|
return new ViewHolder(v, listener);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
|
ContactAddress contact = getItem(position);
|
||||||
|
final String a = (contact.getAddressAsDisplayableString().isEmpty()) ? contact.getPhoneNumber() : contact.getAddressAsDisplayableString();
|
||||||
|
LinphoneContact c = contact.getContact();
|
||||||
|
|
||||||
|
holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
|
if (c != null && c.hasPhoto()) {
|
||||||
|
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.avatar, c.getThumbnailUri());
|
||||||
|
}
|
||||||
|
|
||||||
|
String address = contact.getAddressAsDisplayableString();
|
||||||
|
if (c != null && c.getFullName() != null) {
|
||||||
|
if (address == null)
|
||||||
|
address = c.getPresenceModelForUriOrTel(a);
|
||||||
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
|
holder.name.setText(c.getFullName());
|
||||||
|
} else if (contact.getAddress() != null) {
|
||||||
|
if (contact.getAddress().getUsername() != null) {
|
||||||
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
|
holder.name.setText(contact.getAddress().getUsername());
|
||||||
|
} else if (contact.getAddress().getDisplayName() != null) {
|
||||||
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
|
holder.name.setText(contact.getAddress().getDisplayName());
|
||||||
|
}
|
||||||
|
} else if (address != null) {
|
||||||
|
Address tmpAddr = Factory.instance().createAddress(address);
|
||||||
|
holder.name.setVisibility(View.VISIBLE);
|
||||||
|
holder.name.setText((tmpAddr.getDisplayName() != null) ? tmpAddr.getDisplayName() : tmpAddr.getUsername()) ;
|
||||||
|
} else {
|
||||||
|
holder.name.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
holder.address.setText(a);
|
||||||
|
if (holder.linphoneContact != null) {
|
||||||
|
if (contact.isLinphoneContact() && c != null && c.isInFriendList() && address != null) {
|
||||||
|
holder.linphoneContact.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.linphoneContact.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (holder.isSelect != null) {
|
||||||
|
if (contactIsSelected(contact)) {
|
||||||
|
holder.isSelect.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.isSelect.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// view.setTag(R.id.contact_search_name, address != null ? address : a);
|
||||||
|
// if (listener != null)
|
||||||
|
// view.setOnClickListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean contactIsSelected(ContactAddress ca) {
|
private boolean contactIsSelected(ContactAddress ca) {
|
||||||
for (ContactAddress c : contactsSelected) {
|
for (ContactAddress c : contactsSelected) {
|
||||||
Address addr = c.getAddress();
|
Address addr = c.getAddress();
|
||||||
|
@ -160,11 +249,15 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
return contacts.get(position);
|
return contacts.get(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getItemId(int position) {
|
|
||||||
return position;
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return contacts.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void searchContacts(String search, ListView resultContactsSearch) {
|
public void searchContacts(String search, RecyclerView resultContactsSearch) {
|
||||||
|
// public void searchContacts(String search, ListView resultContactsSearch) {
|
||||||
List<ContactAddress> result = new ArrayList<>();
|
List<ContactAddress> result = new ArrayList<>();
|
||||||
|
|
||||||
String domain = "";
|
String domain = "";
|
||||||
|
@ -206,69 +299,69 @@ public class SearchContactsListAdapter extends BaseAdapter {
|
||||||
this.notifyDataSetChanged();
|
this.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
// public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
View view;
|
// View view;
|
||||||
ViewHolder holder;
|
// ViewHolder holder;
|
||||||
|
//
|
||||||
if (convertView != null) {
|
// if (convertView != null) {
|
||||||
view = convertView;
|
// view = convertView;
|
||||||
holder = (ViewHolder) view.getTag();
|
// holder = (ViewHolder) view.getTag();
|
||||||
} else {
|
// } else {
|
||||||
view = mInflater.inflate(R.layout.search_contact_cell, parent, false);
|
// view = mInflater.inflate(R.layout.search_contact_cell, parent, false);
|
||||||
holder = new ViewHolder(view);
|
// holder = new ViewHolder(view);
|
||||||
view.setTag(holder);
|
// view.setTag(holder);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ContactAddress contact = getItem(position);
|
// ContactAddress contact = getItem(position);
|
||||||
final String a = (contact.getAddressAsDisplayableString().isEmpty()) ? contact.getPhoneNumber() : contact.getAddressAsDisplayableString();
|
// final String a = (contact.getAddressAsDisplayableString().isEmpty()) ? contact.getPhoneNumber() : contact.getAddressAsDisplayableString();
|
||||||
LinphoneContact c = contact.getContact();
|
// LinphoneContact c = contact.getContact();
|
||||||
|
//
|
||||||
holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
// holder.avatar.setImageBitmap(ContactsManager.getInstance().getDefaultAvatarBitmap());
|
||||||
if (c != null && c.hasPhoto()) {
|
// if (c != null && c.hasPhoto()) {
|
||||||
LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.avatar, c.getThumbnailUri());
|
// LinphoneUtils.setThumbnailPictureFromUri(LinphoneActivity.instance(), holder.avatar, c.getThumbnailUri());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
String address = contact.getAddressAsDisplayableString();
|
// String address = contact.getAddressAsDisplayableString();
|
||||||
if (c != null && c.getFullName() != null) {
|
// if (c != null && c.getFullName() != null) {
|
||||||
if (address == null)
|
// if (address == null)
|
||||||
address = c.getPresenceModelForUriOrTel(a);
|
// address = c.getPresenceModelForUriOrTel(a);
|
||||||
holder.name.setVisibility(View.VISIBLE);
|
// holder.name.setVisibility(View.VISIBLE);
|
||||||
holder.name.setText(c.getFullName());
|
// holder.name.setText(c.getFullName());
|
||||||
} else if (contact.getAddress() != null) {
|
// } else if (contact.getAddress() != null) {
|
||||||
if (contact.getAddress().getUsername() != null) {
|
// if (contact.getAddress().getUsername() != null) {
|
||||||
holder.name.setVisibility(View.VISIBLE);
|
// holder.name.setVisibility(View.VISIBLE);
|
||||||
holder.name.setText(contact.getAddress().getUsername());
|
// holder.name.setText(contact.getAddress().getUsername());
|
||||||
} else if (contact.getAddress().getDisplayName() != null) {
|
// } else if (contact.getAddress().getDisplayName() != null) {
|
||||||
holder.name.setVisibility(View.VISIBLE);
|
// holder.name.setVisibility(View.VISIBLE);
|
||||||
holder.name.setText(contact.getAddress().getDisplayName());
|
// holder.name.setText(contact.getAddress().getDisplayName());
|
||||||
}
|
// }
|
||||||
} else if (address != null) {
|
// } else if (address != null) {
|
||||||
Address tmpAddr = Factory.instance().createAddress(address);
|
// Address tmpAddr = Factory.instance().createAddress(address);
|
||||||
holder.name.setVisibility(View.VISIBLE);
|
// holder.name.setVisibility(View.VISIBLE);
|
||||||
holder.name.setText((tmpAddr.getDisplayName() != null) ? tmpAddr.getDisplayName() : tmpAddr.getUsername()) ;
|
// holder.name.setText((tmpAddr.getDisplayName() != null) ? tmpAddr.getDisplayName() : tmpAddr.getUsername()) ;
|
||||||
} else {
|
// } else {
|
||||||
holder.name.setVisibility(View.GONE);
|
// holder.name.setVisibility(View.GONE);
|
||||||
}
|
// }
|
||||||
holder.address.setText(a);
|
// holder.address.setText(a);
|
||||||
if (holder.linphoneContact != null) {
|
// if (holder.linphoneContact != null) {
|
||||||
if (contact.isLinphoneContact() && c != null && c.isInFriendList() && address != null) {
|
// if (contact.isLinphoneContact() && c != null && c.isInFriendList() && address != null) {
|
||||||
holder.linphoneContact.setVisibility(View.VISIBLE);
|
// holder.linphoneContact.setVisibility(View.VISIBLE);
|
||||||
} else {
|
// } else {
|
||||||
holder.linphoneContact.setVisibility(View.GONE);
|
// holder.linphoneContact.setVisibility(View.GONE);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (holder.isSelect != null) {
|
// if (holder.isSelect != null) {
|
||||||
if (contactIsSelected(contact)) {
|
// if (contactIsSelected(contact)) {
|
||||||
holder.isSelect.setVisibility(View.VISIBLE);
|
// holder.isSelect.setVisibility(View.VISIBLE);
|
||||||
} else {
|
// } else {
|
||||||
holder.isSelect.setVisibility(View.INVISIBLE);
|
// holder.isSelect.setVisibility(View.INVISIBLE);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
view.setTag(R.id.contact_search_name, address != null ? address : a);
|
// view.setTag(R.id.contact_search_name, address != null ? address : a);
|
||||||
if (listener != null)
|
// if (listener != null)
|
||||||
view.setOnClickListener(listener);
|
// view.setOnClickListener(listener);
|
||||||
return view;
|
// return view;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue