diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java index 5d800fa..f3c954e 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/fragments/AdvancedUserInfoFragment.java @@ -11,13 +11,16 @@ import android.widget.TextView; import org.communiquons.android.comunic.client.R; import org.communiquons.android.comunic.client.data.models.AdvancedUserInfo; +import org.communiquons.android.comunic.client.data.utils.AccountUtils; import org.communiquons.android.comunic.client.data.utils.Utilities; -import org.communiquons.android.comunic.client.ui.utils.UiUtils; +import org.communiquons.android.comunic.client.ui.views.FriendshipStatusButton; import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage; /** * Advanced user information fragment * + * Warning !!! This fragment is not made to work in an autonomous way !!! + * * @author Pierre HUBERT */ public class AdvancedUserInfoFragment extends Fragment { @@ -42,6 +45,11 @@ public class AdvancedUserInfoFragment extends Fragment { */ private TextView mMemberSinceTarget; + /** + * Friendship status + */ + private FriendshipStatusButton mFriendshipStatus; + /** * Set advanced information about the user * @@ -75,6 +83,7 @@ public class AdvancedUserInfoFragment extends Fragment { mUserAccountImage = view.findViewById(R.id.user_account_image); mUserName = view.findViewById(R.id.user_name); mMemberSinceTarget = view.findViewById(R.id.member_since_value); + mFriendshipStatus = view.findViewById(R.id.friendship_status); } @Override @@ -87,4 +96,18 @@ public class AdvancedUserInfoFragment extends Fragment { mMemberSinceTarget.setText(new Utilities(getActivity()).timeToString( Utilities.time() - mAdvancedUserInfo.getAccount_creation_time())); } + + @Override + public void onResume() { + super.onResume(); + + if(AccountUtils.getID(getActivity()) == mAdvancedUserInfo.getId()) { + mFriendshipStatus.setVisibility(View.GONE); + } + else { + mFriendshipStatus.setUserID(mAdvancedUserInfo.getId()); + mFriendshipStatus.refreshIfRequired(); + } + + } } diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/views/FriendshipStatusButton.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/views/FriendshipStatusButton.java index 74f23bf..3e253cf 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/ui/views/FriendshipStatusButton.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/views/FriendshipStatusButton.java @@ -198,12 +198,13 @@ public class FriendshipStatusButton extends BaseFrameLayoutView implements View. else { //The two people are friends - mOnFriendsStatusUpdateListener.onAreFriend(); + if(mOnFriendsStatusUpdateListener != null) + mOnFriendsStatusUpdateListener.onAreFriend(); if(mFriendshipStatus.isFollowing()) mFollowingButton.setVisibility(View.VISIBLE); else - mFollowingButton.setVisibility(View.GONE); + mFollowButton.setVisibility(View.VISIBLE); } } diff --git a/app/src/main/res/layout/fragment_advanced_user_info.xml b/app/src/main/res/layout/fragment_advanced_user_info.xml index 0298fc1..a9f9d90 100644 --- a/app/src/main/res/layout/fragment_advanced_user_info.xml +++ b/app/src/main/res/layout/fragment_advanced_user_info.xml @@ -81,5 +81,12 @@ + + \ No newline at end of file