mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Add progressbar to conversations list fragment
This commit is contained in:
parent
7e451d73a9
commit
2af59a19ed
@ -13,6 +13,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.communiquons.android.comunic.client.MainActivity;
|
import org.communiquons.android.comunic.client.MainActivity;
|
||||||
@ -74,6 +75,11 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
|
|||||||
*/
|
*/
|
||||||
private ConversationsListAdapter conversationsListAdapter;
|
private ConversationsListAdapter conversationsListAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loading progress bar
|
||||||
|
*/
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
|
||||||
@ -96,6 +102,9 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
|
|||||||
//Get the conversation target list view
|
//Get the conversation target list view
|
||||||
conversationsListView = view.findViewById(R.id.fragment_conversationslist_list);
|
conversationsListView = view.findViewById(R.id.fragment_conversationslist_list);
|
||||||
|
|
||||||
|
//Get progress bar wheel
|
||||||
|
progressBar = view.findViewById(R.id.fragment_conversationslist_progressbar);
|
||||||
|
|
||||||
//Get the list of conversations
|
//Get the list of conversations
|
||||||
new AsyncTask<Void, Void, ArrayList<ConversationsInfo>>(){
|
new AsyncTask<Void, Void, ArrayList<ConversationsInfo>>(){
|
||||||
@Override
|
@Override
|
||||||
@ -243,7 +252,11 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
|
|||||||
//Attach it to the view
|
//Attach it to the view
|
||||||
conversationsListView.setAdapter(conversationsListAdapter);
|
conversationsListView.setAdapter(conversationsListAdapter);
|
||||||
|
|
||||||
|
//Add click listener
|
||||||
conversationsListView.setOnItemClickListener(this);
|
conversationsListView.setOnItemClickListener(this);
|
||||||
|
|
||||||
|
//Remove progress bar
|
||||||
|
display_progress_bar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -261,4 +274,13 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
|
|||||||
openConvListener.openConversation(conv.getID());
|
openConvListener.openConversation(conv.getID());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display (or hide) the progress bar
|
||||||
|
*
|
||||||
|
* @param show Set wether the progress bar should be shown or not
|
||||||
|
*/
|
||||||
|
private void display_progress_bar(boolean show){
|
||||||
|
progressBar.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
@ -148,26 +147,26 @@ public class FriendsListFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
new GetUsersInfos(mContext, mDbHelper).
|
new GetUsersInfos(mContext, mDbHelper).
|
||||||
getMultiple(FriendsUtils.getFriendsIDs(friendsList), new GetUsersInfos.getMultipleUserInfosCallback() {
|
getMultiple(FriendsUtils.getFriendsIDs(friendsList), new GetUsersInfos.getMultipleUserInfosCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void callback(ArrayMap<Integer, UserInfo> info) {
|
public void callback(ArrayMap<Integer, UserInfo> info) {
|
||||||
//Check for errors
|
//Check for errors
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
Toast.makeText(mContext, R.string.fragment_friendslist_err_get_userinfos,
|
Toast.makeText(mContext, R.string.fragment_friendslist_err_get_userinfos,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Merge the user informations list and friends List into FriendInfo list
|
||||||
|
ArrayList<FriendUser> friendsUserList = FriendsUtils.merge_friends_user_infos_list(
|
||||||
|
friendsList,
|
||||||
|
info
|
||||||
|
);
|
||||||
|
|
||||||
|
//Refresh friends list
|
||||||
|
apply_friends_list(friendsUserList);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
//Merge the user informations list and friends List into FriendInfo list
|
|
||||||
ArrayList<FriendUser> friendsUserList = FriendsUtils.merge_friends_user_infos_list(
|
|
||||||
friendsList,
|
|
||||||
info
|
|
||||||
);
|
|
||||||
|
|
||||||
//Refresh friends list
|
|
||||||
apply_friends_list(friendsUserList);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +230,7 @@ public class FriendsListFragment extends Fragment {
|
|||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setTitle(R.string.popup_deletefriend_title)
|
builder.setTitle(R.string.popup_deletefriend_title)
|
||||||
.setMessage(R.string.popup_deletefriend_message);
|
.setMessage(R.string.popup_deletefriend_message);
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.popup_deletefriend_button_confirm, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.popup_deletefriend_button_confirm, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -3,6 +3,14 @@
|
|||||||
android:orientation="vertical" android:layout_width="match_parent"
|
android:orientation="vertical" android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!-- Loading progress bar -->
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/fragment_conversationslist_progressbar"
|
||||||
|
android:layout_marginTop="25dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
<!-- List of the conversations -->
|
<!-- List of the conversations -->
|
||||||
<ListView
|
<ListView
|
||||||
android:id="@+id/fragment_conversationslist_list"
|
android:id="@+id/fragment_conversationslist_list"
|
||||||
|
Loading…
Reference in New Issue
Block a user