diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/mypage/MyPageFragment.java b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/mypage/MyPageFragment.java index 88e72f5..5531868 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/mypage/MyPageFragment.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/main_menu_ui/mypage/MyPageFragment.java @@ -13,6 +13,8 @@ import org.ntlab.acanthus_client.Acanthus; import org.ntlab.acanthus_client.R; import org.ntlab.acanthus_client.databinding.FragmentMypageBinding; +import org.ntlab.acanthus_client.entities.FollowJson; +import org.ntlab.acanthus_client.entities.FollowerJson; import org.ntlab.acanthus_client.views.animation.AnimationActivity; import org.ntlab.acanthus_client.views.main_menu_ui.mypage.help.HowToUseActivity; import org.ntlab.acanthus_client.views.main_menu_ui.mypage.help.InquiryActivity; @@ -20,6 +22,7 @@ import org.ntlab.acanthus_client.views.main_menu_ui.mypage.logout.LogoutActivity; import org.ntlab.acanthus_client.views.main_menu_ui.mypage.others.PrivacyPolicyActivity; import org.ntlab.acanthus_client.views.main_menu_ui.mypage.others.TermsOfServiceActivity; +import org.ntlab.acanthus_client.views.userpage.UserPageViewModel; import org.ntlab.acanthus_client.views.userpage.followList.FollowListActivity; import org.ntlab.acanthus_client.views.userpage.followerList.FollowerListActivity; @@ -34,6 +37,7 @@ public class MyPageFragment extends Fragment { private MyPageViewModel mypageViewModel; + private UserPageViewModel userPageViewModel; private FragmentMypageBinding binding; //----------------------------------------------------------------- @@ -179,7 +183,10 @@ loginNameText.setText(acanthus.getPreferenceName()); mypageViewModel = new ViewModelProvider(this).get(MyPageViewModel.class); mypageViewModel.init(acanthus); + userPageViewModel = new ViewModelProvider(this).get(UserPageViewModel.class); startObserve(); + observeFollowsSize(acanthus.getPreferenceUid()); + observeFollowersSize(acanthus.getPreferenceUid()); mypageViewModel.checkInvitedRequest(); mypageViewModel.getAccountInfoRequest(); @@ -220,6 +227,36 @@ //----------------------------------------------------------------- // + public void observeFollowsSize(Integer loginUid) { + TextView followsSize = binding.followsSizeText; + + userPageViewModel.getFollows(loginUid); + userPageViewModel.getFollowJson().observe(getViewLifecycleOwner(), new Observer() { + @Override + public void onChanged(FollowJson followJson) { + Integer size = followJson.getFollowUids().size(); + followsSize.setText(size.toString()); + } + }); + } + + //----------------------------------------------------------------- + // + public void observeFollowersSize(Integer loginUid) { + TextView followersSize = binding.followersSizeText; + + userPageViewModel.getFollowers(loginUid); + userPageViewModel.getFollowerJson().observe(getViewLifecycleOwner(), new Observer() { + @Override + public void onChanged(FollowerJson followerJson) { + Integer size = followerJson.getFollowerUids().size(); + followersSize.setText(size.toString()); + } + }); + } + + //----------------------------------------------------------------- + // public void transitionFollowListActivity() { Acanthus acanthus = (Acanthus) getActivity().getApplication(); Intent intent = new Intent(acanthus, FollowListActivity.class);