Skip to content

Commit 184352f

Browse files
committed
friend request update issue. fix #153
1 parent a85ab49 commit 184352f

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

chat/src/main/java/cn/wildfire/chat/kit/WfcUIKit.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public void onForeground() {
6868
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
6969
public void onBackground() {
7070
isBackground = true;
71-
viewModelStore.clear();
7271
}
7372
});
7473

chat/src/main/java/cn/wildfire/chat/kit/contact/ContactListFragment.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ private void loadContacts() {
6666
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
6767
View view = super.onCreateView(inflater, container, savedInstanceState);
6868

69-
contactViewModel.contactListUpdatedLiveData().observeForever(contactListUpdateLiveDataObserver);
70-
contactViewModel.friendRequestUpdatedLiveData().observeForever(friendRequestUpdateLiveDataObserver);
69+
contactViewModel.contactListUpdatedLiveData().observe(this, contactListUpdateLiveDataObserver);
70+
contactViewModel.friendRequestUpdatedLiveData().observe(this, friendRequestUpdateLiveDataObserver);
7171

7272
userViewModel = WfcUIKit.getAppScopeViewModel(UserViewModel.class);
7373
userViewModel.userInfoLiveData().observeForever(userInfoLiveDataObserver);
@@ -77,8 +77,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
7777
@Override
7878
public void onDestroyView() {
7979
super.onDestroyView();
80-
contactViewModel.contactListUpdatedLiveData().removeObserver(contactListUpdateLiveDataObserver);
81-
contactViewModel.friendRequestUpdatedLiveData().removeObserver(friendRequestUpdateLiveDataObserver);
8280
userViewModel.userInfoLiveData().removeObserver(userInfoLiveDataObserver);
8381
}
8482

chat/src/main/java/cn/wildfire/chat/kit/contact/newfriend/FriendRequestListFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import androidx.annotation.NonNull;
1010
import androidx.annotation.Nullable;
1111
import androidx.fragment.app.Fragment;
12-
import androidx.lifecycle.ViewModelProviders;
1312
import androidx.recyclerview.widget.DividerItemDecoration;
1413
import androidx.recyclerview.widget.LinearLayoutManager;
1514
import androidx.recyclerview.widget.RecyclerView;
@@ -45,7 +44,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
4544
}
4645

4746
private void init() {
48-
contactViewModel = ViewModelProviders.of(this).get(ContactViewModel.class);
47+
contactViewModel = WfcUIKit.getAppScopeViewModel(ContactViewModel.class);
4948
UserViewModel userViewModel = WfcUIKit.getAppScopeViewModel(UserViewModel.class);
5049
userViewModel.userInfoLiveData().observe(this, userInfos -> {
5150
if (adapter != null) {

0 commit comments

Comments
 (0)