Created
November 21, 2017 16:40
-
-
Save maiconhellmann/70547df808f12437452518c0399b23b2 to your computer and use it in GitHub Desktop.
Kotlin extensions for View
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.support.design.widget.Snackbar | |
import android.view.View | |
import com.github.clans.fab.FloatingActionMenu | |
fun View.visible(){ | |
this.visibility = View.VISIBLE | |
} | |
fun View.visible(visible : Boolean){ | |
if(visible){ | |
visible() | |
}else{ | |
gone() | |
} | |
} | |
fun View.gone(){ | |
this.visibility = View.GONE | |
} | |
fun View.invisible(){ | |
this.visibility = View.INVISIBLE | |
} | |
fun View.snackbar(resId: Int, duration: Int = Snackbar.LENGTH_SHORT) { | |
snackbar(this.resources.getString(resId), duration) | |
} | |
fun View.snackbar(msg: String, duration: Int = Snackbar.LENGTH_SHORT) { | |
Snackbar.make(this, msg, duration).show() | |
} | |
fun View.longSnackbar(resId: Int) { | |
snackbar(resId, Snackbar.LENGTH_LONG) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment