Add Friendship status button on user page fragment

This commit is contained in:
Pierre HUBERT 2018-08-26 14:59:51 +02:00
parent 7944cab063
commit b95c040ff2
3 changed files with 34 additions and 3 deletions

View File

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

View File

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

View File

@ -81,5 +81,12 @@
</LinearLayout>
</LinearLayout>
<org.communiquons.android.comunic.client.ui.views.FriendshipStatusButton
android:id="@+id/friendship_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"/>
</LinearLayout>
</ScrollView>