Skip to content

Commit

Permalink
fix npe
Browse files Browse the repository at this point in the history
  • Loading branch information
imndx committed Oct 16, 2019
1 parent 0078f14 commit 9331020
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ private void showConversationInfo() {
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
conversation = intent.getParcelableExtra("conversation");
if (conversation == null) {
finish();
}
long initialFocusedMessageId = intent.getLongExtra("toFocusMessageId", -1);
String channelPrivateChatUser = intent.getStringExtra("channelPrivateChatUser");
conversationFragment.setupConversation(conversation, null, initialFocusedMessageId, channelPrivateChatUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,23 +300,22 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {

inputPanel.init(this, rootLinearLayout);
inputPanel.setOnConversationInputPanelStateChangeListener(this);

settingViewModel = ViewModelProviders.of(this).get(SettingViewModel.class);
conversationViewModel = WfcUIKit.getAppScopeViewModel(ConversationViewModel.class);
conversationViewModel.clearConversationMessageLiveData().observeForever(clearConversationMessageObserver);
messageViewModel = ViewModelProviders.of(this).get(MessageViewModel.class);

messageViewModel.messageLiveData().observeForever(messageLiveDataObserver);
messageViewModel.messageUpdateLiveData().observeForever(messageUpdateLiveDatObserver);
messageViewModel.messageRemovedLiveData().observeForever(messageRemovedLiveDataObserver);
messageViewModel.mediaUpdateLiveData().observeForever(mediaUploadedLiveDataObserver);

userViewModel = ViewModelProviders.of(this).get(UserViewModel.class);
userViewModel.userInfoLiveData().observeForever(userInfoUpdateLiveDataObserver);
}

private void setupConversation(Conversation conversation) {
if (conversationViewModel == null) {
settingViewModel = ViewModelProviders.of(this).get(SettingViewModel.class);
conversationViewModel = WfcUIKit.getAppScopeViewModel(ConversationViewModel.class);
conversationViewModel.clearConversationMessageLiveData().observeForever(clearConversationMessageObserver);
messageViewModel = ViewModelProviders.of(this).get(MessageViewModel.class);

messageViewModel.messageLiveData().observeForever(messageLiveDataObserver);
messageViewModel.messageUpdateLiveData().observeForever(messageUpdateLiveDatObserver);
messageViewModel.messageRemovedLiveData().observeForever(messageRemovedLiveDataObserver);
messageViewModel.mediaUpdateLiveData().observeForever(mediaUploadedLiveDataObserver);

userViewModel = ViewModelProviders.of(this).get(UserViewModel.class);
userViewModel.userInfoLiveData().observeForever(userInfoUpdateLiveDataObserver);
}

if (conversation.type == Conversation.ConversationType.Group) {
GroupViewModel groupViewModel = ViewModelProviders.of(this).get(GroupViewModel.class);
Expand Down Expand Up @@ -680,6 +679,9 @@ private void updateTypingStatusTitle(TypingMessageContent typingMessageContent)
private Runnable resetConversationTitleRunnable = this::resetConversationTitle;

private void resetConversationTitle() {
if (getActivity() == null || getActivity().isFinishing()) {
return;
}
if (!TextUtils.equals(conversationTitle, getActivity().getTitle())) {
setActivityTitle(conversationTitle);
handler.removeCallbacks(resetConversationTitleRunnable);
Expand Down

0 comments on commit 9331020

Please sign in to comment.