Fix crash when rotating the phone while uploading a picture
This commit is contained in:
parent
e48ecd5109
commit
9bba6a3b64
3 changed files with 22 additions and 1 deletions
|
@ -117,6 +117,7 @@
|
||||||
|
|
||||||
<activity android:name="org.linphone.ChatActivity"
|
<activity android:name="org.linphone.ChatActivity"
|
||||||
android:theme="@style/NoTitle"
|
android:theme="@style/NoTitle"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||||
android:windowSoftInputMode="adjustPan|adjustResize"
|
android:windowSoftInputMode="adjustPan|adjustResize"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
|
@ -20,11 +20,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Margaux Clerc
|
* @author Margaux Clerc
|
||||||
*/
|
*/
|
||||||
public class ChatActivity extends FragmentActivity {
|
public class ChatActivity extends FragmentActivity {
|
||||||
|
private static final String CHAT_FRAGMENT = "chatFragment";
|
||||||
|
private ChatFragment chatFragment;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -39,6 +43,17 @@ public class ChatActivity extends FragmentActivity {
|
||||||
ChatFragment fragment = new ChatFragment();
|
ChatFragment fragment = new ChatFragment();
|
||||||
fragment.setArguments(extras);
|
fragment.setArguments(extras);
|
||||||
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, fragment, "ChatFragment").commit();
|
getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, fragment, "ChatFragment").commit();
|
||||||
|
|
||||||
|
FragmentManager fm = getSupportFragmentManager();
|
||||||
|
chatFragment = (ChatFragment) fm.findFragmentByTag(CHAT_FRAGMENT);
|
||||||
|
|
||||||
|
// If the Fragment is non-null, then it is currently being
|
||||||
|
// retained across a configuration change.
|
||||||
|
if (chatFragment == null) {
|
||||||
|
chatFragment = new ChatFragment();
|
||||||
|
chatFragment.setArguments(extras);
|
||||||
|
fm.beginTransaction().add(R.id.fragmentContainer, chatFragment, CHAT_FRAGMENT).commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
instance = this;
|
instance = this;
|
||||||
View view = inflater.inflate(R.layout.chat, container, false);
|
View view = inflater.inflate(R.layout.chat, container, false);
|
||||||
|
|
||||||
|
// Retain the fragment across configuration changes
|
||||||
|
setRetainInstance(true);
|
||||||
|
|
||||||
//Retrieve parameter from intent
|
//Retrieve parameter from intent
|
||||||
sipUri = getArguments().getString("SipUri");
|
sipUri = getArguments().getString("SipUri");
|
||||||
displayName = getArguments().getString("DisplayName");
|
displayName = getArguments().getString("DisplayName");
|
||||||
|
@ -562,7 +565,9 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(byte[] result) {
|
protected void onPostExecute(byte[] result) {
|
||||||
progressDialog.dismiss();
|
if (progressDialog != null && progressDialog.isShowing()) {
|
||||||
|
progressDialog.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
mUploadingImageStream = new ByteArrayInputStream(result);
|
mUploadingImageStream = new ByteArrayInputStream(result);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue