mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-10-31 09:34:47 +00:00 
			
		
		
		
	Display a notice when the user does not belong to any group.
This commit is contained in:
		| @@ -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); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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> | ||||
| @@ -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> | ||||
| @@ -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> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Pierre HUBERT
					Pierre HUBERT