Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
05761d2f
Commit
05761d2f
authored
Nov 03, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new methods.
parent
49952d35
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
DrawableHelper.kt
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
+35
-0
No files found.
app/src/main/java/chat/rocket/android/app/DrawableHelper.kt
View file @
05761d2f
...
@@ -22,6 +22,7 @@ object DrawableHelper {
...
@@ -22,6 +22,7 @@ object DrawableHelper {
* Wraps an array of Drawable to be used for example for tinting.
* Wraps an array of Drawable to be used for example for tinting.
*
*
* @param drawables The array of Drawable to wrap.
* @param drawables The array of Drawable to wrap.
* @see wrapDrawable
* @see tintDrawables
* @see tintDrawables
*/
*/
fun
wrapDrawables
(
drawables
:
Array
<
Drawable
>)
{
fun
wrapDrawables
(
drawables
:
Array
<
Drawable
>)
{
...
@@ -30,6 +31,16 @@ object DrawableHelper {
...
@@ -30,6 +31,16 @@ object DrawableHelper {
}
}
}
}
/**
* Wraps the Drawable to be used for example for tinting.
*
* @param drawable The Drawable to wrap.
* @see wrapDrawables
* @see tintDrawable
*/
fun
wrapDrawable
(
drawable
:
Drawable
)
=
DrawableCompat
.
wrap
(
drawable
)
/**
/**
* Tints an array of Drawable.
* Tints an array of Drawable.
*
*
...
@@ -38,6 +49,7 @@ object DrawableHelper {
...
@@ -38,6 +49,7 @@ object DrawableHelper {
* @param drawables The array of Drawable to tint.
* @param drawables The array of Drawable to tint.
* @param context The context.
* @param context The context.
* @param resId The resource id color to tint the Drawables.
* @param resId The resource id color to tint the Drawables.
* @see tintDrawable
* @see wrapDrawables
* @see wrapDrawables
*/
*/
fun
tintDrawables
(
drawables
:
Array
<
Drawable
>,
context
:
Context
,
resId
:
Int
)
{
fun
tintDrawables
(
drawables
:
Array
<
Drawable
>,
context
:
Context
,
resId
:
Int
)
{
...
@@ -46,6 +58,19 @@ object DrawableHelper {
...
@@ -46,6 +58,19 @@ object DrawableHelper {
}
}
}
}
/**
* Tints a Drawable.
*
* REMARK: you MUST always wrap the Drawable before tint it.
*
* @param drawable The Drawable to tint.
* @param context The context.
* @param resId The resource id color to tint the Drawable.
* @see tintDrawables
* @see wrapDrawable
*/
fun
tintDrawable
(
drawable
:
Drawable
,
context
:
Context
,
resId
:
Int
)
=
DrawableCompat
.
setTint
(
drawable
,
ContextCompat
.
getColor
(
context
,
resId
))
/**
/**
* Compounds an array of Drawable (to appear to the left of the text) into an array of EditText.
* Compounds an array of Drawable (to appear to the left of the text) into an array of EditText.
*
*
...
@@ -53,6 +78,7 @@ object DrawableHelper {
...
@@ -53,6 +78,7 @@ object DrawableHelper {
*
*
* @param editTexts The array of EditText.
* @param editTexts The array of EditText.
* @param drawables The array of Drawable.
* @param drawables The array of Drawable.
* @see compoundDrawable
*/
*/
fun
compoundDrawables
(
editTexts
:
Array
<
EditText
>,
drawables
:
Array
<
Drawable
>)
{
fun
compoundDrawables
(
editTexts
:
Array
<
EditText
>,
drawables
:
Array
<
Drawable
>)
{
if
(
editTexts
.
size
!=
drawables
.
size
)
{
if
(
editTexts
.
size
!=
drawables
.
size
)
{
...
@@ -63,4 +89,13 @@ object DrawableHelper {
...
@@ -63,4 +89,13 @@ object DrawableHelper {
}
}
}
}
}
}
/**
* Compounds a Drawable (to appear to the left of the text) into an EditText.
*
* @param editText The EditText.
* @param drawable The Drawable.
* @see compoundDrawables
*/
fun
compoundDrawable
(
editText
:
EditText
,
drawable
:
Drawable
)
=
editText
.
setCompoundDrawablesWithIntrinsicBounds
(
drawable
,
null
,
null
,
null
)
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment