Commit cfba5bad authored by 李增强's avatar 李增强

增加初始化完成等待

parent 44ad10bd
...@@ -17,6 +17,7 @@ class QMTJ { ...@@ -17,6 +17,7 @@ class QMTJ {
static Page _page; static Page _page;
static Tap _tap; static Tap _tap;
static Exposure _exposure; static Exposure _exposure;
static Future<bool> _ready;
static void debug() { static void debug() {
Utils.debug(); Utils.debug();
...@@ -39,6 +40,7 @@ class QMTJ { ...@@ -39,6 +40,7 @@ class QMTJ {
_tap = Tap(_db); _tap = Tap(_db);
_exposure = Exposure(_db); _exposure = Exposure(_db);
_db.init(); _db.init();
_ready = new Future.value(true);
Future.delayed(Duration(seconds: 5)).then((value) async { Future.delayed(Duration(seconds: 5)).then((value) async {
await _app.upload(); await _app.upload();
await _page.upload(); await _page.upload();
...@@ -49,23 +51,27 @@ class QMTJ { ...@@ -49,23 +51,27 @@ class QMTJ {
/// APP 可见 /// APP 可见
static void onAppResume({Map<String, dynamic> extras}) async { static void onAppResume({Map<String, dynamic> extras}) async {
await _ready;
_app.onResume(extras: extras); _app.onResume(extras: extras);
} }
/// APP 不可见 /// APP 不可见
static void onAppPause() async { static void onAppPause() async {
await _ready;
_app.onPause(); _app.onPause();
} }
/// PAGE 可见 /// PAGE 可见
static void onPageResume( static void onPageResume(
{String pageId, String lastPageId, Map<String, dynamic> extras}) async { {String pageId, String lastPageId, Map<String, dynamic> extras}) async {
await _ready;
_page.onResume(pageId: pageId, lastPageId: lastPageId, extras: extras); _page.onResume(pageId: pageId, lastPageId: lastPageId, extras: extras);
} }
/// PAGE 不可见 /// PAGE 不可见
static void onPagePause( static void onPagePause(
{String pageId, String lastPageId, Map<String, dynamic> extras}) async { {String pageId, String lastPageId, Map<String, dynamic> extras}) async {
await _ready;
_page.onPause(pageId: pageId, lastPageId: lastPageId, extras: extras); _page.onPause(pageId: pageId, lastPageId: lastPageId, extras: extras);
} }
...@@ -75,6 +81,7 @@ class QMTJ { ...@@ -75,6 +81,7 @@ class QMTJ {
/// [extras] 点击参数 /// [extras] 点击参数
static void tap( static void tap(
{String pageId, String clickId, Map<String, dynamic> extras}) async { {String pageId, String clickId, Map<String, dynamic> extras}) async {
await _ready;
_tap.onTap(pageId: pageId, clickId: clickId, extras: extras); _tap.onTap(pageId: pageId, clickId: clickId, extras: extras);
} }
...@@ -84,6 +91,7 @@ class QMTJ { ...@@ -84,6 +91,7 @@ class QMTJ {
/// [extras] 曝光参数 /// [extras] 曝光参数
static void exposure( static void exposure(
{String pageId, String exposureId, Map<String, dynamic> extras}) async { {String pageId, String exposureId, Map<String, dynamic> extras}) async {
await _ready;
_exposure.onExposure( _exposure.onExposure(
pageId: pageId, exposureId: exposureId, extras: extras); pageId: pageId, exposureId: exposureId, extras: extras);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment