Display a notice when the user does not belong to any group.

This commit is contained in:
Pierre HUBERT 2018-09-08 11:10:44 +02:00
parent 60fd6e75cc
commit 8cf57d17c6
4 changed files with 37 additions and 6 deletions

View File

@ -12,6 +12,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import org.communiquons.android.comunic.client.R;
@ -34,6 +35,7 @@ public class UserGroupsFragment extends AbstractGroupFragment {
*/
private ProgressBar mProgressBar;
private RecyclerView mGroupsView;
private TextView mNoGroupNotice;
/**
* User groups
@ -58,8 +60,10 @@ public class UserGroupsFragment extends AbstractGroupFragment {
//Get views
mGroupsView = view.findViewById(R.id.groups_list);
mProgressBar = view.findViewById(R.id.progressBar);
mNoGroupNotice = view.findViewById(R.id.noGroupNotice);
setProgressBarVisiblity(true);
setProgressBarVisibility(true);
setNoGroupNoticeVisibility(false);
}
@Override
@ -77,7 +81,7 @@ public class UserGroupsFragment extends AbstractGroupFragment {
*/
private void getGroupsList(){
setProgressBarVisiblity(true);
setProgressBarVisibility(true);
getTasksManager().unsetSpecificTasks(GetUserGroupsTask.class);
GetUserGroupsTask getUserGroupsTask = new GetUserGroupsTask(getActivity());
@ -98,7 +102,7 @@ public class UserGroupsFragment extends AbstractGroupFragment {
*/
private void getGroupsListCallback(@Nullable ArrayMap<Integer, GroupInfo> list){
setProgressBarVisiblity(false);
setProgressBarVisibility(false);
if(list == null){
Toast.makeText(getActivity(), R.string.err_get_user_groups, Toast.LENGTH_SHORT).show();
@ -114,7 +118,7 @@ public class UserGroupsFragment extends AbstractGroupFragment {
*/
private void displayGroupsList(){
setProgressBarVisiblity(false);
setProgressBarVisibility(false);
mGroupsAdapter = new GroupsListAdapter(getActivity());
mGroupsAdapter.setList(new ArrayList<>(mGroupsList.values()));
@ -124,14 +128,24 @@ public class UserGroupsFragment extends AbstractGroupFragment {
mGroupsView.addItemDecoration(new DividerItemDecoration(getActivity(),
DividerItemDecoration.VERTICAL));
setNoGroupNoticeVisibility(mGroupsList.size() == 0);
}
/**
* Update (set) progressbar visibility
*
* @param visible Visibility level of the progress bar
* @param visible Visibility of the progress bar
*/
private void setProgressBarVisiblity(boolean visible){
private void setProgressBarVisibility(boolean visible){
mProgressBar.setVisibility(visible ? View.VISIBLE : View.GONE);
}
/**
* Update no group notice visibility
*
* @param visible The visibility of the notice
*/
private void setNoGroupNoticeVisibility(boolean visible){
mNoGroupNotice.setVisibility(visible ? View.VISIBLE : View.GONE);
}
}

View File

@ -30,4 +30,17 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/noGroupNotice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:text="@string/notice_no_group"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

View File

@ -297,4 +297,7 @@
<string name="action_send_survey_response">Répondre</string>
<string name="err_cancel_response">Une erreur a survenue lors de l\'annulation de votre réponse au sondage !</string>
<string name="err_respond_survey">Une erreur a survenue lors de l\'envoi de votre réponse au sondage !</string>
<string name="action_user_groups">Mes groupes</string>
<string name="err_get_user_groups">Une erreur a survenu lors de la récupération de vos groupes !</string>
<string name="notice_no_group">Vous n\'avez aucun groupe pour le moment.</string>
</resources>

View File

@ -298,4 +298,5 @@
<string name="err_respond_survey">Could not send response to the server!</string>
<string name="action_user_groups">My groups</string>
<string name="err_get_user_groups">Could not get the groups of the user!</string>
<string name="notice_no_group">You do not have any group yet.</string>
</resources>