Skip to content

Commit

Permalink
Converted more classes to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
kpmmmurphy committed Jun 1, 2018
1 parent a2dc38c commit e29819f
Show file tree
Hide file tree
Showing 9 changed files with 448 additions and 503 deletions.
42 changes: 22 additions & 20 deletions alerter/src/main/java/com/tapadoo/alerter/Alert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Alert @JvmOverloads constructor(context: Context, attrs: AttributeSet? = n

private var runningAnimation: Runnable? = null

private var dismissable = true
private var isDismissable = true

/**
* Flag to ensure we only set the margins once
Expand Down Expand Up @@ -140,7 +140,7 @@ class Alert @JvmOverloads constructor(context: Context, attrs: AttributeSet? = n
}

override fun onClick(v: View) {
if (dismissable) {
if (isDismissable) {
hide()
}
}
Expand Down Expand Up @@ -469,39 +469,41 @@ class Alert @JvmOverloads constructor(context: Context, attrs: AttributeSet? = n
}

/**
* Set if the alerter is dismissable or not
* Set if the alerter is isDismissable or not
*
* @param dismissible True if alert can be dismissed
*/
fun setDismissable(dismissable: Boolean) {
this.dismissable = dismissable
this.isDismissable = dismissable
}

/**
* Get if the alert is dismissable
* Get if the alert is isDismissable
* @return
*/
fun isDismissable(): Boolean {
return dismissable
return isDismissable
}

/**
* Set whether to enable swipe to dismiss or not
*/
fun enableSwipeToDismiss() {
alertBackground!!.setOnTouchListener(SwipeDismissTouchListener(alertBackground!!, null, object : SwipeDismissTouchListener.DismissCallbacks {
override fun canDismiss(token: Any): Boolean {
return true
}
alertBackground?.let {
it.setOnTouchListener(SwipeDismissTouchListener(it, object : SwipeDismissTouchListener.DismissCallbacks {
override fun canDismiss(): Boolean {
return true
}

override fun onDismiss(view: View, token: Any) {
removeFromParent()
}
override fun onDismiss(view: View) {
removeFromParent()
}

override fun onTouch(view: View, touch: Boolean) {
// Ignore
}
}))
override fun onTouch(view: View, touch: Boolean) {
// Ignore
}
}))
}
}

/**
Expand Down Expand Up @@ -567,11 +569,11 @@ class Alert @JvmOverloads constructor(context: Context, attrs: AttributeSet? = n
this.vibrationEnabled = vibrationEnabled
}

override fun canDismiss(token: Any): Boolean {
return true
override fun canDismiss(): Boolean {
return isDismissable
}

override fun onDismiss(view: View, token: Any) {
override fun onDismiss(view: View) {
flClickShield!!.removeView(alertBackground)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.tapadoo.alerter;
package com.tapadoo.alerter

/**
* On Hide Alert Listener
*
* @author edgeorge
* @since 20/02/2017.
*/

public interface OnHideAlertListener {
interface OnHideAlertListener {
/**
* Called when the Alert is hidden
*/
void onHide();
fun onHide()
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.tapadoo.alerter;
package com.tapadoo.alerter

/**
* On Show Alert Listener
*
* @author edgeorge
* @since 20/02/2017.
*/
public interface OnShowAlertListener {
interface OnShowAlertListener {
/**
* Called when the Alert is initially Shown
*/
void onShow();
fun onShow()
}
Loading

0 comments on commit e29819f

Please sign in to comment.