Put back the worker thread for account manager in android

This commit is contained in:
Gabriel Calero 2018-05-11 16:09:40 -03:00
parent e838a85a47
commit db460e9856
5 changed files with 17 additions and 18 deletions

View file

@ -236,7 +236,6 @@ public class HomeActivity extends AppCompatActivity implements NavigationView.On
}
@Override
public void onBackPressed() {
QtActivity.forceQuit();
finish();
}

View file

@ -69,9 +69,6 @@ public class QtActivity extends Activity {
private QtActivityLoader m_loader = new QtActivityLoader(this);
public boolean isLoading;
private boolean forcedQuit;
public static QtActivity instance;
public QtActivity() {
}
@ -240,7 +237,6 @@ public class QtActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
onCreateHook(savedInstanceState);
instance = this;
}
//---------------------------------------------------------------------------
@ -366,7 +362,6 @@ public class QtActivity extends Activity {
protected void onDestroy() {
super.onDestroy();
QtApplication.invokeDelegate();
instance = null;
}
//---------------------------------------------------------------------------
@ -643,24 +638,13 @@ public class QtActivity extends Activity {
protected void onStart() {
super.onStart();
QtApplication.invokeDelegate();
if (forcedQuit) {
finish();
}
}
//---------------------------------------------------------------------------
@Override
protected void onStop() {
super.onStop();
if (forcedQuit) {
QtApplication.invokeDelegate();
}
}
public static void forceQuit() {
if (instance != null) {
instance.forcedQuit = true;
}
QtApplication.invokeDelegate();
}
//---------------------------------------------------------------------------

View file

@ -10,11 +10,19 @@
//
#include "AndroidHelper.h"
#include <QDebug>
#include <AccountManager.h>
AndroidHelper::AndroidHelper() {
workerThread.start();
}
AndroidHelper::~AndroidHelper() {
workerThread.quit();
workerThread.wait();
}
void AndroidHelper::init() {
DependencyManager::get<AccountManager>()->moveToThread(&workerThread);
}
void AndroidHelper::requestActivity(const QString &activityName) {

View file

@ -13,6 +13,7 @@
#define hifi_Android_Helper_h
#include <QObject>
#include <QThread>
class AndroidHelper : public QObject {
Q_OBJECT
@ -21,6 +22,7 @@ public:
static AndroidHelper instance;
return instance;
}
void init();
void requestActivity(const QString &activityName);
void notifyLoadComplete();
void goBackFromAndroidActivity();
@ -35,6 +37,7 @@ signals:
private:
AndroidHelper();
~AndroidHelper();
QThread workerThread;
};
#endif

View file

@ -850,7 +850,11 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
DependencyManager::set<Cursor::Manager>();
DependencyManager::set<VirtualPad::Manager>();
DependencyManager::set<DesktopPreviewProvider>();
#if defined(Q_OS_ANDROID)
DependencyManager::set<AccountManager>(); // use the default user agent getter
#else
DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp));
#endif
DependencyManager::set<StatTracker>();
DependencyManager::set<ScriptEngines>(ScriptEngine::CLIENT_SCRIPT);
DependencyManager::set<ScriptInitializerMixin, NativeScriptInitializers>();
@ -2246,6 +2250,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID());
#if defined(Q_OS_ANDROID)
AndroidHelper::instance().init();
AndroidHelper::instance().notifyLoadComplete();
#endif
}