Try to fix cleanup

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-01-12 15:59:09 +01:00
parent e6cef58837
commit a0763be26b
3 changed files with 14 additions and 18 deletions

View File

@ -939,10 +939,7 @@ public class CallActivity extends AppCompatActivity {
private void deleteMagicPeerConnection(MagicPeerConnectionWrapper magicPeerConnectionWrapper) {
if (magicPeerConnectionWrapper.getPeerConnection() != null) {
magicPeerConnectionWrapper.removeMediaStream();
magicPeerConnectionWrapper.getPeerConnection().close();
}
magicPeerConnectionWrapper.removePeerConnection(magicPeerConnectionWrapperList.size() == 1);
magicPeerConnectionWrapperList.remove(magicPeerConnectionWrapper);
}
@ -1209,8 +1206,6 @@ public class CallActivity extends AppCompatActivity {
MagicPeerConnectionWrapper magicPeerConnectionWrapper;
if ((magicPeerConnectionWrapper = getPeerConnectionWrapperForSessionId(sessionId)) != null) {
runOnUiThread(() -> removeMediaStream(sessionId));
magicPeerConnectionWrapper.removeMediaStream();
magicPeerConnectionWrapper.removePeerConnection();
deleteMagicPeerConnection(magicPeerConnectionWrapper);
}
}

View File

@ -178,7 +178,7 @@ public class SettingsController extends BaseController {
true);
if (!TextUtils.isEmpty(getResources().getString(R.string.nc_gpl3_url))) {
licenceButton.setOnClickListener(view1 -> {
licenceButton.addPreferenceClickListener(view1 -> {
sourceCodeButton.setEnabled(false);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().
getString(R.string.nc_gpl3_url)));
@ -190,7 +190,7 @@ public class SettingsController extends BaseController {
}
if (!TextUtils.isEmpty(getResources().getString(R.string.nc_privacy_url))) {
privacyButton.setOnClickListener(view12 -> {
privacyButton.addPreferenceClickListener(view12 -> {
sourceCodeButton.setEnabled(false);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().
getString(R.string.nc_privacy_url)));
@ -202,7 +202,7 @@ public class SettingsController extends BaseController {
}
if (!TextUtils.isEmpty(getResources().getString(R.string.nc_source_code_url))) {
sourceCodeButton.setOnClickListener(view13 -> {
sourceCodeButton.addPreferenceClickListener(view13 -> {
sourceCodeButton.setEnabled(false);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().
getString(R.string.nc_source_code_url)));
@ -216,14 +216,14 @@ public class SettingsController extends BaseController {
versionInfo.setSummary("v" + BuildConfig.VERSION_NAME);
addAccountButton.setOnClickListener(view15 -> {
addAccountButton.addPreferenceClickListener(view15 -> {
addAccountButton.setEnabled(false);
getParentController().getRouter().pushController(RouterTransaction.with(new
ServerSelectionController()).pushChangeHandler(new VerticalChangeHandler())
.popChangeHandler(new VerticalChangeHandler()));
});
switchAccountButton.setOnClickListener(view16 -> {
switchAccountButton.addPreferenceClickListener(view16 -> {
switchAccountButton.setEnabled(false);
getParentController().getRouter().pushController(RouterTransaction.with(new
SwitchAccountController()).pushChangeHandler(new VerticalChangeHandler())
@ -255,7 +255,7 @@ public class SettingsController extends BaseController {
baseUrlTextView.setText(userEntity.getBaseUrl());
reauthorizeButton.setOnClickListener(view14 -> {
reauthorizeButton.addPreferenceClickListener(view14 -> {
reauthorizeButton.setEnabled(false);
getParentController().getRouter().pushController(RouterTransaction.with(
new WebViewLoginController(userEntity.getBaseUrl(), true))
@ -317,7 +317,7 @@ public class SettingsController extends BaseController {
removeAccountButton.setEnabled(true);
removeAccountButton.setOnClickListener(view1 -> {
removeAccountButton.addPreferenceClickListener(view1 -> {
removeAccountButton.setEnabled(false);
cookieManager.getCookieStore().removeAll();
boolean otherUserExists = userUtils.scheduleUserForDeletionWithId(userEntity.getId());

View File

@ -92,13 +92,14 @@ public class MagicPeerConnectionWrapper {
}
}
public void removePeerConnection() {
peerConnection.close();
peerConnection = null;
}
public void removeMediaStream() {
public void removePeerConnection(boolean isFinal) {
if (peerConnection != null && localMediaStream != null) {
peerConnection.close();
peerConnection.removeStream(localMediaStream);
if (isFinal) {
peerConnection.dispose();
}
peerConnection = null;
}
}