Added spinner on chat room deletion
This commit is contained in:
parent
6f5f61fc20
commit
5d9b0fc5ca
2 changed files with 100 additions and 66 deletions
|
@ -1,71 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorH"
|
||||
android:orientation="vertical" >
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/top_bar"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/colorF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/new_discussion"
|
||||
android:src="@drawable/chat_add"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_new_discussion"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_in_call"
|
||||
android:src="@drawable/call_back"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_back_call"
|
||||
android:visibility="invisible"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit"
|
||||
android:src="@drawable/edit_list_button"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_edit_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/edit_list"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/chatList"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@color/colorE"
|
||||
android:cacheColorHint="@color/transparent"
|
||||
android:dividerHeight="1dp" />
|
||||
android:background="@color/colorH"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noChatHistory"
|
||||
android:text="@string/no_chat_history"
|
||||
style="@style/font6"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/top_bar"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/colorF"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp">
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/new_discussion"
|
||||
android:src="@drawable/chat_add"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_new_discussion"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_in_call"
|
||||
android:src="@drawable/call_back"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_back_call"
|
||||
android:visibility="invisible"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.4"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit"
|
||||
android:src="@drawable/edit_list_button"
|
||||
android:background="@drawable/toolbar_button"
|
||||
android:contentDescription="@string/content_description_edit_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.2"
|
||||
android:padding="15dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/edit_list"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/chatList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@color/colorE"
|
||||
android:cacheColorHint="@color/transparent"
|
||||
android:dividerHeight="1dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noChatHistory"
|
||||
android:text="@string/no_chat_history"
|
||||
style="@style/font6"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/wait_layout" android:id="@+id/waitScreen"/>
|
||||
|
||||
</RelativeLayout>
|
|
@ -28,9 +28,12 @@ import android.widget.AdapterView;
|
|||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.linphone.contacts.ContactsManager;
|
||||
import org.linphone.core.ChatRoomListenerStub;
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.ui.ListSelectionHelper;
|
||||
import org.linphone.contacts.ContactsUpdatedListener;
|
||||
import org.linphone.fragments.FragmentsAvailable;
|
||||
|
@ -53,6 +56,8 @@ public class ChatListFragment extends Fragment implements OnItemClickListener, C
|
|||
private ChatRoomsAdapter mChatRoomsAdapter;
|
||||
private CoreListenerStub mListener;
|
||||
private ListSelectionHelper mSelectionHelper;
|
||||
private RelativeLayout mWaitLayout;
|
||||
private int mChatRoomDeletionPendingCount;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -63,6 +68,9 @@ public class ChatListFragment extends Fragment implements OnItemClickListener, C
|
|||
mChatRoomsAdapter = new ChatRoomsAdapter(getActivity(), mSelectionHelper, mInflater);
|
||||
mSelectionHelper.setAdapter(mChatRoomsAdapter);
|
||||
|
||||
mWaitLayout = view.findViewById(R.id.waitScreen);
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
|
||||
mChatRoomsList = view.findViewById(R.id.chatList);
|
||||
mChatRoomsList.setAdapter(mChatRoomsAdapter);
|
||||
mChatRoomsList.setOnItemClickListener(this);
|
||||
|
@ -145,9 +153,27 @@ public class ChatListFragment extends Fragment implements OnItemClickListener, C
|
|||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
for (Object obj : objectsToDelete) {
|
||||
ChatRoom room = (ChatRoom)obj;
|
||||
mChatRoomDeletionPendingCount = objectsToDelete.length;
|
||||
room.setListener(new ChatRoomListenerStub() {
|
||||
@Override
|
||||
public void onStateChanged(ChatRoom room, ChatRoom.State state) {
|
||||
super.onStateChanged(room, state);
|
||||
Log.e("Chat Room State changed " + state.toString());
|
||||
if (state == ChatRoom.State.Deleted || state == ChatRoom.State.TerminationFailed) {
|
||||
mChatRoomDeletionPendingCount -= 1;
|
||||
|
||||
if (mChatRoomDeletionPendingCount == 0) {
|
||||
mWaitLayout.setVisibility(View.GONE);
|
||||
refreshChatRoomsList();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
lc.deleteChatRoom(room);
|
||||
}
|
||||
refreshChatRoomsList();
|
||||
if (mChatRoomDeletionPendingCount > 0) {
|
||||
mWaitLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue