Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
ddd759aa
Commit
ddd759aa
authored
13 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Close XmlResourceParser when finish parsing
Change-Id: If21ee187c83f044b235d88fba15af00e6ac8a308
parent
d2bc850c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+13
-4
13 additions, 4 deletions
...ndroid/inputmethod/keyboard/internal/KeyboardBuilder.java
with
13 additions
and
4 deletions
java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+
13
−
4
View file @
ddd759aa
...
@@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal;
...
@@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard.internal;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.res.Resources
;
import
android.content.res.Resources
;
import
android.content.res.TypedArray
;
import
android.content.res.TypedArray
;
import
android.content.res.XmlResourceParser
;
import
android.util.DisplayMetrics
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.util.Log
;
import
android.util.TypedValue
;
import
android.util.TypedValue
;
...
@@ -268,14 +269,17 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
...
@@ -268,14 +269,17 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
public
KeyboardBuilder
<
KP
>
load
(
KeyboardId
id
)
{
public
KeyboardBuilder
<
KP
>
load
(
KeyboardId
id
)
{
mParams
.
mId
=
id
;
mParams
.
mId
=
id
;
final
XmlResourceParser
parser
=
mResources
.
getXml
(
id
.
getXmlId
());
try
{
try
{
parseKeyboard
(
id
.
getXmlId
()
);
parseKeyboard
(
parser
);
}
catch
(
XmlPullParserException
e
)
{
}
catch
(
XmlPullParserException
e
)
{
Log
.
w
(
TAG
,
"keyboard XML parse error: "
+
e
);
Log
.
w
(
TAG
,
"keyboard XML parse error: "
+
e
);
throw
new
IllegalArgumentException
(
e
);
throw
new
IllegalArgumentException
(
e
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
Log
.
w
(
TAG
,
"keyboard XML parse error: "
+
e
);
Log
.
w
(
TAG
,
"keyboard XML parse error: "
+
e
);
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
finally
{
parser
.
close
();
}
}
return
this
;
return
this
;
}
}
...
@@ -288,9 +292,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
...
@@ -288,9 +292,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
return
new
Keyboard
(
mParams
);
return
new
Keyboard
(
mParams
);
}
}
private
void
parseKeyboard
(
int
resId
)
throws
XmlPullParserException
,
IOException
{
private
void
parseKeyboard
(
XmlResourceParser
parser
)
throws
XmlPullParserException
,
IOException
{
if
(
DEBUG
)
Log
.
d
(
TAG
,
String
.
format
(
"<%s> %s"
,
TAG_KEYBOARD
,
mParams
.
mId
));
if
(
DEBUG
)
Log
.
d
(
TAG
,
String
.
format
(
"<%s> %s"
,
TAG_KEYBOARD
,
mParams
.
mId
));
final
XmlPullParser
parser
=
mResources
.
getXml
(
resId
);
int
event
;
int
event
;
while
((
event
=
parser
.
next
())
!=
XmlPullParser
.
END_DOCUMENT
)
{
while
((
event
=
parser
.
next
())
!=
XmlPullParser
.
END_DOCUMENT
)
{
if
(
event
==
XmlPullParser
.
START_TAG
)
{
if
(
event
==
XmlPullParser
.
START_TAG
)
{
...
@@ -535,7 +539,12 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
...
@@ -535,7 +539,12 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
throw
new
ParseException
(
"No keyboardLayout attribute in <include/>"
,
parser
);
throw
new
ParseException
(
"No keyboardLayout attribute in <include/>"
,
parser
);
if
(
DEBUG
)
Log
.
d
(
TAG
,
String
.
format
(
"<%s keyboardLayout=%s />"
,
if
(
DEBUG
)
Log
.
d
(
TAG
,
String
.
format
(
"<%s keyboardLayout=%s />"
,
TAG_INCLUDE
,
mResources
.
getResourceEntryName
(
keyboardLayout
)));
TAG_INCLUDE
,
mResources
.
getResourceEntryName
(
keyboardLayout
)));
parseMerge
(
mResources
.
getLayout
(
keyboardLayout
),
row
,
skip
);
final
XmlResourceParser
parserForInclude
=
mResources
.
getXml
(
keyboardLayout
);
try
{
parseMerge
(
parserForInclude
,
row
,
skip
);
}
finally
{
parserForInclude
.
close
();
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment