mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 07:49:28 +00:00
Add Friendship status button on user page fragment
This commit is contained in:
parent
7944cab063
commit
b95c040ff2
@ -11,13 +11,16 @@ 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.models.AdvancedUserInfo;
|
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.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;
|
import org.communiquons.android.comunic.client.ui.views.WebUserAccountImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advanced user information fragment
|
* Advanced user information fragment
|
||||||
*
|
*
|
||||||
|
* Warning !!! This fragment is not made to work in an autonomous way !!!
|
||||||
|
*
|
||||||
* @author Pierre HUBERT
|
* @author Pierre HUBERT
|
||||||
*/
|
*/
|
||||||
public class AdvancedUserInfoFragment extends Fragment {
|
public class AdvancedUserInfoFragment extends Fragment {
|
||||||
@ -42,6 +45,11 @@ public class AdvancedUserInfoFragment extends Fragment {
|
|||||||
*/
|
*/
|
||||||
private TextView mMemberSinceTarget;
|
private TextView mMemberSinceTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Friendship status
|
||||||
|
*/
|
||||||
|
private FriendshipStatusButton mFriendshipStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set advanced information about the user
|
* Set advanced information about the user
|
||||||
*
|
*
|
||||||
@ -75,6 +83,7 @@ public class AdvancedUserInfoFragment extends Fragment {
|
|||||||
mUserAccountImage = view.findViewById(R.id.user_account_image);
|
mUserAccountImage = view.findViewById(R.id.user_account_image);
|
||||||
mUserName = view.findViewById(R.id.user_name);
|
mUserName = view.findViewById(R.id.user_name);
|
||||||
mMemberSinceTarget = view.findViewById(R.id.member_since_value);
|
mMemberSinceTarget = view.findViewById(R.id.member_since_value);
|
||||||
|
mFriendshipStatus = view.findViewById(R.id.friendship_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -87,4 +96,18 @@ public class AdvancedUserInfoFragment extends Fragment {
|
|||||||
mMemberSinceTarget.setText(new Utilities(getActivity()).timeToString(
|
mMemberSinceTarget.setText(new Utilities(getActivity()).timeToString(
|
||||||
Utilities.time() - mAdvancedUserInfo.getAccount_creation_time()));
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,12 +198,13 @@ public class FriendshipStatusButton extends BaseFrameLayoutView implements View.
|
|||||||
else {
|
else {
|
||||||
|
|
||||||
//The two people are friends
|
//The two people are friends
|
||||||
mOnFriendsStatusUpdateListener.onAreFriend();
|
if(mOnFriendsStatusUpdateListener != null)
|
||||||
|
mOnFriendsStatusUpdateListener.onAreFriend();
|
||||||
|
|
||||||
if(mFriendshipStatus.isFollowing())
|
if(mFriendshipStatus.isFollowing())
|
||||||
mFollowingButton.setVisibility(View.VISIBLE);
|
mFollowingButton.setVisibility(View.VISIBLE);
|
||||||
else
|
else
|
||||||
mFollowingButton.setVisibility(View.GONE);
|
mFollowButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,5 +81,12 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</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>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
Loading…
Reference in New Issue
Block a user