Guest User

Untitled

a guest
Jan 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. val progresRing = ProgressDialog(this@AddExtraPicturesActivity)
  2. progresRing.isIndeterminate = true
  3. progresRing.setTitle("Uploading pictures")
  4. progresRing.setMessage("Please wait")
  5. progresRing.setCancelable(false)
  6.  
  7. progresRing.show()
  8. for (item in pictureList) {
  9.  
  10. if(item.pictureFile != null) {
  11. val file = item.pictureFile
  12.  
  13. if(file!!.exists()) {
  14. var fileData = Base64.encodeToString(FileUtils.readFileToString(file).toByteArray(), Base64.DEFAULT)
  15.  
  16. val transactionId = UUID.randomUUID().toString()
  17. val tokenId = ""
  18.  
  19. val jobDocument = JobDocument("Test", "", "", "PHONE_PICTURE", "jpg", "test.jpg", "", fileData)
  20. val requestBody = UploadDocumentRequest("Test", jobDocument)
  21.  
  22. val service = RestAPI(this@AddExtraPicturesActivity)
  23.  
  24.  
  25. val request = service.uploadDocument(authorization, transactionId, tokenId, requestBody)
  26.  
  27. request.enqueue(object : Callback<UploadDocumentResponse> {
  28. override fun onResponse(call: Call<UploadDocumentResponse>, response: Response<UploadDocumentResponse>) {
  29. Timber.d( response.toString())
  30. }
  31.  
  32. override fun onFailure(call: Call<UploadDocumentResponse>, t: Throwable) {
  33. Timber.d(t.toString())
  34.  
  35. }
  36. })
  37. }
  38. }
  39. }
  40. progresRing.dismiss()
Add Comment
Please, Sign In to add comment