|
|
@@ -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
|
|
|
}
|
|
|
}
|
|
|
}
|