| |
---|
| | setContentView(R.layout.activity_userpage); |
---|
| | |
---|
| | userPageViewModel = new ViewModelProvider(this).get(UserPageViewModel.class); |
---|
| | acanthus = (Acanthus) getApplication(); |
---|
| | Integer uid = 1; |
---|
| | // Integer uid = acanthus.getPreferenceUid(); |
---|
| | String token = "abc0"; |
---|
| | // String token = acanthus.getPreferenceToken(); |
---|
| | // Intent intent = getIntent(); //FollowListActivity,FollowerListActivityからそれぞれuidをもらう |
---|
| | // Integer uid2 = intent.getIntExtra("UID", 0); |
---|
| | Integer uid2 = 2; |
---|
| | Integer loginUid = 1; |
---|
| | // Integer loginUid = acanthus.getPreferenceUid(); |
---|
| | String loginToken = "abc0"; |
---|
| | // String loginToken = acanthus.getPreferenceToken(); |
---|
| | Intent intent = getIntent(); //FollowListActivity,FollowerListActivityからそれぞれuidをもらう |
---|
| | // Integer uid = intent.getIntExtra("UID", 0); |
---|
| | Integer uid = 2; |
---|
| | String uname = intent.getStringExtra("NAME"); |
---|
| | |
---|
| | TextView userNameText = findViewById(R.id.userNameText); |
---|
| | // userNameText.setText(); |
---|
| | userNameText.setText(uname); |
---|
| | |
---|
| | TextView profileText = findViewById(R.id.profileText); |
---|
| | |
---|
| | Button returnButton = findViewById(R.id.returnButton); |
---|
| |
---|
| | |
---|
| | Button followUserButton = findViewById(R.id.followUserButton); |
---|
| | |
---|
| | //閲覧しているユーザーページが自分のページならフォローボタンを非表示する |
---|
| | if (uid == uid2) { |
---|
| | if (loginUid == uid) { |
---|
| | followUserButton.setVisibility(View.INVISIBLE); |
---|
| | } |
---|
| | |
---|
| | //ログインしているユーザーがフォローしているかの有無で画面表示時のボタンの文字を変更する |
---|
| | userPageViewModel.getFollows(uid); |
---|
| | userPageViewModel.getFollows(loginUid); |
---|
| | userPageViewModel.getFollowJson().observe(this, new Observer<FollowJson>() { |
---|
| | @Override |
---|
| | public void onChanged(@Nullable FollowJson followJson) { |
---|
| | followsUidList = followJson.getFollowUids(); |
---|
| | |
---|
| | if (followsUidList.contains(uid2)) { |
---|
| | if (followsUidList.contains(uid)) { |
---|
| | followUserButton.setText("フォロー解除"); |
---|
| | }else{ |
---|
| | followUserButton.setText("フォローする"); |
---|
| | } |
---|
| |
---|
| | //ユーザーのフォロー及びフォロー解除の処理 |
---|
| | followUserButton.setOnClickListener(new View.OnClickListener() { |
---|
| | @Override |
---|
| | public void onClick(View v) { |
---|
| | if (!followsUidList.contains(uid2)) { |
---|
| | userPageViewModel.addFollow(uid, token, uid2); |
---|
| | followsUidList.add(uid2); |
---|
| | if (!followsUidList.contains(uid)) { |
---|
| | userPageViewModel.addFollow(loginUid, loginToken, uid); |
---|
| | followsUidList.add(uid); |
---|
| | followUserButton.setText("フォロー解除"); |
---|
| | }else{ |
---|
| | userPageViewModel.releaseFollow(uid, token, uid2); |
---|
| | followsUidList.remove(uid2); |
---|
| | userPageViewModel.releaseFollow(loginUid, loginToken, uid); |
---|
| | followsUidList.remove(uid); |
---|
| | followUserButton.setText("フォローする"); |
---|
| | } |
---|
| | } |
---|
| | }); |
---|
| |
---|
| | followListButton.setOnClickListener(new View.OnClickListener() { |
---|
| | @Override |
---|
| | public void onClick(View v) { |
---|
| | Intent intent = new Intent(getApplication(), FollowListActivity.class); |
---|
| | intent.putExtra("UID", uid2); |
---|
| | intent.putExtra("UID", uid); |
---|
| | startActivity(intent); |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| |
---|
| | followerListButton.setOnClickListener(new View.OnClickListener() { |
---|
| | @Override |
---|
| | public void onClick(View v) { |
---|
| | Intent intent = new Intent(getApplication(), FollowerListActivity.class); |
---|
| | intent.putExtra("UID", uid2); |
---|
| | intent.putExtra("UID", uid); |
---|
| | startActivity(intent); |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| |
---|
| | workListButton.setOnClickListener(new View.OnClickListener() { |
---|
| | @Override |
---|
| | public void onClick(View v) { |
---|
| | Intent intent = new Intent(getApplication(), WorkListActivity.class); |
---|
| | intent.putExtra("UID", uid2); |
---|
| | intent.putExtra("UID", uid); |
---|
| | startActivity(intent); |
---|
| | } |
---|
| | }); |
---|
| | |
---|
| | |