stop io during configure(), call startIo()/stopIo() without is-running-check

This commit is contained in:
B. Petersen 2020-05-27 21:47:07 +02:00
parent 47f7ceb986
commit a15a82c353
No known key found for this signature in database
GPG key ID: 3B88E92DEA8E9AFC
4 changed files with 12 additions and 11 deletions

View file

@ -511,8 +511,10 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
// calling configure() results in
// receiving multiple DC_EVENT_CONFIGURE_PROGRESS events
DcHelper.getContext(this).captureNextError();
DcHelper.getContext(this).configure(); // TODO-ASYNC: make sure, io is stopped before and started afterwards
ApplicationDcContext dcContext = DcHelper.getContext(this);
dcContext.stopIo();
dcContext.captureNextError();
dcContext.configure();
}
private void setConfig(@IdRes int viewId, String configTarget, boolean doTrim) {
@ -534,6 +536,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
ApplicationDcContext dcContext = DcHelper.getContext(this);
long progress = (Long)data1;
if (progress==0/*error/aborted*/) {
dcContext.maybeStartIo(); // start-io is also needed on errors to make previous config work in case of changes
dcContext.endCaptureNextError();
progressDialog.dismiss();
if (dcContext.hasCapturedError()) {
@ -555,6 +558,7 @@ public class RegistrationActivity extends BaseActionBarActivity implements DcEve
progressDialog.setMessage(getResources().getString(R.string.one_moment)+String.format(" %d%%", percent));
}
else if (progress==1000/*done*/) {
dcContext.maybeStartIo();
dcContext.endCaptureNextError();
progressDialog.dismiss();
Intent conversationList = new Intent(getApplicationContext(), ConversationListActivity.class);

View file

@ -147,7 +147,8 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
// calling configure() results in
// receiving multiple DC_EVENT_CONFIGURE_PROGRESS events
dcContext.configure(); // TODO-ASYNC: make sure, io is stopped before and started afterwards
dcContext.stopIo();
dcContext.configure();
}
private void progressError() {
@ -192,12 +193,14 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
progressUpdate((int)progress);
}
else if (progress==1000/*done*/) {
dcContext.maybeStartIo();
progressSuccess(false);
}
}
else if (manualConfigure && eventId==DcContext.DC_EVENT_CONFIGURE_PROGRESS) {
long progress = (Long)data1;
if (progress==1000/*done*/) {
dcContext.maybeStartIo();
finish(); // remove ourself from the activity stack (finishAffinity is available in API 16, we're targeting API 14)
}
}

View file

@ -99,7 +99,7 @@ public class AccountManager {
// getSelectedAccount()
ApplicationContext appContext = (ApplicationContext)context.getApplicationContext();
appContext.dcContext.notificationCenter.removeAllNotifiations();
appContext.dcContext.maybeStopIo();
appContext.dcContext.stopIo();
appContext.dcContext.unref();
appContext.dcContext = new ApplicationDcContext(context);
}

View file

@ -116,17 +116,11 @@ public class ApplicationDcContext extends DcContext {
}
public void maybeStartIo() {
if (!isIoRunning()) {
if (isConfigured()!=0) {
startIo();
}
}
public void maybeStopIo() {
if (isIoRunning()) {
stopIo();
}
}
public void setStockTranslations() {
// the integers are defined in the core and used only here, an enum or sth. like that won't have a big benefit
setStockTranslation(1, context.getString(R.string.chat_no_messages));