mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 07:49:28 +00:00
Display groups posts on latest posts thread
This commit is contained in:
parent
ab37254cf7
commit
35c5040133
@ -3,7 +3,9 @@ package org.communiquons.android.comunic.client.data.arrays;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
|
|
||||||
|
import org.communiquons.android.comunic.client.data.enums.PageType;
|
||||||
import org.communiquons.android.comunic.client.data.models.Comment;
|
import org.communiquons.android.comunic.client.data.models.Comment;
|
||||||
|
import org.communiquons.android.comunic.client.data.models.GroupInfo;
|
||||||
import org.communiquons.android.comunic.client.data.models.Post;
|
import org.communiquons.android.comunic.client.data.models.Post;
|
||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
|
|
||||||
@ -28,6 +30,11 @@ public class PostsList extends ArrayList<Post> {
|
|||||||
*/
|
*/
|
||||||
private ArrayMap<Integer, UserInfo> mUsersInfo = new ArrayMap<>();
|
private ArrayMap<Integer, UserInfo> mUsersInfo = new ArrayMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associated groups information
|
||||||
|
*/
|
||||||
|
private ArrayMap<Integer, GroupInfo> mGroupsInfo = new ArrayMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the IDs of the users who created the posts and their comments
|
* Get the IDs of the users who created the posts and their comments
|
||||||
*
|
*
|
||||||
@ -44,6 +51,9 @@ public class PostsList extends ArrayList<Post> {
|
|||||||
if(!ids.contains(userID))
|
if(!ids.contains(userID))
|
||||||
ids.add(userID);
|
ids.add(userID);
|
||||||
|
|
||||||
|
if(post.getPage_type() == PageType.USER_PAGE && !ids.contains(post.getPage_id()))
|
||||||
|
ids.add(post.getPage_id());
|
||||||
|
|
||||||
if(post.getComments_list() != null){
|
if(post.getComments_list() != null){
|
||||||
|
|
||||||
//Process the list of comments
|
//Process the list of comments
|
||||||
@ -61,12 +71,28 @@ public class PostsList extends ArrayList<Post> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get IDs of the related groups
|
||||||
|
*
|
||||||
|
* @return The list of IDs of related groups (may be an empty array)
|
||||||
|
*/
|
||||||
|
public ArrayList<Integer> getGroupsId(){
|
||||||
|
|
||||||
|
ArrayList<Integer> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Post post : this){
|
||||||
|
if(post.getPage_type() == PageType.GROUP_PAGE && !list.contains(post.getPage_id()))
|
||||||
|
list.add(post.getPage_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get associated user information
|
* Get associated user information
|
||||||
*
|
*
|
||||||
* @return Associated user information
|
* @return Associated user information
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public ArrayMap<Integer, UserInfo> getUsersInfo() {
|
public ArrayMap<Integer, UserInfo> getUsersInfo() {
|
||||||
return mUsersInfo;
|
return mUsersInfo;
|
||||||
}
|
}
|
||||||
@ -86,4 +112,31 @@ public class PostsList extends ArrayList<Post> {
|
|||||||
public boolean hasUsersInfo(){
|
public boolean hasUsersInfo(){
|
||||||
return this.mUsersInfo != null;
|
return this.mUsersInfo != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get related groups information
|
||||||
|
*
|
||||||
|
* @return Information about the groups
|
||||||
|
*/
|
||||||
|
public ArrayMap<Integer, GroupInfo> getGroupsInfo() {
|
||||||
|
return mGroupsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set groups information
|
||||||
|
*
|
||||||
|
* @param groupsInfo Information about related groups
|
||||||
|
*/
|
||||||
|
public void setGroupsInfo(ArrayMap<Integer, GroupInfo> groupsInfo) {
|
||||||
|
this.mGroupsInfo = groupsInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether groups information have been set or not
|
||||||
|
*
|
||||||
|
* @return TRUE if information about groups have been set / FALSE else
|
||||||
|
*/
|
||||||
|
public boolean hasGroupsInfo(){
|
||||||
|
return this.mGroupsInfo != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,7 @@ public class PostsHelper {
|
|||||||
public PostsList get_latest(int from) {
|
public PostsList get_latest(int from) {
|
||||||
//Perform a request on the API
|
//Perform a request on the API
|
||||||
APIRequest params = new APIRequest(mContext, "posts/get_latest");
|
APIRequest params = new APIRequest(mContext, "posts/get_latest");
|
||||||
|
params.addBoolean("include_groups", true);
|
||||||
|
|
||||||
//Check if we have to start from a precise post
|
//Check if we have to start from a precise post
|
||||||
if(from > 0)
|
if(from > 0)
|
||||||
@ -166,6 +167,23 @@ public class PostsHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load information related to a post
|
||||||
|
*
|
||||||
|
* @param list The list of posts to process
|
||||||
|
* @return TRUE if all the information have been successfully loaded / FALSE else
|
||||||
|
*/
|
||||||
|
public boolean load_related_information(@NonNull PostsList list){
|
||||||
|
|
||||||
|
//Get information about related users
|
||||||
|
list.setUsersInfo(new GetUsersHelper(mContext).getMultiple(list.getUsersId()));
|
||||||
|
|
||||||
|
//Get information about related groups
|
||||||
|
list.setGroupsInfo(new GroupsHelper(mContext).getInfoMultiple(list.getGroupsId()));
|
||||||
|
|
||||||
|
return list.hasUsersInfo() && list.hasGroupsInfo();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intend to delete a post specified by its ID
|
* Intend to delete a post specified by its ID
|
||||||
*
|
*
|
||||||
|
@ -6,6 +6,7 @@ import org.communiquons.android.comunic.client.data.enums.GroupRegistrationLevel
|
|||||||
import org.communiquons.android.comunic.client.data.enums.GroupVisibility;
|
import org.communiquons.android.comunic.client.data.enums.GroupVisibility;
|
||||||
import org.communiquons.android.comunic.client.data.enums.GroupsMembershipLevels;
|
import org.communiquons.android.comunic.client.data.enums.GroupsMembershipLevels;
|
||||||
import org.communiquons.android.comunic.client.data.enums.GroupPostsCreationLevel;
|
import org.communiquons.android.comunic.client.data.enums.GroupPostsCreationLevel;
|
||||||
|
import org.communiquons.android.comunic.client.data.utils.Utilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Group information base model
|
* Group information base model
|
||||||
@ -43,6 +44,13 @@ public class GroupInfo {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The name of the group ready to be shown on a TextView
|
||||||
|
*/
|
||||||
|
public String getDisplayName(){
|
||||||
|
return Utilities.prepareStringTextView(getName());
|
||||||
|
}
|
||||||
|
|
||||||
public String getIcon_url() {
|
public String getIcon_url() {
|
||||||
return icon_url;
|
return icon_url;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.support.annotation.CallSuper;
|
import android.support.annotation.CallSuper;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.ArrayMap;
|
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -17,6 +16,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
import org.communiquons.android.comunic.client.data.arrays.PostsList;
|
||||||
|
import org.communiquons.android.comunic.client.data.enums.PageType;
|
||||||
import org.communiquons.android.comunic.client.data.models.Comment;
|
import org.communiquons.android.comunic.client.data.models.Comment;
|
||||||
import org.communiquons.android.comunic.client.data.models.Post;
|
import org.communiquons.android.comunic.client.data.models.Post;
|
||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
@ -64,9 +64,10 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
private PostsList mList;
|
private PostsList mList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the users
|
* Specify whether the posts target should be shown or not
|
||||||
*/
|
*/
|
||||||
private ArrayMap<Integer, UserInfo> mUsersInfo;
|
private boolean mDisplayPostsTarget = true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities object
|
* Utilities object
|
||||||
@ -90,7 +91,6 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
mList = list;
|
mList = list;
|
||||||
mUsersInfo = list.getUsersInfo();
|
|
||||||
|
|
||||||
//Utilities
|
//Utilities
|
||||||
mUtils = new Utilities(getContext());
|
mUtils = new Utilities(getContext());
|
||||||
@ -98,6 +98,15 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
mListener = listener;
|
mListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify whether the target of the posts should be shown or not
|
||||||
|
*
|
||||||
|
* @param displayPostsTarget TRUE to display posts target / FALSE else
|
||||||
|
*/
|
||||||
|
public void setDisplayPostsTarget(boolean displayPostsTarget) {
|
||||||
|
this.mDisplayPostsTarget = displayPostsTarget;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
return mList.size();
|
return mList.size();
|
||||||
@ -161,6 +170,7 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
((TextPostHolder)viewHolder).bind(position);
|
((TextPostHolder)viewHolder).bind(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text posts holder
|
* Text posts holder
|
||||||
*/
|
*/
|
||||||
@ -168,6 +178,8 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
|
|
||||||
private WebUserAccountImage mUserAccountImage;
|
private WebUserAccountImage mUserAccountImage;
|
||||||
private TextView mUserAccountName;
|
private TextView mUserAccountName;
|
||||||
|
private ImageView mPostTargetArrow;
|
||||||
|
private TextView mTargetPageName;
|
||||||
private TextView mPostDate;
|
private TextView mPostDate;
|
||||||
private ImageView mPostVisibility;
|
private ImageView mPostVisibility;
|
||||||
private ImageView mPostActions;
|
private ImageView mPostActions;
|
||||||
@ -184,6 +196,8 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
|
|
||||||
mUserAccountImage = itemView.findViewById(R.id.user_account_image);
|
mUserAccountImage = itemView.findViewById(R.id.user_account_image);
|
||||||
mUserAccountName = itemView.findViewById(R.id.user_account_name);
|
mUserAccountName = itemView.findViewById(R.id.user_account_name);
|
||||||
|
mPostTargetArrow = itemView.findViewById(R.id.target_arrow);
|
||||||
|
mTargetPageName = itemView.findViewById(R.id.target_page_name);
|
||||||
mPostDate = itemView.findViewById(R.id.post_creation_time);
|
mPostDate = itemView.findViewById(R.id.post_creation_time);
|
||||||
mPostVisibility = itemView.findViewById(R.id.post_visibility);
|
mPostVisibility = itemView.findViewById(R.id.post_visibility);
|
||||||
mPostActions = itemView.findViewById(R.id.post_actions_btn);
|
mPostActions = itemView.findViewById(R.id.post_actions_btn);
|
||||||
@ -212,8 +226,8 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
|
|
||||||
Post post = getPost(position);
|
Post post = getPost(position);
|
||||||
UserInfo user = null;
|
UserInfo user = null;
|
||||||
if(mUsersInfo.containsKey(post.getUserID()))
|
if(mList.getUsersInfo().containsKey(post.getUserID()))
|
||||||
user = mUsersInfo.get(post.getUserID());
|
user = mList.getUsersInfo().get(post.getUserID());
|
||||||
|
|
||||||
|
|
||||||
//Apply user information
|
//Apply user information
|
||||||
@ -226,6 +240,40 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
mUserAccountName.setText("");
|
mUserAccountName.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Specify post target
|
||||||
|
setTargetNameVisibility(true);
|
||||||
|
|
||||||
|
//Check if posts target has not to be shown
|
||||||
|
if(!mDisplayPostsTarget)
|
||||||
|
setTargetNameVisibility(false);
|
||||||
|
|
||||||
|
//Do not display post target if the user who created the post created it on his page
|
||||||
|
else if(post.getPage_type() == PageType.USER_PAGE
|
||||||
|
&& post.getPage_id() == post.getUserID())
|
||||||
|
setTargetNameVisibility(false);
|
||||||
|
|
||||||
|
//For user page
|
||||||
|
else if(post.getPage_type() == PageType.USER_PAGE
|
||||||
|
&& mList.getUsersInfo().containsKey(post.getPage_id())){
|
||||||
|
|
||||||
|
mTargetPageName.setText(mList.getUsersInfo().get(post.getPage_id())
|
||||||
|
.getDisplayFullName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//For group page
|
||||||
|
else if(post.getPage_type() == PageType.GROUP_PAGE
|
||||||
|
&& mList.getGroupsInfo().containsKey(post.getPage_id())){
|
||||||
|
|
||||||
|
mTargetPageName.setText(mList.getGroupsInfo().get(post.getPage_id())
|
||||||
|
.getDisplayName());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Information about user / group not found
|
||||||
|
else
|
||||||
|
setTargetNameVisibility(false);
|
||||||
|
|
||||||
|
|
||||||
//Post date
|
//Post date
|
||||||
mPostDate.setText(mUtils.timeToString(Utilities.time() - post.getPost_time()));
|
mPostDate.setText(mUtils.timeToString(Utilities.time() - post.getPost_time()));
|
||||||
@ -292,8 +340,8 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
if(comment.isDeleted())
|
if(comment.isDeleted())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
UserInfo commentUser = mUsersInfo.containsKey(comment.getUserID()) ?
|
UserInfo commentUser = mList.getUsersInfo().containsKey(comment.getUserID()) ?
|
||||||
mUsersInfo.get(comment.getUserID()) : null;
|
mList.getUsersInfo().get(comment.getUserID()) : null;
|
||||||
|
|
||||||
View commentView = CommentsAdapter.getInflatedView(getContext(), comment,
|
View commentView = CommentsAdapter.getInflatedView(getContext(), comment,
|
||||||
mListener, commentUser, mCommentsList);
|
mListener, commentUser, mCommentsList);
|
||||||
@ -339,6 +387,11 @@ public class PostsAdapter extends BaseRecyclerViewAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setTargetNameVisibility(boolean visible){
|
||||||
|
mPostTargetArrow.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||||
|
mTargetPageName.setVisibility(visible ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
private void sendComment(){
|
private void sendComment(){
|
||||||
mListener.onCreateComment(getLayoutPosition(), mSendCommentButton,
|
mListener.onCreateComment(getLayoutPosition(), mSendCommentButton,
|
||||||
getPost(getLayoutPosition()), mEditCommentContentView);
|
getPost(getLayoutPosition()), mEditCommentContentView);
|
||||||
|
@ -21,13 +21,16 @@ public class GetLatestPostsTask extends SafeAsyncTask<Integer, Void, PostsList>
|
|||||||
@Override
|
@Override
|
||||||
protected PostsList doInBackground(Integer... integers) {
|
protected PostsList doInBackground(Integer... integers) {
|
||||||
|
|
||||||
|
PostsHelper helper = new PostsHelper(getContext());
|
||||||
|
|
||||||
//Get the list of posts
|
//Get the list of posts
|
||||||
int from = integers[0] == 0 ? -1 : integers[0];
|
int from = integers[0] == 0 ? -1 : integers[0];
|
||||||
PostsList list = new PostsHelper(getContext()).get_latest(from);
|
PostsList list = helper.get_latest(from);
|
||||||
if(list == null) return null;
|
if(list == null) return null;
|
||||||
|
|
||||||
list.setUsersInfo(new GetUsersHelper(getContext()).getMultiple(list.getUsersId()));
|
//Load related information
|
||||||
if(!list.hasUsersInfo()) return null;
|
if(!helper.load_related_information(list))
|
||||||
|
return null;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,16 @@ public class GetSinglePostTask extends SafeAsyncTask<Integer, Void, PostsList> {
|
|||||||
@Override
|
@Override
|
||||||
protected PostsList doInBackground(Integer... integers) {
|
protected PostsList doInBackground(Integer... integers) {
|
||||||
|
|
||||||
Post post = new PostsHelper(getContext()).getSingle(integers[0]);
|
PostsHelper helper = new PostsHelper(getContext());
|
||||||
|
|
||||||
|
Post post = helper.getSingle(integers[0]);
|
||||||
if(post == null) return null;
|
if(post == null) return null;
|
||||||
|
|
||||||
PostsList list = new PostsList();
|
PostsList list = new PostsList();
|
||||||
list.add(post);
|
list.add(post);
|
||||||
|
|
||||||
list.setUsersInfo(new GetUsersHelper(getContext()).getMultiple(list.getUsersId()));
|
if(!helper.load_related_information(list))
|
||||||
|
return null;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -31,16 +31,20 @@ public class LoadUserPostsTask extends SafeAsyncTask<Integer, Void, PostsList> {
|
|||||||
@Override
|
@Override
|
||||||
protected PostsList doInBackground(Integer ...integers) {
|
protected PostsList doInBackground(Integer ...integers) {
|
||||||
|
|
||||||
|
PostsHelper helper = new PostsHelper(getContext());
|
||||||
|
|
||||||
PostsList list;
|
PostsList list;
|
||||||
|
|
||||||
if(integers.length == 0)
|
if(integers.length == 0)
|
||||||
list = new PostsHelper(getContext()).get_user(mUserID);
|
list = helper.get_user(mUserID);
|
||||||
else
|
else
|
||||||
list = new PostsHelper(getContext()).get_user(mUserID, integers[0]);
|
list = helper.get_user(mUserID, integers[0]);
|
||||||
|
|
||||||
//Get associated user information, if possible
|
//Get associated user information, if possible
|
||||||
if(list != null)
|
if(list == null) return null;
|
||||||
list.setUsersInfo(new GetUsersHelper(getContext()).getMultiple(list.getUsersId()));
|
|
||||||
|
if(!helper.load_related_information(list))
|
||||||
|
return null;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,11 @@ abstract class AbstractPostsListFragment extends Fragment
|
|||||||
*/
|
*/
|
||||||
private int MENU_ACTION = MENU_ACTION_NONE;
|
private int MENU_ACTION = MENU_ACTION_NONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify whether posts target should be shown or not
|
||||||
|
*/
|
||||||
|
private boolean mDisplayPostsTarget = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current processed comment that context menu display actions for
|
* Current processed comment that context menu display actions for
|
||||||
*/
|
*/
|
||||||
@ -131,8 +136,7 @@ abstract class AbstractPostsListFragment extends Fragment
|
|||||||
/**
|
/**
|
||||||
* Arguments used to create post form
|
* Arguments used to create post form
|
||||||
*/
|
*/
|
||||||
Bundle mCreateFormArgs;
|
private Bundle mCreateFormArgs;
|
||||||
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@ -256,12 +260,20 @@ abstract class AbstractPostsListFragment extends Fragment
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if(list == null){
|
if(list == null){
|
||||||
Toast.makeText(getActivity(), R.string.err_get_posts_list, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), R.string.err_get_posts_list,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!list.hasUsersInfo()){
|
if(!list.hasUsersInfo()){
|
||||||
Toast.makeText(getActivity(), R.string.err_get_user_info, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), R.string.err_get_user_info,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!list.hasGroupsInfo()){
|
||||||
|
Toast.makeText(getActivity(), R.string.err_get_related_groups_info,
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,6 +304,7 @@ abstract class AbstractPostsListFragment extends Fragment
|
|||||||
//Create posts adapter (if required)
|
//Create posts adapter (if required)
|
||||||
if(mPostsAdapter == null) {
|
if(mPostsAdapter == null) {
|
||||||
mPostsAdapter = new PostsAdapter(getActivity(), mPostsList, this);
|
mPostsAdapter = new PostsAdapter(getActivity(), mPostsList, this);
|
||||||
|
mPostsAdapter.setDisplayPostsTarget(mDisplayPostsTarget);
|
||||||
|
|
||||||
//Connect the adapter to the view
|
//Connect the adapter to the view
|
||||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
@ -319,6 +332,15 @@ abstract class AbstractPostsListFragment extends Fragment
|
|||||||
return getPostsList().get(getPostsList().size() - 1).getId();
|
return getPostsList().get(getPostsList().size() - 1).getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify whether posts target should be shown or not
|
||||||
|
*
|
||||||
|
* @param displayPostsTarget TRUE to display / FALSE else
|
||||||
|
*/
|
||||||
|
protected void setDisplayPostsTarget(boolean displayPostsTarget) {
|
||||||
|
this.mDisplayPostsTarget = displayPostsTarget;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReachTop() {
|
public void onReachTop() {
|
||||||
//Nothing
|
//Nothing
|
||||||
|
@ -46,6 +46,8 @@ public class UserPostsFragment extends AbstractPostsListFragment {
|
|||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setDisplayPostsTarget(false);
|
||||||
|
|
||||||
//Get arguments
|
//Get arguments
|
||||||
Bundle bundle = getArguments();
|
Bundle bundle = getArguments();
|
||||||
assert bundle != null;
|
assert bundle != null;
|
||||||
|
9
app/src/main/res/drawable/ic_play_arrow.xml
Normal file
9
app/src/main/res/drawable/ic_play_arrow.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="@color/default_drawable_color"
|
||||||
|
android:pathData="M8,5v14l11,-7z"/>
|
||||||
|
</vector>
|
@ -28,6 +28,27 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="User name" />
|
tools:text="User name" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/target_arrow"
|
||||||
|
style="@style/PostTargetArrow"
|
||||||
|
android:layout_width="15dp"
|
||||||
|
android:layout_height="13dp"
|
||||||
|
android:scaleType="centerInside"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/post_creation_time"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/user_account_name"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/user_account_name"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/target_page_name"
|
||||||
|
style="@style/PostOwnerName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/target_arrow"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/target_arrow"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/target_arrow"
|
||||||
|
tools:text="Target Page" />
|
||||||
|
|
||||||
<!-- Post creation time -->
|
<!-- Post creation time -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/post_creation_time"
|
android:id="@+id/post_creation_time"
|
||||||
|
@ -266,4 +266,8 @@
|
|||||||
<string name="err_update_conversation_message_content">Une erreur a survenue lors de la mise à jour du contenu du message ! Veuillez réessayer…</string>
|
<string name="err_update_conversation_message_content">Une erreur a survenue lors de la mise à jour du contenu du message ! Veuillez réessayer…</string>
|
||||||
<string name="success_update_conversation_message_content">Le contenu du message a bien été mis à jour !</string>
|
<string name="success_update_conversation_message_content">Le contenu du message a bien été mis à jour !</string>
|
||||||
<string name="err_get_older_posts">Une erreur a survenue lors de la récupération de posts plus anciens !</string>
|
<string name="err_get_older_posts">Une erreur a survenue lors de la récupération de posts plus anciens !</string>
|
||||||
|
<string name="err_get_posts_list">Impossible de récupérer la liste de posts !</string>
|
||||||
|
<string name="notice_no_post_yet">Il n\'y a aucun post à afficher ici pour le moment.</string>
|
||||||
|
<string name="post_visibility_icon">Visiblité du post</string>
|
||||||
|
<string name="err_get_related_groups_info">Une erreur a survenue lors de la récupération d\'information sur les groupes liés !</string>
|
||||||
</resources>
|
</resources>
|
@ -268,4 +268,5 @@
|
|||||||
<string name="err_get_posts_list">Could not get the list of posts!</string>
|
<string name="err_get_posts_list">Could not get the list of posts!</string>
|
||||||
<string name="notice_no_post_yet">There is no post to display here yet.</string>
|
<string name="notice_no_post_yet">There is no post to display here yet.</string>
|
||||||
<string name="post_visibility_icon">Post visibility</string>
|
<string name="post_visibility_icon">Post visibility</string>
|
||||||
|
<string name="err_get_related_groups_info">Could not get information about related groups!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -93,6 +93,12 @@
|
|||||||
<item name="android:textStyle">bold</item>
|
<item name="android:textStyle">bold</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Post target arrow -->
|
||||||
|
<style name="PostTargetArrow">
|
||||||
|
<item name="android:src">@drawable/ic_play_arrow</item>
|
||||||
|
<item name="android:tint">@color/user_name_link</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!-- Post date -->
|
<!-- Post date -->
|
||||||
<style name="PostDate">
|
<style name="PostDate">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user