Invalidate history & chat lists when contacts are udpated
This commit is contained in:
parent
34e6b15e32
commit
502a70f128
3 changed files with 31 additions and 5 deletions
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.HistoryListFragment.CallHistoryAdapter;
|
||||
import org.linphone.core.LinphoneAddress;
|
||||
import org.linphone.core.LinphoneChatMessage;
|
||||
import org.linphone.core.LinphoneChatRoom;
|
||||
|
@ -55,7 +56,7 @@ import android.widget.TextView;
|
|||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class ChatListFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
||||
public class ChatListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
||||
private LayoutInflater mInflater;
|
||||
private List<String> mConversations;
|
||||
private ListView chatList;
|
||||
|
@ -193,6 +194,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
ContactsManager.addContactsListener(this);
|
||||
|
||||
if (LinphoneManager.getLc().getCallsNb() > 0) {
|
||||
backInCall.setVisibility(View.VISIBLE);
|
||||
|
@ -219,9 +221,15 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
if (lc != null) {
|
||||
lc.removeListener(mListener);
|
||||
}
|
||||
ContactsManager.removeContactsListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactsUpdated() {
|
||||
hideAndDisplayMessageIfNoChat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
|
|
|
@ -52,7 +52,7 @@ import android.widget.TextView;
|
|||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
public class HistoryListFragment extends Fragment implements OnClickListener, OnItemClickListener {
|
||||
public class HistoryListFragment extends Fragment implements OnClickListener, OnItemClickListener, ContactsUpdatedListener {
|
||||
private ListView historyList;
|
||||
private LayoutInflater mInflater;
|
||||
private TextView noCallHistory, noMissedCallHistory;
|
||||
|
@ -198,6 +198,7 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
ContactsManager.addContactsListener(this);
|
||||
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.HISTORY_LIST);
|
||||
|
@ -212,6 +213,17 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
ContactsManager.removeContactsListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContactsUpdated() {
|
||||
historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
@ -338,7 +350,9 @@ public class HistoryListFragment extends Fragment implements OnClickListener, On
|
|||
|
||||
class CallHistoryAdapter extends BaseAdapter {
|
||||
CallHistoryAdapter(Context aContext) {
|
||||
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return mLogs.size();
|
||||
}
|
||||
|
|
|
@ -400,7 +400,11 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
|
|||
if (lc.findFriendByAddress(friend.getAddress().asString()) == null) {
|
||||
try {
|
||||
lc.addFriend(friend);
|
||||
if (!ContactsManager.getInstance().hasContactsAccess()) {
|
||||
// This refresh is only needed if app has no contacts permission to refresh the list of LinphoneFriends.
|
||||
// Otherwise contacts will be refreshed due to changes in native contact and the handler in ContactsManager
|
||||
ContactsManager.getInstance().fetchContactsAsync();
|
||||
}
|
||||
} catch (LinphoneCoreException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue