diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml
new file mode 100644
index 0000000..4a53bee
--- /dev/null
+++ b/.idea/AndroidProjectSystem.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
index b268ef3..5c64f4d 100644
--- a/.idea/deploymentTargetSelector.xml
+++ b/.idea/deploymentTargetSelector.xml
@@ -4,6 +4,14 @@
+
+
+
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8978d23..2e7eabd 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,7 @@
+
-
+
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..16660f1
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/tampopo_client/views/MainActivity.java b/app/src/main/java/com/example/tampopo_client/views/MainActivity.java
index 9911876..7f5b854 100644
--- a/app/src/main/java/com/example/tampopo_client/views/MainActivity.java
+++ b/app/src/main/java/com/example/tampopo_client/views/MainActivity.java
@@ -130,45 +130,8 @@
}
});
- //アクティビティを投稿した人がアクティビティを更新しないか監視する
- //なにかをクリックしたらここに飛んでくる
- for (String friendId : userViews.keySet()) {
- //final String updateFriendId = friendId;
- MutableLiveData> activitiesLiveData = activityViewModel.getActivitiesLiveDataFromUserId(friendId);
- //MutableLiveData> activitiesLiveData = activityViewModel.getActivitiesLiveDataFromUserId(updateFriendId);
-
- //FriendIconView friendView = userViews.get(friendId);
- //if (friendView == null) continue;
-
- activitiesLiveData.observeForever(new Observer>() {
- //アクティビティを更新したらonChangedが呼び出される
- @Override
- public void onChanged(List activities) {
- // 更新したフレンドの再登場,更新してないフレンドの退場
- //更新した人を見つけてFriendIconViewを呼び出して、
- List sortedFriendUserIds = activityViewModel.getSortedFriendUserIds();//アクティビティを更新した最新6人のリスト
-// FriendIconView userView = userViews.get(friendId);
-// if (userView != null && activities != null && !activities.isEmpty()) {
-// //latestは最新のアクティビティを保持する
-// Activity latest = activities.get(activities.size() - 1);
-// }
-// // 最新更新フレンドをリストに追加(最大6人保持)
- int size = sortedFriendUserIds.size();
- List latestSix = sortedFriendUserIds.subList(Math.max(size - 6, 0), size);
-
- synchronized (recentUpdatedFriends) {
- if (latestSix.contains(friendId)) {
- recentUpdatedFriends.remove(friendId);
- recentUpdatedFriends.add(0, friendId);
- if (recentUpdatedFriends.size() > 6) {
- recentUpdatedFriends.remove(recentUpdatedFriends.size() - 1);
- }
- }
- }
-//スレッド処理をいれて更新できるようにする
- }
- });
- }
+ // アクティビティ更新の監視は、各FriendIconView作成時に登録する
+ // (updateActivityView内でLiveData.observe(...)を行う)
// for (String friendId : userViews.keySet()) {
@@ -390,6 +353,7 @@
for (String friendId : friends) {
FriendIconView userView = userViews.get(friendId);
//userViews.put(friendId, null);
+ // 各フレンドのアクティビティLiveDataを取得
MutableLiveData> activitiesLiveData = activityViewModel.getActivitiesLiveDataFromUserId(friendId);
// for (String friendId : sortedFriendUserIds) {
@@ -444,6 +408,11 @@
// Mapに登録、画面に追加
userViews.put(friendId, container);
+
+ // フレンドのアクティビティ更新を監視し、吹き出しコメントを更新する
+ if (activitiesLiveData != null) {
+ activitiesLiveData.observe(MainActivity.this, container.getActivitiesObserver());
+ }
// userView = container;
// messageList.addView(container);