Skip to content

Commit

Permalink
Add custom alert image
Browse files Browse the repository at this point in the history
  • Loading branch information
Maliotis committed May 27, 2020
1 parent a2bcefc commit 70d647b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions app/src/main/java/com/maliotis/ioslikealert/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.maliotis.iosalert.IOSAlert
import com.maliotis.iosalert.IOSClickListener



val TAG = MainActivity::class.java.simpleName
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -21,13 +21,39 @@ class MainActivity : AppCompatActivity() {
IOSAlert.Builder(this)
.title("Title")
.body("This is a body text")
.typeface(Typeface.SERIF)
.iOSAlertPositiveClickListener(object: IOSClickListener {
override fun onClick(dialog: Dialog?) {
// Your code here on Positive Click
Log.d(TAG, "onClick: positive button pressed")
dialog?.dismiss()
}
})
.negativeText("Cancel")
.iOSAlertNegativeClickListener(object: IOSClickListener {
override fun onClick(dialog: Dialog?) {
// Your code here on Negative Click
Log.d(TAG, "onClick: negative button pressed")
dialog?.dismiss()
}

})
// The blur radius <= 25f
.blurRadius(22f)
// Sets the transparency to 0.2f - that translates to 0.8 alpha value
.transparency(0.2f)
// On touch down will highlight the buttons with a gray tint
.tintButtons(true)
//.tintButtonsColor(Color.DKGRAY)
//.backgroundColor(Color.WHITE)
//.backgroundColor(255, 255, 255, 255)
//.cornerRadius(10f) // 10f by default

// User won't be able to leave the alert without pressing one of the buttons
.isCancellable(false)


//.build() // Use build instead of buildAndShow if you want to show the alert yourself
// In the case use: iosAlert.show(supportFragmentManager, "tag")
.buildAndShow()

//iosAlert.show(supportFragmentManager, "tag")
Expand Down
Binary file added app/src/main/res/drawable/custom_alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 70d647b

Please sign in to comment.