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 TextViewsubtextprivate IntegerleftPaddingprivate IntegertopPaddingprivate IntegerrightPaddingprivate IntegerbottomPaddingprivate IntegerstartPaddingprivate IntegerendPaddingprivate Paddingpaddingpublic 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 UnitsetPadding(View $self, Integer value)Set a uniform padding for all sides final ConstraintLayoutgetLayout(CheckedSetting $self)final TextViewgetLabel(CheckedSetting $self)final CompoundButtongetCheckbox(CheckedSetting $self)final TextViewgetSubtext(CheckedSetting $self)final IntegergetLeftPadding(View $self)final UnitsetLeftPadding(View $self, Integer value)final IntegergetTopPadding(View $self)final UnitsetTopPadding(View $self, Integer value)final IntegergetRightPadding(View $self)final UnitsetRightPadding(View $self, Integer value)final IntegergetBottomPadding(View $self)final UnitsetBottomPadding(View $self, Integer value)final IntegergetStartPadding(View $self)final UnitsetStartPadding(View $self, Integer value)final IntegergetEndPadding(View $self)final UnitsetEndPadding(View $self, Integer value)final PaddinggetPadding(View $self)final UnitsetPadding(View $self, Padding value)-
-
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
-
setPadding
final Unit setPadding(View $self, Integer value)
Set a uniform padding for all sides
-
getLayout
final ConstraintLayout getLayout(CheckedSetting $self)
-
getCheckbox
final CompoundButton getCheckbox(CheckedSetting $self)
-
getSubtext
final TextView getSubtext(CheckedSetting $self)
-
getLeftPadding
final Integer getLeftPadding(View $self)
-
setLeftPadding
final Unit setLeftPadding(View $self, Integer value)
-
getTopPadding
final Integer getTopPadding(View $self)
-
setTopPadding
final Unit setTopPadding(View $self, Integer value)
-
getRightPadding
final Integer getRightPadding(View $self)
-
setRightPadding
final Unit setRightPadding(View $self, Integer value)
-
getBottomPadding
final Integer getBottomPadding(View $self)
-
setBottomPadding
final Unit setBottomPadding(View $self, Integer value)
-
getStartPadding
final Integer getStartPadding(View $self)
-
setStartPadding
final Unit setStartPadding(View $self, Integer value)
-
getEndPadding
final Integer getEndPadding(View $self)
-
setEndPadding
final Unit setEndPadding(View $self, Integer value)
-
getPadding
final Padding getPadding(View $self)
-
setPadding
final Unit setPadding(View $self, Padding value)
-
-
-
-