Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Magisk
Commits
4db41e2a
Commit
4db41e2a
authored
Jun 16, 2019
by
Viktor De Pasquale
Committed by
John Wu
Jun 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added attempted fix for parsing data off default thread
parent
982a43fc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
UpdateRepos.java
...src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
+15
-10
No files found.
app/src/main/java/com/topjohnwu/magisk/tasks/UpdateRepos.java
View file @
4db41e2a
...
@@ -3,8 +3,6 @@ package com.topjohnwu.magisk.tasks;
...
@@ -3,8 +3,6 @@ package com.topjohnwu.magisk.tasks;
import
android.database.Cursor
;
import
android.database.Cursor
;
import
android.util.Pair
;
import
android.util.Pair
;
import
androidx.annotation.NonNull
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.App
;
import
com.topjohnwu.magisk.Config
;
import
com.topjohnwu.magisk.Config
;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Const
;
...
@@ -20,7 +18,6 @@ import org.json.JSONException;
...
@@ -20,7 +18,6 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -33,16 +30,11 @@ import java.util.concurrent.ConcurrentLinkedQueue;
...
@@ -33,16 +30,11 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Future
;
import
androidx.annotation.NonNull
;
import
io.reactivex.Single
;
import
io.reactivex.Single
;
@Deprecated
@Deprecated
public
class
UpdateRepos
{
public
class
UpdateRepos
{
private
static
final
DateFormat
DATE_FORMAT
;
static
{
DATE_FORMAT
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
,
Locale
.
US
);
DATE_FORMAT
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
}
@NonNull
@NonNull
private
final
RepoDatabaseHelper
repoDB
;
private
final
RepoDatabaseHelper
repoDB
;
...
@@ -71,6 +63,17 @@ public class UpdateRepos {
...
@@ -71,6 +63,17 @@ public class UpdateRepos {
}
}
}
}
/**
* Static instance of (Simple)DateFormat is not threadsafe so in order to make it safe it needs
* to be created beforehand on the same thread where it'll be used.
* See https://stackoverflow.com/a/18383395
*/
private
static
SimpleDateFormat
getDateFormat
()
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
,
Locale
.
US
);
format
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"UTC"
));
return
format
;
}
/* We sort repos by last push, which means that we only need to check whether the
/* We sort repos by last push, which means that we only need to check whether the
* first page is updated to determine whether the online repo database is changed
* first page is updated to determine whether the online repo database is changed
*/
*/
...
@@ -95,10 +98,12 @@ public class UpdateRepos {
...
@@ -95,10 +98,12 @@ public class UpdateRepos {
return
true
;
return
true
;
try
{
try
{
SimpleDateFormat
dateFormat
=
getDateFormat
();
for
(
int
i
=
0
;
i
<
res
.
getResult
().
length
();
i
++)
{
for
(
int
i
=
0
;
i
<
res
.
getResult
().
length
();
i
++)
{
JSONObject
rawRepo
=
res
.
getResult
().
getJSONObject
(
i
);
JSONObject
rawRepo
=
res
.
getResult
().
getJSONObject
(
i
);
String
id
=
rawRepo
.
getString
(
"name"
);
String
id
=
rawRepo
.
getString
(
"name"
);
Date
date
=
DATE_FORMAT
.
parse
(
rawRepo
.
getString
(
"pushed_at"
));
Date
date
=
dateFormat
.
parse
(
rawRepo
.
getString
(
"pushed_at"
));
moduleQueue
.
offer
(
new
Pair
<>(
id
,
date
));
moduleQueue
.
offer
(
new
Pair
<>(
id
,
date
));
}
}
}
catch
(
JSONException
|
ParseException
e
)
{
}
catch
(
JSONException
|
ParseException
e
)
{
...
...
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