Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.52 KB | None | 0 0
  1.  
  2. interface JobUploadInteractor : Interactor {
  3.  
  4.     var input: Input?
  5.     var output: Output?
  6.  
  7.     data class Input(var orderUpload: OrderUpload)
  8.  
  9.     interface Output {
  10.         fun onAuthReply(success: Boolean)
  11.         fun onError(msg: String)
  12.     }
  13.  
  14. }
  15.  
  16.  
  17.  
  18.  
  19. lass JobUploadInteractorImpl(val context: Context, executor: Executor, var api: Api, var xmlBuilder: XMLBuilder, var prefManager: PrefManager) : BaseInteractor(executor), JobUploadInteractor {
  20.  
  21.     override var input: JobUploadInteractor.Input? = null
  22.     override var output: JobUploadInteractor.Output? = null
  23.  
  24.     lateinit var auth: String
  25.  
  26.     override fun execute() {
  27.  
  28.         input?.let {
  29.  
  30.             val username = prefManager.getString(KyborgConstants.USERNAME, null)
  31.             val password = prefManager.getString(KyborgConstants.PASSWORD, null)
  32.             if (username != null && password != null) {
  33.                 auth = "$username:$password"
  34.                 xmlBuilder.writeXMLForRegistration(it.orderUpload, getResultFile(it.orderUpload.regGuid))
  35.                 api.postJobData(it.orderUpload).execute()
  36.             }
  37.         }
  38.     }
  39.  
  40. }
  41.  
  42.  
  43.  
  44. class JobDetailPresenter @Inject constructor(var interactor: JobUploadInteractor) : BasePresenterImpl<JobDetailContract.JobDetailView>(), JobDetailContract.JobDetailPresenter, JobUploadInteractor.Output {
  45.  
  46.     init {
  47.         interactor.output = this
  48.     }
  49.  
  50.  
  51.     fun uploadOrder(order: OrderUpload) {
  52.         interactor.input?.orderUpload = order;
  53.         interactor.run()
  54.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement