-
- All Implemented Interfaces:
public final class ViewExtensionsKt
-
-
Method Summary
Modifier and Type Method Description Boolean
getIsVisible()
void
setIsVisible(Boolean isVisible)
Boolean
getIsHidden()
void
setIsHidden(Boolean isHidden)
final Integer
getPx()
final static Unit
toast(Fragment $self, String text, Integer length)
Displays the toast using Fragments context final static Unit
toast(Fragment $self, @StringRes() Integer textRes, Integer length)
Displays the toast using Fragments context final static Unit
toast(Context $self, @StringRes() Integer textRes, Integer length)
Displays the toast using caller context final static Unit
toast(Context $self, String text, Integer length)
Displays the toast using caller context final static Unit
showKeyboard(View view)
Utility method for showing keyboard. final static Unit
hideKeyboard(View view)
Utility method for hiding keyboard. final static Unit
setBackgroundColorRes(View $self, @ColorRes() Integer color)
Sets the background color for this view. final static Unit
setMargins(View $self, Integer left, Integer top, Integer right, Integer bottom)
Sets the margins, in pixels. final static Unit
delegateInteractions(View $self, View destinationView)
Moves all the touch events of the caller view to given view final static LayoutInflater
inflater(View $self)
Returns LayoutInflater from the given view's context. final static View
inflate(ViewGroup $self, @LayoutRes() Integer layoutRes, ViewGroup viewGroup, Boolean attachRoot)
Helper inflate call on the caller ViewGroup final static String
trimmedText(TextView $self)
Return the trimmed text that TextView is displaying final static Unit
setViewVisible(View $self, Boolean visible)
Helper method to assign the text to TextView final static Unit
setTextRes(TextView $self, @StringRes() Integer textRes, Object params)
Helper method to assign the text to TextView final static Unit
setTextColorRes(TextView $self, @ColorRes() Integer color)
Sets the text color for all the states (normal, selected, focused) to be this color. final static Unit
setTextAppearanceRes(TextView $self, @StyleRes() Integer textAppearance)
Sets the text appearance from the specified style resource. final static Unit
setFont(TextView $self, @FontRes() Integer font)
Sets the typeface and style in which the text should be displayed. final static Unit
clearText(EditText $self)
Clear the text is displaying in the edit text view. final static Unit
addTextWatcher(EditText $self, Function1<String, Unit> watcher)
Extension to only observe the TextWatcher.afterTextChanged event and ignore the other callbacks final static Unit
setTint(ImageView $self, @ColorRes() Integer colorRes)
Set a tinting option for the image. final static Pair<Integer, Integer>
getScreenSize()
Return the current display metrics that are in effect for this resource object. final static Integer
getColor(View $self, @ColorRes() Integer colorResId)
-
-
Method Detail
-
getIsVisible
Boolean getIsVisible()
-
setIsVisible
void setIsVisible(Boolean isVisible)
-
getIsHidden
Boolean getIsHidden()
-
setIsHidden
void setIsHidden(Boolean isHidden)
-
toast
final static Unit toast(Fragment $self, String text, Integer length)
Displays the toast using Fragments context
- Parameters:
text
- to be displayedlength
- of the message
-
toast
final static Unit toast(Fragment $self, @StringRes() Integer textRes, Integer length)
Displays the toast using Fragments context
- Parameters:
textRes
- to be displayedlength
- of the message
-
toast
final static Unit toast(Context $self, @StringRes() Integer textRes, Integer length)
Displays the toast using caller context
- Parameters:
textRes
- to be displayedlength
- of the message
-
toast
final static Unit toast(Context $self, String text, Integer length)
Displays the toast using caller context
- Parameters:
text
- to be displayedlength
- of the message
-
showKeyboard
final static Unit showKeyboard(View view)
Utility method for showing keyboard.
- Parameters:
view
- which has keyboard focus
-
hideKeyboard
final static Unit hideKeyboard(View view)
Utility method for hiding keyboard.
- Parameters:
view
- which has keyboard focus
-
setBackgroundColorRes
final static Unit setBackgroundColorRes(View $self, @ColorRes() Integer color)
Sets the background color for this view.
- Parameters:
color
- the color res of the background
-
setMargins
final static Unit setMargins(View $self, Integer left, Integer top, Integer right, Integer bottom)
Sets the margins, in pixels. Margin values should be positive.
- Parameters:
left
- the left margin sizetop
- the top margin sizeright
- the right margin sizebottom
- the bottom margin size
-
delegateInteractions
final static Unit delegateInteractions(View $self, View destinationView)
Moves all the touch events of the caller view to given view
- Parameters:
destinationView
- to accept all the touch events of the caller view
-
inflater
final static LayoutInflater inflater(View $self)
Returns LayoutInflater from the given view's context.
-
inflate
final static View inflate(ViewGroup $self, @LayoutRes() Integer layoutRes, ViewGroup viewGroup, Boolean attachRoot)
Helper inflate call on the caller ViewGroup
-
trimmedText
final static String trimmedText(TextView $self)
Return the trimmed text that TextView is displaying
-
setViewVisible
final static Unit setViewVisible(View $self, Boolean visible)
Helper method to assign the text to TextView
-
setTextRes
final static Unit setTextRes(TextView $self, @StringRes() Integer textRes, Object params)
Helper method to assign the text to TextView
-
setTextColorRes
final static Unit setTextColorRes(TextView $self, @ColorRes() Integer color)
Sets the text color for all the states (normal, selected, focused) to be this color.
- Parameters:
color
- A color res value
-
setTextAppearanceRes
final static Unit setTextAppearanceRes(TextView $self, @StyleRes() Integer textAppearance)
Sets the text appearance from the specified style resource.
- Parameters:
textAppearance
- the resource identifier of the style to apply
-
setFont
final static Unit setFont(TextView $self, @FontRes() Integer font)
Sets the typeface and style in which the text should be displayed.
- Parameters:
font
- the resource identifier of the font to apply
-
clearText
final static Unit clearText(EditText $self)
Clear the text is displaying in the edit text view.
-
addTextWatcher
final static Unit addTextWatcher(EditText $self, Function1<String, Unit> watcher)
Extension to only observe the TextWatcher.afterTextChanged event and ignore the other callbacks
-
setTint
final static Unit setTint(ImageView $self, @ColorRes() Integer colorRes)
Set a tinting option for the image.
- Parameters:
colorRes
- the resource identifier of the color tint to apply.
-
getScreenSize
final static Pair<Integer, Integer> getScreenSize()
Return the current display metrics that are in effect for this resource object.
-
-
-
-