Selaa lähdekoodia

hilangkan helper untuk pengecekan ip adress

Hendi 2 vuotta sitten
vanhempi
commit
d92f504d22

BIN
Sirani.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 11
Sirani/View/Account/Login/LoginVC.swift

@@ -196,17 +196,7 @@ class LoginVC: UIViewController {
     private func login(username: String, password: String) {
         if !loading {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.login(username: username, password: password)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.login(username: username, password: password)
             } else {
                 showNoConnection()
             }

+ 2 - 23
Sirani/View/Aplikasi/AplikasiVC.swift

@@ -68,18 +68,7 @@ class AplikasiVC: UIViewController {
     private func loadData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(status: self.status, limit: self.limit, page: self.page, search: self.search)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
-                
+                self.presenter.loadData(status: self.status, limit: self.limit, page: self.page, search: self.search)
             } else {
                 showNoConnection()
             }
@@ -89,17 +78,7 @@ class AplikasiVC: UIViewController {
     private func downloadFile(urlWeb: String, filename: String) {
         if !loading {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.downloadFile(urlWeb: urlWeb, filename: filename)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.downloadFile(urlWeb: urlWeb, filename: filename)
             } else {
                 showNoConnection()
             }

+ 23 - 43
Sirani/View/BalaiUji/Index/BalaiUjiVC.swift

@@ -76,17 +76,7 @@ class BalaiUjiVC: UIViewController {
     private func loadData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(status: self.status, limit: self.limit, page: self.page, jenis: self.jenis, search: self.search)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadData(status: self.status, limit: self.limit, page: self.page, jenis: self.jenis, search: self.search)
             } else {
                 showNoConnection()
             }
@@ -109,38 +99,28 @@ class BalaiUjiVC: UIViewController {
     @IBAction func onBtnLuarNegeriDataTap(_ sender: Any) {
         if !loading {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.progressLoading.show()
-                            self.loading = true
-                            
-                            let filename = "2019_Pengakuan_Balai_Uji_Asing.pdf";
-                            let destination: DownloadRequest.Destination = { _, _ in
-                                let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
-                                let fileURL = documentsURL.appendingPathComponent(filename)
-                                return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
-                            }
-                            
-                            let urlRequest = "https://sertifikasi.postel.go.id/esertifikasi_mobile/assets/file/2019_Pengakuan_Balai_Uji_Asing.pdf"
-                            AF.download(urlRequest, to: destination).validate().responseData { response in
-                                if let url = response.fileURL {
-                                    self.documentInteractorController = UIDocumentInteractionController()
-                                    self.documentInteractorController.delegate = self
-                                    self.documentInteractorController.url = url
-                                    self.documentInteractorController.presentPreview(animated: true)
-                                }
-                                
-                                DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
-                                    self.progressLoading.hide()
-                                    self.loading = false
-                                }
-                            }
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
+                self.progressLoading.show()
+                self.loading = true
+                
+                let filename = "2019_Pengakuan_Balai_Uji_Asing.pdf";
+                let destination: DownloadRequest.Destination = { _, _ in
+                    let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+                    let fileURL = documentsURL.appendingPathComponent(filename)
+                    return (fileURL, [.removePreviousFile, .createIntermediateDirectories])
+                }
+                
+                let urlRequest = "https://sertifikasi.postel.go.id/esertifikasi_mobile/assets/file/2019_Pengakuan_Balai_Uji_Asing.pdf"
+                AF.download(urlRequest, to: destination).validate().responseData { response in
+                    if let url = response.fileURL {
+                        self.documentInteractorController = UIDocumentInteractionController()
+                        self.documentInteractorController.delegate = self
+                        self.documentInteractorController.url = url
+                        self.documentInteractorController.presentPreview(animated: true)
+                    }
+                    
+                    DispatchQueue.main.asyncAfter(deadline: .now() + 0.6) {
+                        self.progressLoading.hide()
+                        self.loading = false
                     }
                 }
             }

+ 1 - 11
Sirani/View/DaftarSertifikat/Index/DaftarSertifikatVC.swift

@@ -73,17 +73,7 @@ class DaftarSertifikatVC: UIViewController {
     private func loadCertificateData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadCertificatesData(jenis: self.jenis, columns: self.columns, cursor: self.cursor, prev: self.prev, search: self.search)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadCertificatesData(jenis: self.jenis, columns: self.columns, cursor: self.cursor, prev: self.prev, search: self.search)
             } else {
                 showNoConnection()
             }

+ 2 - 23
Sirani/View/Faq/FaqList/FaqVC.swift

@@ -91,17 +91,7 @@ class FaqVC: UIViewController {
     // private functions
     private func loadDataCategories() {
         if ConnectionHelper.isConnectedToNetwork() {
-            ConnectionHelper.checkIpAddress { [weak self] success in
-                guard let self = self else { return }
-
-                DispatchQueue.main.async {
-                    if success {
-                        self.presenter.loadDataCategory()
-                    } else {
-                        CommonHelper.showNotAllowConnection(in: self)
-                    }
-                }
-            }
+            self.presenter.loadDataCategory()
         } else {
             showNoConnection()
         }
@@ -113,18 +103,7 @@ class FaqVC: UIViewController {
                 self.faqContents.removeAll()
                 tvFaqContent.reloadData()
             }
-            
-            ConnectionHelper.checkIpAddress { [weak self] success in
-                guard let self = self else { return }
-
-                DispatchQueue.main.async {
-                    if success {
-                        self.presenter.loadDataContent(faq_cat_id: categoryId)
-                    } else {
-                        CommonHelper.showNotAllowConnection(in: self)
-                    }
-                }
-            }
+            self.presenter.loadDataContent(faq_cat_id: categoryId)
             
         } else {
             showNoConnection()

+ 5 - 61
Sirani/View/Home/HomeVC.swift

@@ -221,17 +221,7 @@ class HomeVC: UIViewController {
                 clearMoreMenuNotifData()
                 
                 if ConnectionHelper.isConnectedToNetwork() {
-                    ConnectionHelper.checkIpAddress { [weak self] success in
-                        guard let self = self else { return }
-
-                        DispatchQueue.main.async {
-                            if success {
-                                self.presenter.loadMenuNotifications()
-                            } else {
-                                CommonHelper.showNotAllowConnection(in: self)
-                            }
-                        }
-                    }
+                    self.presenter.loadMenuNotifications()
                 } else {
                     CommonHelper.showNoConnection(in: self)
                 }
@@ -277,17 +267,7 @@ class HomeVC: UIViewController {
         notifContainer.show()
         
         if ConnectionHelper.isConnectedToNetwork() {
-            ConnectionHelper.checkIpAddress { [weak self] success in
-                guard let self = self else { return }
-
-                DispatchQueue.main.async {
-                    if success {
-                        self.presenter.loadTotalUnreadNotif()
-                    } else {
-                        CommonHelper.showNotAllowConnection(in: self)
-                    }
-                }
-            }
+            self.presenter.loadTotalUnreadNotif()
         } else {
             CommonHelper.showNoConnection(in: self)
         }
@@ -319,20 +299,7 @@ class HomeVC: UIViewController {
         homeNewsTV.tableFooterView = footer
         
         if ConnectionHelper.isConnectedToNetwork() {
-            ConnectionHelper.checkIpAddress { [weak self] success in
-                guard let self = self else { return }
-
-                DispatchQueue.main.async {
-                    if success {
-                        print("call news")
-                        self.presenter.loadNews(cursor: 5, prev: 1, jenis: "", columns: "")
-                    } else {
-                        CommonHelper.showNotAllowConnection(in: self)
-                        self.listNews.removeAll()
-                        self.homeNewsTV.reloadData()
-                    }
-                }
-            }
+            self.presenter.loadNews(cursor: 5, prev: 1, jenis: "", columns: "")
         } else {
             CommonHelper.showNoConnection(in: self)
         }
@@ -340,20 +307,7 @@ class HomeVC: UIViewController {
 
     private func setSlideImageView() {
         if ConnectionHelper.isConnectedToNetwork() {
-            ConnectionHelper.checkIpAddress { [weak self] success in
-                guard let self = self else { return }
-
-                DispatchQueue.main.async {
-                    if success {
-                        print("call slideimage")
-                        self.presenter.loadSlideshowImages()
-                    } else {
-                        CommonHelper.showNotAllowConnection(in: self)
-                        self.slideshow.setImageInputs([])
-                        self.slideshow.reloadInputViews()
-                    }
-                }
-            }
+            self.presenter.loadSlideshowImages()
         } else {
             CommonHelper.showNoConnection(in: self)
         }
@@ -696,17 +650,7 @@ class HomeVC: UIViewController {
                 clearMoreMenuNotifData()
                 
                 if ConnectionHelper.isConnectedToNetwork() {
-                    ConnectionHelper.checkIpAddress { [weak self] success in
-                        guard let self = self else { return }
-
-                        DispatchQueue.main.async {
-                            if success {
-                                self.presenter.loadMenuNotifications()
-                            } else {
-                                CommonHelper.showNotAllowConnection(in: self)
-                            }
-                        }
-                    }
+                    self.presenter.loadMenuNotifications()
                 } else {
                     CommonHelper.showNoConnection(in: self)
                 }

+ 2 - 23
Sirani/View/Label/LabelVC.swift

@@ -70,17 +70,7 @@ class LabelVC: UIViewController {
     private func loadData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(status: self.status, limit: self.limit, page: self.page, search: self.search)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadData(status: self.status, limit: self.limit, page: self.page, search: self.search)
             } else {
                 showNoConnection()
             }
@@ -90,18 +80,7 @@ class LabelVC: UIViewController {
     private func downloadFile(urlWeb: String, filename: String) {
         if !loading {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.downloadFile(urlWeb: urlWeb, filename: filename)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
-                
+                self.presenter.downloadFile(urlWeb: urlWeb, filename: filename)
             } else {
                 showNoConnection()
             }

+ 1 - 11
Sirani/View/News/Detail/NewsDetailVC.swift

@@ -75,17 +75,7 @@ class NewsDetailVC: UIViewController {
         if !loading {
             if ConnectionHelper.isConnectedToNetwork() {
                 print("Load data \(newsId)")
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(newsId: self.newsId)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadData(newsId: self.newsId)
             } else {
                 showNoConnection()
             }

+ 1 - 11
Sirani/View/News/Index/NewsVC.swift

@@ -93,17 +93,7 @@ class NewsVC: UIViewController {
     private func loadData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(cursor: self.cursor, prev: self.prev, jenis: self.jenis, columns: self.columns, keyword: self.keyword)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadData(cursor: self.cursor, prev: self.prev, jenis: self.jenis, columns: self.columns, keyword: self.keyword)
                 
             } else {
                 showNoConnection()

+ 2 - 23
Sirani/View/Notification/NotificationDetail/NotificationDetailVC.swift

@@ -75,18 +75,7 @@ class NotificationDetailVC: UIViewController {
     private func loadData(notifId: Int) {
         if !loading {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(notifId: notifId)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
-                
+                self.presenter.loadData(notifId: notifId)
             }
             else {
                CommonHelper.showNoConnection(in: self)
@@ -128,17 +117,7 @@ extension NotificationDetailVC: NotificationDetailViewDelegate {
         lblCatatan.text = "\(notificationDetail.note)"
 
         if ConnectionHelper.isConnectedToNetwork() {
-            ConnectionHelper.checkIpAddress { [weak self] success in
-                guard let self = self else { return }
-
-                DispatchQueue.main.async {
-                    if success {
-                        self.presenter.loadData(notifId: self.notifId)
-                    } else {
-                        CommonHelper.showNotAllowConnection(in: self)
-                    }
-                }
-            }
+            self.presenter.loadData(notifId: self.notifId)
         } else {
             CommonHelper.showNoConnection(in: self)
         }

+ 1 - 14
Sirani/View/Notification/NotificationList/NotificationListVC.swift

@@ -90,20 +90,7 @@ class NotificationListVC: UIViewController {
     private func loadData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                if ConnectionHelper.isConnectedToNetwork() {
-                    ConnectionHelper.checkIpAddress { [weak self] success in
-                        guard let self = self else { return }
-
-                        DispatchQueue.main.async {
-                            if success {
-                                self.presenter.loadData(cursor: self.cursor, prev: self.prev)
-                            } else {
-                                CommonHelper.showNotAllowConnection(in: self)
-                            }
-                        }
-                    }
-                    
-                }
+                self.presenter.loadData(cursor: self.cursor, prev: self.prev)
                 
             } else {
                 showNoConnection()

+ 1 - 11
Sirani/View/ScanQR/Scanner/QRScannerVC.swift

@@ -167,17 +167,7 @@ class QRScannerVC: UIViewController {
     private func loadData(code: String) {
         if !loading {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(code: code)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadData(code: code)
             } else {
                 showNoConnection()
             }

+ 1 - 11
Sirani/View/Sertifikat/SertifikatPrivate/SertifikatViewController.swift

@@ -69,17 +69,7 @@ class SertifikatViewController: UIViewController {
     private func loadCertificateData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadPrivateCertificatesData(status: self.status, limit: self.limit, page: self.page, search: self.search)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadPrivateCertificatesData(status: self.status, limit: self.limit, page: self.page, search: self.search)
             } else {
                 showNoConnection()
             }

+ 1 - 11
Sirani/View/Sertifikat/SertifikatPublic/SertifikatPublicVC.swift

@@ -69,17 +69,7 @@ class SertifikatPublicVC: UIViewController {
     private func loadCertificateData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadPublicCertificatesData(status: self.status, limit: self.limit, page: self.page, search: self.search)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadPublicCertificatesData(status: self.status, limit: self.limit, page: self.page, search: self.search)
             } else {
                 CommonHelper.showNoConnection(in: self)
             }

+ 1 - 11
Sirani/View/TarifSertifikat/Index/TarifSertifikatVC.swift

@@ -73,17 +73,7 @@ class TarifSertifikatVC: UIViewController {
     private func loadData() {
         if !loading && !lastDataLoadedEmpty {
             if ConnectionHelper.isConnectedToNetwork() {
-                ConnectionHelper.checkIpAddress { [weak self] success in
-                    guard let self = self else { return }
-
-                    DispatchQueue.main.async {
-                        if success {
-                            self.presenter.loadData(jenis: self.jenis, columns: self.columns, cursor: self.cursor, prev: self.prev, search: self.search)
-                        } else {
-                            CommonHelper.showNotAllowConnection(in: self)
-                        }
-                    }
-                }
+                self.presenter.loadData(jenis: self.jenis, columns: self.columns, cursor: self.cursor, prev: self.prev, search: self.search)
             } else {
                 showNoConnection()
             }