Package com.aliucord.utils
Object ViewUtils
-
- All Implemented Interfaces:
public class ViewUtils
-
-
Field Summary
Fields Modifier and Type Field Description private final ConstraintLayoutlayoutprivate final TextViewlabelprivate final CompoundButtoncheckboxprivate final TextViewsubtextpublic final static ViewUtilsINSTANCE
-
Method Summary
Modifier and Type Method Description final <T extends View> TaddTo(T $self, ViewGroup group, Function1<T, Unit> block)Shorthand extension function to add a View into a ViewGroup, and then run a scoped function final <T extends View> TaddTo(T $self, ViewGroup group, Integer index, Function1<T, Unit> block)Shorthand extension function to add a View into a ViewGroup at specified index, and then run a scoped function final <T extends View> TfindViewById(View $self, String idName)The same as View.findViewById, but takes the name of the id instead. final <T extends View> TsetDefaultMargins(T $self, Boolean bottom, Boolean top, Boolean left, Boolean right)Adds default discord paddings as margins to a View. final ConstraintLayoutgetLayout(CheckedSetting $self)final TextViewgetLabel(CheckedSetting $self)final CompoundButtongetCheckbox(CheckedSetting $self)final TextViewgetSubtext(CheckedSetting $self)-
-
Method Detail
-
addTo
final <T extends View> T addTo(T $self, ViewGroup group, Function1<T, Unit> block)
Shorthand extension function to add a View into a ViewGroup, and then run a scoped function
- Parameters:
group- ViewGroup to add this View intoblock- A scoped function, with the View as its receiver- Returns:
The View
-
addTo
final <T extends View> T addTo(T $self, ViewGroup group, Integer index, Function1<T, Unit> block)
Shorthand extension function to add a View into a ViewGroup at specified index, and then run a scoped function
- Parameters:
group- ViewGroup to add this View intoindex- Index to insert this View atblock- A scoped function, with the View as its receiver- Returns:
The View
-
findViewById
final <T extends View> T findViewById(View $self, String idName)
The same as View.findViewById, but takes the name of the id instead.
- Parameters:
idName- the name of the id resource- Returns:
a view with the given id in the layout, or
nullif it is not found
-
setDefaultMargins
final <T extends View> T setDefaultMargins(T $self, Boolean bottom, Boolean top, Boolean left, Boolean right)
Adds default discord paddings as margins to a View. By default, margins are set for the bottom, left, and right of the View, but not the top.
- Parameters:
bottom- Whether to set topMargin.top- Whether to set bottomMargin.left- Whether to set leftMargin.right- Whether to set rightMargin.- Returns:
The View
-
getLayout
final ConstraintLayout getLayout(CheckedSetting $self)
-
getCheckbox
final CompoundButton getCheckbox(CheckedSetting $self)
-
getSubtext
final TextView getSubtext(CheckedSetting $self)
-
-
-
-