Hide create post button if the user is not allowed to create post.

This commit is contained in:
Pierre 2018-04-14 17:11:23 +02:00
parent 4aeddb3ba2
commit a77254d098
3 changed files with 25 additions and 0 deletions

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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();
}