Manos Chorianopoulos

fix WebviewVC (add webviewDidFocusRefresh script)

...@@ -30,6 +30,7 @@ var timer2: DispatchSourceTimer? ...@@ -30,6 +30,7 @@ var timer2: DispatchSourceTimer?
30 var listenersCount = 0; 30 var listenersCount = 0;
31 31
32 var webViewLoaded: Bool = false 32 var webViewLoaded: Bool = false
33 + var mWebviewSupermarket: Bool = false
33 34
34 public override func loadView() { 35 public override func loadView() {
35 super.loadView(); 36 super.loadView();
...@@ -95,6 +96,10 @@ var timer2: DispatchSourceTimer? ...@@ -95,6 +96,10 @@ var timer2: DispatchSourceTimer?
95 96
96 sendWebviewDidFocus() 97 sendWebviewDidFocus()
97 } 98 }
99 +
100 + if(mWebviewSupermarket) {
101 + sendWebviewDidFocusRefresh()
102 + }
98 } 103 }
99 104
100 public override func viewWillDisappear(_ animated: Bool) { 105 public override func viewWillDisappear(_ animated: Bool) {
...@@ -142,6 +147,7 @@ var timer2: DispatchSourceTimer? ...@@ -142,6 +147,7 @@ var timer2: DispatchSourceTimer?
142 // Handle code when the application is about to enter the foreground 147 // Handle code when the application is about to enter the foreground
143 148
144 sendWebviewDidFocus() 149 sendWebviewDidFocus()
150 + sendWebviewDidFocusRefresh()
145 } 151 }
146 152
147 @objc func applicationDidEnterBackground() { 153 @objc func applicationDidEnterBackground() {
...@@ -162,6 +168,18 @@ var timer2: DispatchSourceTimer? ...@@ -162,6 +168,18 @@ var timer2: DispatchSourceTimer?
162 }) 168 })
163 } 169 }
164 170
171 + func sendWebviewDidFocusRefresh() {
172 + let scriptSource2 = "webviewDidFocusRefresh(\(self.webviewDidFocusRefresh));"
173 +
174 + webView.evaluateJavaScript(scriptSource2, completionHandler: { (object, error) in
175 + self.mWebviewSupermarket = false
176 + // print("==== webviewDidFocus object ====")
177 + // print(object)
178 + // print("==== webviewDidFocus error ====")
179 + // print(error)
180 + })
181 + }
182 +
165 func addApplicationObservers() { 183 func addApplicationObservers() {
166 NotificationCenter.default.addObserver(self, selector: #selector(applicationWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil) 184 NotificationCenter.default.addObserver(self, selector: #selector(applicationWillEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
167 NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil) 185 NotificationCenter.default.addObserver(self, selector: #selector(applicationDidEnterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
...@@ -493,7 +511,7 @@ var timer2: DispatchSourceTimer? ...@@ -493,7 +511,7 @@ var timer2: DispatchSourceTimer?
493 511
494 if (eventArray[0] == "event") { 512 if (eventArray[0] == "event") {
495 if (eventArray[1] == "closeArtwork") { 513 if (eventArray[1] == "closeArtwork") {
496 - 514 + self.mWebviewSupermarket = false
497 self.navigationController?.popViewController(animated: true) 515 self.navigationController?.popViewController(animated: true)
498 516
499 } else if (eventArray[1] == "addUserTag") { 517 } else if (eventArray[1] == "addUserTag") {
...@@ -842,6 +860,9 @@ var timer2: DispatchSourceTimer? ...@@ -842,6 +860,9 @@ var timer2: DispatchSourceTimer?
842 } 860 }
843 } 861 }
844 862
863 + } else if (eventArray[1] == "webviewRefresh") {
864 + self.mWebviewSupermarket = true
865 +
845 } 866 }
846 867
847 } 868 }
......