Created
July 13, 2019 14:14
-
-
Save rahulkhatri19/becaf68f4724643149934631c11e7c3b to your computer and use it in GitHub Desktop.
This file contains 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
import android.content.Context | |
import android.util.Log | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.widget.Toast | |
import androidx.appcompat.app.AlertDialog | |
import com.example.flipkotlinfirst.R | |
import kotlinx.android.synthetic.main.alert_custom_layout.view.* | |
class AlertDialogUtility { | |
companion object { | |
fun alertDialog(context: Context, alertText: String, animNumber: Int) { | |
val layoutBuilder = LayoutInflater.from(context).inflate(R.layout.alert_custom_layout, null) | |
val builder:AlertDialog.Builder = AlertDialog.Builder(context).setView(layoutBuilder) | |
val alertDialog:AlertDialog = builder.show() | |
layoutBuilder.tv_alert.text = alertText | |
layoutBuilder.et_name.visibility = View.INVISIBLE | |
if (animNumber == 1) { | |
layoutBuilder.lottie_anim.setAnimation("right.json") // json file in assets folder. | |
// If json file in raw folder it will not work, file not found exception. | |
} else if (animNumber == 2) { | |
layoutBuilder.lottie_anim.setAnimation("walkthrough.json") | |
} else { | |
Log.e("no ", "anim selected") | |
} | |
layoutBuilder.lottie_anim.loop(true) | |
layoutBuilder.lottie_anim.playAnimation() | |
layoutBuilder.btn_ok.setOnClickListener { | |
Toast.makeText(context, "Ok Bye "/* + layoutBuilder.et_name.text.toString()*/, Toast.LENGTH_SHORT).show() | |
alertDialog.dismiss() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment