Fix crash in chat

This commit is contained in:
Margaux Clerc 2015-11-26 10:43:15 +01:00
parent 0e4b5d7d0b
commit bb217a3a6e
2 changed files with 15 additions and 16 deletions

View file

@ -3,7 +3,7 @@
android:id="@+id/layout"
android:background="@drawable/list_selector"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_height="60dp"
android:padding="5dp"
android:gravity="center_vertical"
android:orientation="vertical" >

View file

@ -146,7 +146,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if(getArguments() == null || getArguments().getString("SipUri") == null) {
newChatConversation = true;
Log.w("lala");
} else {
//Retrieve parameter from intent
sipUri = getArguments().getString("SipUri");
@ -468,7 +467,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
chatRoom = lc.getChatRoom(lAddress);
chatRoom.markAsRead();
contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
displayChatHeader(lAddress);
if(chatRoom != null) {
displayChatHeader(lAddress);
dispayMessageList();
}
}
}
@ -493,12 +495,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
this.pictureUri = pictureUri;
initChatRoom(sipUri);
if(chatRoom != null) {
LinphoneAddress lAddress = chatRoom.getPeerAddress();
displayChatHeader(lAddress);
dispayMessageList();
}
}
@Override
@ -608,12 +604,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
LinphoneManager.addListener(this);
// Force hide keyboard
boolean isOrientationLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
if(isOrientationLandscape) {
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
} else {
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
String draft = getArguments().getString("messageDraft");
message.setText(draft);
@ -621,7 +612,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if(!newChatConversation) {
initChatRoom(sipUri);
remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
dispayMessageList();
}
super.onResume();
}
@ -709,6 +699,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
editList.setVisibility(View.VISIBLE);
isEditMode = true;
dispayMessageList();
//TODO refaire la liste
}
if(id == R.id.start_call){
LinphoneActivity.instance().setAddresGoToDialerAndCall(sipUri, LinphoneUtils.getUsernameFromAddress(sipUri), null);
@ -740,6 +731,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if (chatRoom != null && messageToSend != null && messageToSend.length() > 0 && isNetworkReachable) {
LinphoneChatMessage message = chatRoom.createLinphoneChatMessage(messageToSend);
chatRoom.sendChatMessage(message);
lAddress = chatRoom.getPeerAddress();
if (LinphoneActivity.isInstanciated()) {
LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
@ -761,6 +753,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
private void sendImageMessage(String path, int imageSize) {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();
if(newChatConversation && chatRoom == null) {
String address = searchContactField.getText().toString();
if (address != null && !address.equals("")) {
initChatRoom(address);
}
}
invalidate();
if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) {