diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bdefc6e..36e34ea 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -52,12 +52,12 @@
android:name=".LoginActivity"
android:exported="true"
android:label="@string/title_activity_login">
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
diff --git a/app/src/main/java/com/example/nemophila/MyPageActivity.java b/app/src/main/java/com/example/nemophila/MyPageActivity.java
index 153245d..973cb52 100644
--- a/app/src/main/java/com/example/nemophila/MyPageActivity.java
+++ b/app/src/main/java/com/example/nemophila/MyPageActivity.java
@@ -16,14 +16,20 @@
import com.example.nemophila.R;
import com.example.nemophila.RequestedActivity;
import com.example.nemophila.entities.Account;
+import com.example.nemophila.entities.Post;
import com.example.nemophila.viewmodels.AccountViewModel;
+import java.util.List;
+
public class MyPageActivity extends AppCompatActivity {
//MyPageActivity画面の作成
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mypage);
+
+ Nemophila nemophila = (Nemophila) getApplication();
+
//ボタンを押した場合の画面遷移
Button friendButton = (Button) findViewById(R.id.friend);
friendButton.setOnClickListener(new View.OnClickListener() {
@@ -58,12 +64,20 @@
});
//AccountViewModelとの通信とテキストの表示
AccountViewModel accountViewModel = new ViewModelProvider(this).get(AccountViewModel.class);
- Nemophila nemophila = (Nemophila) getApplication();
+ accountViewModel.getAccountLiveData().observe(this, new Observer () {
+ @Override
+ public void onChanged(Account account) {
+ String name = account.getName();
+ TextView myName = (TextView) findViewById(R.id.name);
+ myName.setText(name);
+ nemophila.setName(name);
+ }
+
+ });
String uid = nemophila.getUid();
- Account account = accountViewModel.getAccount(uid);
- String name = account.getName();
- TextView myname = (TextView) findViewById(R.id.name);
- myname.setText(name);
+ String name = nemophila.getName();
+ TextView myName = (TextView) findViewById(R.id.name);
+ myName.setText(name);
TextView id = (TextView) findViewById(R.id.id);
id.setText(uid);
diff --git a/app/src/main/java/com/example/nemophila/MyPageEditorActivity.java b/app/src/main/java/com/example/nemophila/MyPageEditorActivity.java
index 69078c3..4a75d76 100644
--- a/app/src/main/java/com/example/nemophila/MyPageEditorActivity.java
+++ b/app/src/main/java/com/example/nemophila/MyPageEditorActivity.java
@@ -1,6 +1,7 @@
package com.example.nemophila;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import android.content.Intent;
@@ -10,6 +11,7 @@
import android.widget.EditText;
import android.widget.TextView;
+import com.example.nemophila.entities.Account;
import com.example.nemophila.viewmodels.AccountViewModel;
public class MyPageEditorActivity extends AppCompatActivity {
@@ -22,8 +24,8 @@
AccountViewModel accountViewModel = new ViewModelProvider(this).get(AccountViewModel.class);
Nemophila nemophila = (Nemophila) getApplication();
String name = nemophila.getName();
- EditText myname = (EditText) findViewById(R.id.editName);
- myname.setText(name);
+ EditText myName = (EditText) findViewById(R.id.editName);
+ myName.setText(name);
//MyPageに戻るボタン
Button backButton = (Button) findViewById(R.id.backMyPage);
backButton.setOnClickListener(new View.OnClickListener() {
@@ -33,6 +35,20 @@
}
});
+
+ accountViewModel.getAccountLiveData().observe(this, new Observer() {
+ @Override
+ public void onChanged(Account account) {
+ String name = account.getName();
+ TextView myName = (TextView) findViewById(R.id.name);
+ myName.setText(name);
+ nemophila.setName(name);
+ Intent intent = new Intent(MyPageEditorActivity.this, MyPageActivity.class);
+ startActivity(intent);
+ }
+
+ });
+
//変更確定ボタンを押した場合の動き
Button changeNameButton = (Button) findViewById(R.id.changeConfirm);
changeNameButton.setOnClickListener(new View.OnClickListener() {
@@ -45,7 +61,6 @@
EditText editNewPw = (EditText) findViewById(R.id.editNewPw);
String newPw = editNewPw.getText().toString();
//Nemophilaから(id)(token)をgetしてaccountViewModelに送る
- Nemophila nemophila = (Nemophila) getApplication();
String uid = nemophila.getUid();
String token = nemophila.getToken();
if(newName!=null) {
@@ -54,16 +69,12 @@
if(oldPw!=null && newPw!=null) {
accountViewModel.changePw(uid, oldPw, newPw, token);
}
-//変更確定ボタンを押した場合もMyPageに戻る
- Intent intent = new Intent(MyPageEditorActivity.this, MyPageActivity.class);
- startActivity(intent);
}
});
// 削除ボタンを押したときの処理
Button deleteAccountButton = (Button) findViewById(R.id.deleteAccount);
deleteAccountButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- Nemophila nemophila = (Nemophila) getApplication();
String uid = nemophila.getUid();
String token = nemophila.getToken();
Intent intent = new Intent(MyPageEditorActivity.this, LoginActivity.class);