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
cf17e21a
Commit
cf17e21a
authored
Aug 03, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proper callback to trigger UI update
parent
0e0240c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
14 deletions
+25
-14
build.gradle
app/build.gradle
+1
-1
ReposFragment.java
app/src/full/java/com/topjohnwu/magisk/ReposFragment.java
+3
-8
UpdateRepos.java
...rc/full/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
+0
-5
RepoDatabaseHelper.java
...ava/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
+21
-0
No files found.
app/build.gradle
View file @
cf17e21a
...
...
@@ -27,7 +27,7 @@ android {
productFlavors
{
full
{
versionCode
13
1
versionCode
13
2
versionName
"5.8.3"
}
stub
{
...
...
app/src/full/java/com/topjohnwu/magisk/ReposFragment.java
View file @
cf17e21a
...
...
@@ -34,7 +34,7 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber {
@BindView
(
R
.
id
.
empty_rv
)
TextView
emptyRv
;
@BindView
(
R
.
id
.
swipeRefreshLayout
)
SwipeRefreshLayout
mSwipeRefreshLayout
;
p
ublic
static
ReposAdapter
adapter
;
p
rivate
ReposAdapter
adapter
;
@Override
public
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
...
...
@@ -62,12 +62,6 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber {
return
view
;
}
@Override
public
void
onPause
()
{
super
.
onPause
();
adapter
=
null
;
}
@Override
public
int
[]
getSubscribedTopics
()
{
return
new
int
[]
{
Topic
.
MODULE_LOAD_DONE
,
Topic
.
REPO_LOAD_DONE
};
...
...
@@ -77,12 +71,12 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber {
public
void
onPublish
(
int
topic
,
Object
[]
result
)
{
if
(
topic
==
Topic
.
MODULE_LOAD_DONE
)
{
adapter
=
new
ReposAdapter
(
mm
.
repoDB
,
(
Map
<
String
,
Module
>)
result
[
0
]);
mm
.
repoDB
.
registerAdapter
(
adapter
);
recyclerView
.
setAdapter
(
adapter
);
recyclerView
.
setVisibility
(
View
.
VISIBLE
);
emptyRv
.
setVisibility
(
View
.
GONE
);
}
if
(
Topic
.
isPublished
(
getSubscribedTopics
()))
{
adapter
.
notifyDBChanged
();
mSwipeRefreshLayout
.
setRefreshing
(
false
);
recyclerView
.
setVisibility
(
adapter
.
getItemCount
()
==
0
?
View
.
GONE
:
View
.
VISIBLE
);
emptyRv
.
setVisibility
(
adapter
.
getItemCount
()
==
0
?
View
.
VISIBLE
:
View
.
GONE
);
...
...
@@ -125,6 +119,7 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber {
@Override
public
void
onDestroyView
()
{
super
.
onDestroyView
();
mm
.
repoDB
.
unregisterAdapter
();
unbinder
.
unbind
();
}
}
app/src/full/java/com/topjohnwu/magisk/asyncs/UpdateRepos.java
View file @
cf17e21a
...
...
@@ -6,7 +6,6 @@ import android.os.AsyncTask;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.ReposFragment
;
import
com.topjohnwu.magisk.container.Repo
;
import
com.topjohnwu.magisk.utils.Logger
;
import
com.topjohnwu.magisk.utils.Topic
;
...
...
@@ -80,10 +79,6 @@ public class UpdateRepos {
set
.
remove
(
id
);
repo
.
update
(
date
);
mm
.
repoDB
.
addRepo
(
repo
);
Data
.
mainHandler
.
post
(()
->
{
if
(
ReposFragment
.
adapter
!=
null
)
ReposFragment
.
adapter
.
notifyDBChanged
();
});
}
catch
(
Repo
.
IllegalRepoException
e
)
{
Logger
.
debug
(
e
.
getMessage
());
mm
.
repoDB
.
removeRepo
(
id
);
...
...
app/src/full/java/com/topjohnwu/magisk/database/RepoDatabaseHelper.java
View file @
cf17e21a
...
...
@@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteOpenHelper;
import
com.topjohnwu.magisk.Const
;
import
com.topjohnwu.magisk.Data
;
import
com.topjohnwu.magisk.MagiskManager
;
import
com.topjohnwu.magisk.adapters.ReposAdapter
;
import
com.topjohnwu.magisk.container.Repo
;
import
java.util.HashSet
;
...
...
@@ -20,6 +21,7 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
private
SQLiteDatabase
mDb
;
private
MagiskManager
mm
;
private
ReposAdapter
adapter
;
public
RepoDatabaseHelper
(
Context
context
)
{
super
(
context
,
"repo.db"
,
null
,
DATABASE_VER
);
...
...
@@ -63,15 +65,18 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
public
void
clearRepo
()
{
mDb
.
delete
(
TABLE_NAME
,
null
,
null
);
notifyAdapter
();
}
public
void
removeRepo
(
String
id
)
{
mDb
.
delete
(
TABLE_NAME
,
"id=?"
,
new
String
[]
{
id
});
notifyAdapter
();
}
public
void
removeRepo
(
Repo
repo
)
{
mDb
.
delete
(
TABLE_NAME
,
"repo_name=?"
,
new
String
[]
{
repo
.
getRepoName
()
});
notifyAdapter
();
}
public
void
removeRepo
(
Iterable
<
String
>
list
)
{
...
...
@@ -79,10 +84,12 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
if
(
id
==
null
)
continue
;
mDb
.
delete
(
TABLE_NAME
,
"id=?"
,
new
String
[]
{
id
});
}
notifyAdapter
();
}
public
void
addRepo
(
Repo
repo
)
{
mDb
.
replace
(
TABLE_NAME
,
null
,
repo
.
getContentValues
());
notifyAdapter
();
}
public
Repo
getRepo
(
String
id
)
{
...
...
@@ -121,4 +128,18 @@ public class RepoDatabaseHelper extends SQLiteOpenHelper {
}
return
set
;
}
public
void
registerAdapter
(
ReposAdapter
a
)
{
adapter
=
a
;
}
public
void
unregisterAdapter
()
{
adapter
=
null
;
}
private
void
notifyAdapter
()
{
if
(
adapter
!=
null
)
{
Data
.
mainHandler
.
post
(
adapter:
:
notifyDBChanged
);
}
}
}
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