mirror of
				https://github.com/pierre42100/ComunicAndroid
				synced 2025-10-31 01:24:43 +00:00 
			
		
		
		
	Hide create post button if the user is not allowed to create post.
This commit is contained in:
		| @@ -400,6 +400,8 @@ public class GetUsersHelper { | ||||
|             //Get account creation time | ||||
|             advancedUserInfo.setAccount_creation_time(userObject.getInt("account_creation_time")); | ||||
|  | ||||
|             //Check if user can post text or this page or not | ||||
|             advancedUserInfo.setCanPostText(userObject.getBoolean("can_post_texts")); | ||||
|  | ||||
|         } catch (JSONException e){ | ||||
|             e.printStackTrace(); | ||||
|   | ||||
| @@ -12,6 +12,7 @@ public class AdvancedUserInfo extends UserInfo { | ||||
|     //Private fields | ||||
|     private int account_creation_time; | ||||
|     private boolean accessForbidden = false; | ||||
|     private boolean canPostText; | ||||
|  | ||||
|     /** | ||||
|      * Get the account creation time | ||||
| @@ -48,4 +49,22 @@ public class AdvancedUserInfo extends UserInfo { | ||||
|     public void setAccessForbidden(boolean accessForbidden) { | ||||
|         this.accessForbidden = accessForbidden; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Set whether the current user can post a text on this user page or not | ||||
|      * | ||||
|      * @param canPostText TRUE to allow / FALSE to deny | ||||
|      */ | ||||
|     public void setCanPostText(boolean canPostText) { | ||||
|         this.canPostText = canPostText; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Check whether the user can post text on this user page | ||||
|      * | ||||
|      * @return TRUE : yes / FALSE no | ||||
|      */ | ||||
|     public boolean isCanPostText() { | ||||
|         return canPostText; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -260,6 +260,10 @@ public class UserPageFragment extends Fragment implements PostsCreateFormFragmen | ||||
|         ImageLoadHelper.remove(user_image); | ||||
|         ImageLoadHelper.load(getActivity(), userInfo.getAcountImageURL(), user_image); | ||||
|  | ||||
|         //Check if the user can post text on this page | ||||
|         mCreatePostButton.setVisibility(userInfo.isCanPostText() ? View.VISIBLE : View.GONE); | ||||
|  | ||||
|  | ||||
|         //Load the list of posts of the user | ||||
|         load_posts(); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Pierre
					Pierre