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
c9d3e20a
Commit
c9d3e20a
authored
Mar 17, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix repo loading UI logic
parent
d5408d1f
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
31 deletions
+54
-31
MagiskFragment.java
src/main/java/com/topjohnwu/magisk/MagiskFragment.java
+4
-4
MagiskHideFragment.java
src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
+1
-1
MainActivity.java
src/main/java/com/topjohnwu/magisk/MainActivity.java
+1
-1
ModulesFragment.java
src/main/java/com/topjohnwu/magisk/ModulesFragment.java
+1
-1
ReposFragment.java
src/main/java/com/topjohnwu/magisk/ReposFragment.java
+6
-5
SettingsActivity.java
src/main/java/com/topjohnwu/magisk/SettingsActivity.java
+2
-2
UpdateRepos.java
src/main/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
+6
-1
Topic.java
src/main/java/com/topjohnwu/magisk/utils/Topic.java
+33
-16
No files found.
src/main/java/com/topjohnwu/magisk/MagiskFragment.java
View file @
c9d3e20a
...
@@ -159,8 +159,8 @@ public class MagiskFragment extends Fragment
...
@@ -159,8 +159,8 @@ public class MagiskFragment extends Fragment
safetyNetStatusText
.
setText
(
R
.
string
.
safetyNet_check_text
);
safetyNetStatusText
.
setText
(
R
.
string
.
safetyNet_check_text
);
mm
.
safetyNetDone
.
hasPublished
=
false
;
mm
.
safetyNetDone
.
reset
()
;
mm
.
updateCheckDone
.
hasPublished
=
false
;
mm
.
updateCheckDone
.
reset
()
;
mm
.
remoteMagiskVersionString
=
null
;
mm
.
remoteMagiskVersionString
=
null
;
mm
.
remoteMagiskVersionCode
=
-
1
;
mm
.
remoteMagiskVersionCode
=
-
1
;
collapse
();
collapse
();
...
@@ -176,11 +176,11 @@ public class MagiskFragment extends Fragment
...
@@ -176,11 +176,11 @@ public class MagiskFragment extends Fragment
}
}
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
)
{
if
(
topic
==
mm
.
updateCheckDone
)
{
if
(
topic
==
mm
.
updateCheckDone
)
{
updateCheckUI
();
updateCheckUI
();
}
else
if
(
topic
==
mm
.
safetyNetDone
)
{
}
else
if
(
topic
==
mm
.
safetyNetDone
)
{
updateSafetyNetUI
((
int
)
result
);
updateSafetyNetUI
((
int
)
topic
.
getResults
()[
0
]
);
}
}
}
}
...
...
src/main/java/com/topjohnwu/magisk/MagiskHideFragment.java
View file @
c9d3e20a
...
@@ -84,7 +84,7 @@ public class MagiskHideFragment extends Fragment implements Topic.Subscriber {
...
@@ -84,7 +84,7 @@ public class MagiskHideFragment extends Fragment implements Topic.Subscriber {
}
}
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
)
{
mSwipeRefreshLayout
.
setRefreshing
(
false
);
mSwipeRefreshLayout
.
setRefreshing
(
false
);
appAdapter
.
filter
(
lastFilter
);
appAdapter
.
filter
(
lastFilter
);
}
}
...
...
src/main/java/com/topjohnwu/magisk/MainActivity.java
View file @
c9d3e20a
...
@@ -127,7 +127,7 @@ public class MainActivity extends Activity
...
@@ -127,7 +127,7 @@ public class MainActivity extends Activity
}
}
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
)
{
recreate
();
recreate
();
}
}
...
...
src/main/java/com/topjohnwu/magisk/ModulesFragment.java
View file @
c9d3e20a
...
@@ -79,7 +79,7 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
...
@@ -79,7 +79,7 @@ public class ModulesFragment extends Fragment implements Topic.Subscriber {
}
}
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
)
{
updateUI
();
updateUI
();
}
}
...
...
src/main/java/com/topjohnwu/magisk/ReposFragment.java
View file @
c9d3e20a
...
@@ -27,6 +27,7 @@ import butterknife.Unbinder;
...
@@ -27,6 +27,7 @@ import butterknife.Unbinder;
public
class
ReposFragment
extends
Fragment
implements
Topic
.
Subscriber
{
public
class
ReposFragment
extends
Fragment
implements
Topic
.
Subscriber
{
private
Unbinder
unbinder
;
private
Unbinder
unbinder
;
private
MagiskManager
mm
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
@BindView
(
R
.
id
.
recyclerView
)
RecyclerView
recyclerView
;
@BindView
(
R
.
id
.
empty_rv
)
TextView
emptyRv
;
@BindView
(
R
.
id
.
empty_rv
)
TextView
emptyRv
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
...
@@ -44,8 +45,9 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
...
@@ -44,8 +45,9 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_repos
,
container
,
false
);
View
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_repos
,
container
,
false
);
unbinder
=
ButterKnife
.
bind
(
this
,
view
);
unbinder
=
ButterKnife
.
bind
(
this
,
view
);
mm
=
getApplication
();
mSwipeRefreshLayout
.
setRefreshing
(
true
);
mSwipeRefreshLayout
.
setRefreshing
(
mm
.
repoLoadDone
.
isPending
()
);
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
mSwipeRefreshLayout
.
setOnRefreshListener
(()
->
{
recyclerView
.
setVisibility
(
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
View
.
VISIBLE
);
...
@@ -60,7 +62,7 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
...
@@ -60,7 +62,7 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
@Override
@Override
public
void
onResume
()
{
public
void
onResume
()
{
adapter
=
new
ReposAdapter
(
getApplication
().
repoDB
,
getApplication
()
.
moduleMap
);
adapter
=
new
ReposAdapter
(
mm
.
repoDB
,
mm
.
moduleMap
);
recyclerView
.
setAdapter
(
adapter
);
recyclerView
.
setAdapter
(
adapter
);
super
.
onResume
();
super
.
onResume
();
}
}
...
@@ -72,7 +74,7 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
...
@@ -72,7 +74,7 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
}
}
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
)
{
mSwipeRefreshLayout
.
setRefreshing
(
false
);
mSwipeRefreshLayout
.
setRefreshing
(
false
);
recyclerView
.
setVisibility
(
adapter
.
getItemCount
()
==
0
?
View
.
GONE
:
View
.
VISIBLE
);
recyclerView
.
setVisibility
(
adapter
.
getItemCount
()
==
0
?
View
.
GONE
:
View
.
VISIBLE
);
emptyRv
.
setVisibility
(
adapter
.
getItemCount
()
==
0
?
View
.
VISIBLE
:
View
.
GONE
);
emptyRv
.
setVisibility
(
adapter
.
getItemCount
()
==
0
?
View
.
VISIBLE
:
View
.
GONE
);
...
@@ -80,7 +82,7 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
...
@@ -80,7 +82,7 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
@Override
@Override
public
Topic
[]
getSubscription
()
{
public
Topic
[]
getSubscription
()
{
return
new
Topic
[]
{
getApplication
()
.
repoLoadDone
};
return
new
Topic
[]
{
mm
.
repoLoadDone
};
}
}
@Override
@Override
...
@@ -103,7 +105,6 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
...
@@ -103,7 +105,6 @@ public class ReposFragment extends Fragment implements Topic.Subscriber {
@Override
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
MagiskManager
mm
=
getApplication
();
if
(
item
.
getItemId
()
==
R
.
id
.
repo_sort
)
{
if
(
item
.
getItemId
()
==
R
.
id
.
repo_sort
)
{
new
AlertDialog
.
Builder
(
getActivity
())
new
AlertDialog
.
Builder
(
getActivity
())
.
setTitle
(
R
.
string
.
sorting_order
)
.
setTitle
(
R
.
string
.
sorting_order
)
...
...
src/main/java/com/topjohnwu/magisk/SettingsActivity.java
View file @
c9d3e20a
...
@@ -69,7 +69,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -69,7 +69,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
}
}
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
)
{
recreate
();
recreate
();
}
}
...
@@ -311,7 +311,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
...
@@ -311,7 +311,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
}
}
@Override
@Override
public
void
onTopicPublished
(
Topic
topic
,
Object
result
)
{
public
void
onTopicPublished
(
Topic
topic
)
{
setLocalePreference
((
ListPreference
)
findPreference
(
Const
.
Key
.
LOCALE
));
setLocalePreference
((
ListPreference
)
findPreference
(
Const
.
Key
.
LOCALE
));
}
}
...
...
src/main/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
View file @
c9d3e20a
...
@@ -42,7 +42,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
...
@@ -42,7 +42,7 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
MagiskManager
mm
=
MagiskManager
.
get
();
MagiskManager
mm
=
MagiskManager
.
get
();
prefs
=
mm
.
prefs
;
prefs
=
mm
.
prefs
;
repoDB
=
mm
.
repoDB
;
repoDB
=
mm
.
repoDB
;
mm
.
repoLoadDone
.
hasPublished
=
false
;
mm
.
repoLoadDone
.
reset
()
;
// Legacy data cleanup
// Legacy data cleanup
File
old
=
new
File
(
mm
.
getApplicationInfo
().
dataDir
+
"/shared_prefs"
,
"RepoMap.xml"
);
File
old
=
new
File
(
mm
.
getApplicationInfo
().
dataDir
+
"/shared_prefs"
,
"RepoMap.xml"
);
if
(
old
.
exists
()
||
prefs
.
getString
(
"repomap"
,
null
)
!=
null
)
{
if
(
old
.
exists
()
||
prefs
.
getString
(
"repomap"
,
null
)
!=
null
)
{
...
@@ -160,6 +160,11 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
...
@@ -160,6 +160,11 @@ public class UpdateRepos extends ParallelTask<Void, Void, Void> {
ReposFragment
.
adapter
.
notifyDBChanged
();
ReposFragment
.
adapter
.
notifyDBChanged
();
}
}
@Override
protected
void
onPreExecute
()
{
MagiskManager
.
get
().
repoLoadDone
.
setPending
();
}
@Override
@Override
protected
Void
doInBackground
(
Void
...
voids
)
{
protected
Void
doInBackground
(
Void
...
voids
)
{
etags
=
new
ArrayList
<>(
Arrays
.
asList
(
prefs
.
getString
(
Const
.
Key
.
ETAG_KEY
,
""
).
split
(
","
)));
etags
=
new
ArrayList
<>(
Arrays
.
asList
(
prefs
.
getString
(
Const
.
Key
.
ETAG_KEY
,
""
).
split
(
","
)));
...
...
src/main/java/com/topjohnwu/magisk/utils/Topic.java
View file @
c9d3e20a
...
@@ -7,8 +7,13 @@ import java.util.List;
...
@@ -7,8 +7,13 @@ import java.util.List;
public
class
Topic
{
public
class
Topic
{
public
boolean
hasPublished
=
false
;
private
static
final
int
NON_INIT
=
0
;
private
static
final
int
PENDING
=
1
;
private
static
final
int
PUBLISHED
=
2
;
private
int
state
=
NON_INIT
;
private
List
<
WeakReference
<
Subscriber
>>
subscribers
;
private
List
<
WeakReference
<
Subscriber
>>
subscribers
;
private
Object
[]
results
;
public
void
subscribe
(
Subscriber
sub
)
{
public
void
subscribe
(
Subscriber
sub
)
{
if
(
subscribers
==
null
)
{
if
(
subscribers
==
null
)
{
...
@@ -30,29 +35,47 @@ public class Topic {
...
@@ -30,29 +35,47 @@ public class Topic {
}
}
}
}
public
void
publish
()
{
public
void
reset
()
{
publish
(
true
,
null
);
state
=
NON_INIT
;
results
=
null
;
}
public
boolean
isPublished
()
{
return
state
==
PUBLISHED
;
}
}
public
void
publish
(
boolean
record
)
{
public
void
publish
()
{
publish
(
record
,
null
);
publish
(
true
);
}
}
public
void
publish
(
boolean
record
,
Object
result
)
{
public
void
publish
(
boolean
record
,
Object
...
results
)
{
hasPublished
=
record
;
if
(
record
)
state
=
PUBLISHED
;
this
.
results
=
results
;
if
(
subscribers
!=
null
)
{
if
(
subscribers
!=
null
)
{
for
(
WeakReference
<
Subscriber
>
subscriber
:
subscribers
)
{
for
(
WeakReference
<
Subscriber
>
subscriber
:
subscribers
)
{
if
(
subscriber
.
get
()
!=
null
)
if
(
subscriber
.
get
()
!=
null
)
subscriber
.
get
().
onTopicPublished
(
this
,
result
);
subscriber
.
get
().
onTopicPublished
(
this
);
}
}
}
}
}
public
Object
[]
getResults
()
{
return
results
;
}
public
boolean
isPending
()
{
return
state
==
PENDING
;
}
}
public
void
setPending
()
{
state
=
PENDING
;
}
public
interface
Subscriber
{
public
interface
Subscriber
{
default
void
subscribeTopics
()
{
default
void
subscribeTopics
()
{
for
(
Topic
topic
:
getSubscription
())
{
for
(
Topic
topic
:
getSubscription
())
{
if
(
topic
.
hasPublished
)
{
if
(
topic
.
isPublished
()
)
{
onTopicPublished
(
topic
);
onTopicPublished
(
topic
);
}
}
topic
.
subscribe
(
this
);
topic
.
subscribe
(
this
);
...
@@ -63,13 +86,7 @@ public class Topic {
...
@@ -63,13 +86,7 @@ public class Topic {
event
.
unsubscribe
(
this
);
event
.
unsubscribe
(
this
);
}
}
}
}
default
void
onTopicPublished
()
{
void
onTopicPublished
(
Topic
topic
);
onTopicPublished
(
null
,
null
);
}
default
void
onTopicPublished
(
Topic
topic
)
{
onTopicPublished
(
topic
,
null
);
}
void
onTopicPublished
(
Topic
topic
,
Object
result
);
Topic
[]
getSubscription
();
Topic
[]
getSubscription
();
}
}
}
}
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