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..27380e1 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; @@ -180,6 +183,8 @@ mypageViewModel = new ViewModelProvider(this).get(MyPageViewModel.class); mypageViewModel.init(acanthus); startObserve(); + observeFollowsSize(acanthus.getPreferenceUid()); + observeFollowersSize(acanthus.getPreferenceUid()); mypageViewModel.checkInvitedRequest(); mypageViewModel.getAccountInfoRequest(); @@ -220,6 +225,36 @@ //----------------------------------------------------------------- // + public void observeFollowsSize(Integer loginUid) { + TextView followsSize = binding.followsSizeText; + + mypageViewModel.getMyFollows(loginUid); + mypageViewModel.getMyFollowJson().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; + + mypageViewModel.getMyFollowers(loginUid); + mypageViewModel.getMyFollowerJson().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);