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
852128b9
Commit
852128b9
authored
Nov 14, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add try-catch block for safe casting.
parent
81f19d31
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
LayoutHelper.kt
app/src/main/java/chat/rocket/android/app/LayoutHelper.kt
+11
-5
No files found.
app/src/main/java/chat/rocket/android/app/LayoutHelper.kt
View file @
852128b9
...
@@ -2,13 +2,14 @@ package chat.rocket.android.app
...
@@ -2,13 +2,14 @@ package chat.rocket.android.app
import
android.app.Activity
import
android.app.Activity
import
android.graphics.Rect
import
android.graphics.Rect
import
android.util.Log
import
android.view.View
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.FrameLayout
/**
/**
* @author Filipe de Lima Brito (filipedelimabrito@gmail.com)
* @author Filipe de Lima Brito (filipedelimabrito@gmail.com)
*/
*/
//TODO
C
heck if this code has memory leak.
//TODO
: c
heck if this code has memory leak.
object
LayoutHelper
{
object
LayoutHelper
{
private
lateinit
var
childOfContent
:
View
private
lateinit
var
childOfContent
:
View
private
var
usableHeightPrevious
:
Int
=
0
private
var
usableHeightPrevious
:
Int
=
0
...
@@ -25,10 +26,15 @@ object LayoutHelper {
...
@@ -25,10 +26,15 @@ object LayoutHelper {
* @param activity The Activity to adjust the layout.
* @param activity The Activity to adjust the layout.
*/
*/
fun
androidBug5497Workaround
(
activity
:
Activity
)
{
fun
androidBug5497Workaround
(
activity
:
Activity
)
{
val
content
=
activity
.
findViewById
<
View
>(
android
.
R
.
id
.
content
)
as
FrameLayout
try
{
childOfContent
=
content
.
getChildAt
(
0
)
val
content
=
activity
.
findViewById
<
View
>(
android
.
R
.
id
.
content
)
as
FrameLayout
childOfContent
.
viewTreeObserver
.
addOnGlobalLayoutListener
({
resizeChildOfContent
()
})
childOfContent
=
content
.
getChildAt
(
0
)
frameLayoutParams
=
childOfContent
.
layoutParams
as
FrameLayout
.
LayoutParams
childOfContent
.
viewTreeObserver
.
addOnGlobalLayoutListener
({
resizeChildOfContent
()
})
frameLayoutParams
=
childOfContent
.
layoutParams
as
FrameLayout
.
LayoutParams
}
catch
(
exception
:
ClassCastException
)
{
// TODO: are we using the android.util.Log for logging that type of errors?
Log
.
e
(
"ERROR"
,
exception
.
message
)
}
}
}
private
fun
resizeChildOfContent
()
{
private
fun
resizeChildOfContent
()
{
...
...
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