Fixed remaining setListener methods on ChatRoom
This commit is contained in:
parent
984c8aca2a
commit
1cc13877b0
2 changed files with 23 additions and 20 deletions
|
@ -60,6 +60,7 @@ public class ChatListFragment extends Fragment implements OnItemClickListener, C
|
||||||
private ListSelectionHelper mSelectionHelper;
|
private ListSelectionHelper mSelectionHelper;
|
||||||
private RelativeLayout mWaitLayout;
|
private RelativeLayout mWaitLayout;
|
||||||
private int mChatRoomDeletionPendingCount;
|
private int mChatRoomDeletionPendingCount;
|
||||||
|
private ChatRoomListenerStub mChatRoomListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -111,6 +112,25 @@ public class ChatListFragment extends Fragment implements OnItemClickListener, C
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mChatRoomListener = new ChatRoomListenerStub() {
|
||||||
|
@Override
|
||||||
|
public void onStateChanged(ChatRoom room, ChatRoom.State state) {
|
||||||
|
super.onStateChanged(room, state);
|
||||||
|
if (state == ChatRoom.State.Deleted || state == ChatRoom.State.TerminationFailed) {
|
||||||
|
mChatRoomDeletionPendingCount -= 1;
|
||||||
|
|
||||||
|
if (state == ChatRoom.State.TerminationFailed) {
|
||||||
|
//TODO error message
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mChatRoomDeletionPendingCount == 0) {
|
||||||
|
mWaitLayout.setVisibility(View.GONE);
|
||||||
|
refreshChatRoomsList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,24 +193,7 @@ public class ChatListFragment extends Fragment implements OnItemClickListener, C
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
room.setListener(new ChatRoomListenerStub() {
|
room.addListener(mChatRoomListener);
|
||||||
@Override
|
|
||||||
public void onStateChanged(ChatRoom room, ChatRoom.State state) {
|
|
||||||
super.onStateChanged(room, state);
|
|
||||||
if (state == ChatRoom.State.Deleted || state == ChatRoom.State.TerminationFailed) {
|
|
||||||
mChatRoomDeletionPendingCount -= 1;
|
|
||||||
|
|
||||||
if (state == ChatRoom.State.TerminationFailed) {
|
|
||||||
//TODO error message
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mChatRoomDeletionPendingCount == 0) {
|
|
||||||
mWaitLayout.setVisibility(View.GONE);
|
|
||||||
refreshChatRoomsList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
lc.deleteChatRoom(room);
|
lc.deleteChatRoom(room);
|
||||||
}
|
}
|
||||||
if (mChatRoomDeletionPendingCount > 0) {
|
if (mChatRoomDeletionPendingCount > 0) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
for (ChatRoom room : mRooms) {
|
for (ChatRoom room : mRooms) {
|
||||||
room.setListener(null);
|
room.removeListener(mListener);
|
||||||
}
|
}
|
||||||
mRooms.clear();
|
mRooms.clear();
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ public class ChatRoomsAdapter extends ListSelectionAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatRoom.hasCapability(ChatRoomCapabilities.Conference.toInt()) && chatRoom.getState() == ChatRoom.State.Created) { // Only set for state Created otherwise it will conflict with removal listener
|
if (chatRoom.hasCapability(ChatRoomCapabilities.Conference.toInt()) && chatRoom.getState() == ChatRoom.State.Created) { // Only set for state Created otherwise it will conflict with removal listener
|
||||||
chatRoom.setListener(mListener);
|
chatRoom.addListener(mListener);
|
||||||
chatRoom.setUserData(holder);
|
chatRoom.setUserData(holder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue