Created
          April 21, 2020 17:07 
        
      - 
      
- 
        Save DjangoLC/c91b9dc8dd079061dd351d4e9be6475c to your computer and use it in GitHub Desktop. 
    sample
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package com.djangomx.airsale.utils.dialogs | |
| import android.content.Context | |
| import androidx.appcompat.app.AlertDialog | |
| typealias onClickAllow = (Boolean) -> Unit | |
| object Dialogs { | |
| var alertDialog: AlertDialog.Builder? = null | |
| fun createDialog(context: Context): AlertDialog.Builder { | |
| alertDialog = AlertDialog.Builder(context) | |
| return alertDialog!! | |
| } | |
| class Builder(val context: Context) { | |
| private var folio = "" | |
| private var onClickAllow: onClickAllow? = null | |
| private var positiveButton = "" | |
| private var cancellable = false | |
| fun setTitle(folio: String): Builder { | |
| this.folio = folio | |
| return this | |
| } | |
| fun setPositiveButton(title: String = "ACEPTAR", listener: (Boolean) -> Unit): Builder { | |
| onClickAllow = listener | |
| positiveButton = title | |
| return this | |
| } | |
| fun setCancellable(boolean: Boolean): Builder { | |
| this.cancellable = boolean | |
| return this | |
| } | |
| fun create() : AlertDialog { | |
| val dialog = createDialog(context) | |
| .setTitle(folio) | |
| .setPositiveButton(positiveButton) { d, w -> | |
| onClickAllow!!.invoke(true) | |
| d.dismiss() | |
| } | |
| .setCancelable(cancellable) | |
| return dialog.create() | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment