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
9d46f182
Commit
9d46f182
authored
Sep 26, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DrawableHelper.kt
parent
66cbbad6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
DrawableHelper.kt
.../java/chat/rocket/android/widget/helper/DrawableHelper.kt
+32
-0
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/DrawableHelper.kt
View file @
9d46f182
package
chat.rocket.android.widget.helper
import
android.content.Context
import
android.graphics.Bitmap
import
android.graphics.Canvas
import
android.graphics.drawable.BitmapDrawable
import
android.graphics.drawable.Drawable
import
android.support.v4.content.ContextCompat
import
android.support.v4.graphics.drawable.DrawableCompat
/**
* Created by Filipe de Lima Brito (filipedelimabrito@gmail.com) on 8/29/17.
*/
object
DrawableHelper
{
/**
* Returns a bitmap from drawable.
*
* @param drawable The drawable to get the bitmap.
* @return A bitmap.
*/
fun
getBitmapFromDrawable
(
drawable
:
Drawable
,
intrinsicWidth
:
Int
=
1
,
intrinsicHeight
:
Int
=
1
):
Bitmap
{
if
(
drawable
is
BitmapDrawable
)
{
return
drawable
.
bitmap
}
val
textDrawableIntrinsicWidth
=
drawable
.
intrinsicWidth
var
textDrawableIntrinsicHeight
=
drawable
.
intrinsicHeight
val
width
=
if
(
textDrawableIntrinsicWidth
>
0
)
textDrawableIntrinsicWidth
else
intrinsicWidth
val
height
=
if
(
textDrawableIntrinsicHeight
>
0
)
textDrawableIntrinsicHeight
else
intrinsicHeight
val
bitmap
=
Bitmap
.
createBitmap
(
width
,
height
,
Bitmap
.
Config
.
ARGB_8888
)
val
canvas
=
Canvas
(
bitmap
)
drawable
.
setBounds
(
0
,
0
,
canvas
.
width
,
canvas
.
height
)
drawable
.
draw
(
canvas
)
return
bitmap
}
/**
* Wraps a drawable to be used for example for tinting.
*
...
...
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