Improve launch speed

This commit is contained in:
世界 2021-03-12 15:26:52 +08:00
parent 83278a4d76
commit f31999e653
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
4 changed files with 25 additions and 23 deletions

View File

@ -51,7 +51,7 @@ public class GcmImpl implements ExternalGcm.Interface {
@Override @Override
public void initPlayServices() { public void initPlayServices() {
UIUtil.runOnIoDispatcher(() -> { Utilities.stageQueue.postRunnable(() -> {
if (hasPlayServices = checkPlayServices()) { if (hasPlayServices = checkPlayServices()) {
final String currentPushString = SharedConfig.pushString; final String currentPushString = SharedConfig.pushString;
if (!TextUtils.isEmpty(currentPushString)) { if (!TextUtils.isEmpty(currentPushString)) {

View File

@ -216,7 +216,7 @@ public class ApplicationLoader extends Application {
} }
applicationInited = true; applicationInited = true;
UIUtil.runOnIoDispatcher(() -> { Utilities.stageQueue.postRunnable(() -> {
try { try {
LocaleController.getInstance(); //TODO improve LocaleController.getInstance(); //TODO improve
@ -295,7 +295,7 @@ public class ApplicationLoader extends Application {
} }
}; };
if (finalA == UserConfig.selectedAccount) initRunnable.run(); if (finalA == UserConfig.selectedAccount) initRunnable.run();
else UIUtil.runOnIoDispatcher(initRunnable); else Utilities.stageQueue.postRunnable(initRunnable);
} }
ExternalGcm.initPlayServices(); ExternalGcm.initPlayServices();
@ -311,7 +311,7 @@ public class ApplicationLoader extends Application {
DownloadController.getInstance(finalA); DownloadController.getInstance(finalA);
}; };
if (finalA == UserConfig.selectedAccount) initRunnable.run(); if (finalA == UserConfig.selectedAccount) initRunnable.run();
else UIUtil.runOnIoDispatcher(initRunnable); else Utilities.stageQueue.postRunnable(initRunnable);
} }
} }
@ -369,7 +369,7 @@ public class ApplicationLoader extends Application {
} }
public static void startPushService() { public static void startPushService() {
UIUtil.runOnIoDispatcher(ApplicationLoader::startPushServiceInternal); Utilities.stageQueue.postRunnable(ApplicationLoader::startPushServiceInternal);
} }
private static void startPushServiceInternal() { private static void startPushServiceInternal() {

View File

@ -254,8 +254,6 @@ public class LocaleController {
} }
} }
} }
if (localInstance.formatterDay == null || localInstance.chatFullDate == null)
localInstance.recreateFormatters();
return localInstance; return localInstance;
} }

View File

@ -362,27 +362,31 @@ public class ConnectionsManager extends BaseController {
public void init(int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String systemLangCode, String configPath, String logPath, String regId, String cFingerprint, int timezoneOffset, int userId, boolean enablePushConnection) { public void init(int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String systemLangCode, String configPath, String logPath, String regId, String cFingerprint, int timezoneOffset, int userId, boolean enablePushConnection) {
SharedConfig.loadProxyList(); Utilities.stageQueue.postRunnable(() -> {
if (SharedConfig.proxyEnabled && SharedConfig.currentProxy != null) { SharedConfig.loadProxyList();
if (SharedConfig.currentProxy instanceof SharedConfig.ExternalSocks5Proxy) {
((SharedConfig.ExternalSocks5Proxy) SharedConfig.currentProxy).start(); if (SharedConfig.proxyEnabled && SharedConfig.currentProxy != null) {
if (SharedConfig.currentProxy instanceof SharedConfig.ExternalSocks5Proxy) {
((SharedConfig.ExternalSocks5Proxy) SharedConfig.currentProxy).start();
}
native_setProxySettings(currentAccount, SharedConfig.currentProxy.address, SharedConfig.currentProxy.port, SharedConfig.currentProxy.username, SharedConfig.currentProxy.password, SharedConfig.currentProxy.secret);
} }
native_setProxySettings(currentAccount, SharedConfig.currentProxy.address, SharedConfig.currentProxy.port, SharedConfig.currentProxy.username, SharedConfig.currentProxy.password, SharedConfig.currentProxy.secret);
}
String installer = ""; String installer = "";
try { try {
installer = ApplicationLoader.applicationContext.getPackageManager().getInstallerPackageName(ApplicationLoader.applicationContext.getPackageName()); installer = ApplicationLoader.applicationContext.getPackageManager().getInstallerPackageName(ApplicationLoader.applicationContext.getPackageName());
} catch (Throwable ignore) { } catch (Throwable ignore) {
} }
if (installer == null) { if (installer == null) {
installer = ""; installer = "";
} }
native_init(currentAccount, version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, systemLangCode, configPath, logPath, regId, cFingerprint, installer, timezoneOffset, userId, enablePushConnection, ApplicationLoader.isNetworkOnline(), ApplicationLoader.getCurrentNetworkType()); native_init(currentAccount, version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, systemLangCode, configPath, logPath, regId, cFingerprint, installer, timezoneOffset, userId, enablePushConnection, ApplicationLoader.isNetworkOnline(), ApplicationLoader.getCurrentNetworkType());
checkConnection(); checkConnection();
});
} }