Skip to content

Commit

Permalink
singleTask
Browse files Browse the repository at this point in the history
  • Loading branch information
Notsfsssf committed Jul 28, 2020
1 parent daf70bf commit e57a5b3
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ android {
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.perol.pixez"
applicationId "com.perol.play.pixez"
minSdkVersion 21
targetSdkVersion 29
versionCode 15
versionCode 16
versionName "0.1.2 element"
}
compileOptions {
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_en-US.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Recommend_for_you" : MessageLookupByLibrary.simpleMessage("For you"),
"Reply" : MessageLookupByLibrary.simpleMessage("Reply"),
"Report_Message" : MessageLookupByLibrary.simpleMessage("Report this content if it makes you feel uncomfortable, we will remove it ASAP once we confirmed that it\'s harmful."),
"Retry" : MessageLookupByLibrary.simpleMessage("Retry"),
"Retry_Failed_Tasks" : MessageLookupByLibrary.simpleMessage("Retry failed tasks"),
"Running" : MessageLookupByLibrary.simpleMessage("Running"),
"Save" : MessageLookupByLibrary.simpleMessage("Save"),
Expand Down Expand Up @@ -179,6 +180,7 @@ class MessageLookup extends MessageLookupByLibrary {
"popular_desc" : MessageLookupByLibrary.simpleMessage("Popular"),
"private" : MessageLookupByLibrary.simpleMessage("Private"),
"public" : MessageLookupByLibrary.simpleMessage("Public"),
"refresh" : MessageLookupByLibrary.simpleMessage("Refresh"),
"report" : MessageLookupByLibrary.simpleMessage("Report"),
"title_and_caption" : MessageLookupByLibrary.simpleMessage("Title and description"),
"total_bookmark" : MessageLookupByLibrary.simpleMessage("Total likes"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_zh-CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Recommend_for_you" : MessageLookupByLibrary.simpleMessage("为你推荐"),
"Reply" : MessageLookupByLibrary.simpleMessage("回复"),
"Report_Message" : MessageLookupByLibrary.simpleMessage("如果该内容让你感到不适,点击确定回报给审核,该内容会在核实后立即删除,我们会尽快处理该内容"),
"Retry" : MessageLookupByLibrary.simpleMessage("重试"),
"Retry_Failed_Tasks" : MessageLookupByLibrary.simpleMessage("重试失败任务"),
"Running" : MessageLookupByLibrary.simpleMessage("进行中"),
"Save" : MessageLookupByLibrary.simpleMessage("保存"),
Expand Down Expand Up @@ -179,6 +180,7 @@ class MessageLookup extends MessageLookupByLibrary {
"popular_desc" : MessageLookupByLibrary.simpleMessage("热度降序"),
"private" : MessageLookupByLibrary.simpleMessage("非公开"),
"public" : MessageLookupByLibrary.simpleMessage("公开"),
"refresh" : MessageLookupByLibrary.simpleMessage("刷新"),
"report" : MessageLookupByLibrary.simpleMessage("举报"),
"title_and_caption" : MessageLookupByLibrary.simpleMessage("标题和总结"),
"total_bookmark" : MessageLookupByLibrary.simpleMessage("收藏量"),
Expand Down
2 changes: 2 additions & 0 deletions lib/generated/intl/messages_zh-TW.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Recommend_for_you" : MessageLookupByLibrary.simpleMessage("為你推薦"),
"Reply" : MessageLookupByLibrary.simpleMessage("回覆"),
"Report_Message" : MessageLookupByLibrary.simpleMessage("如果該內容讓你感到不適,可點擊確定以回報審核,我們會盡快處理,該內容將會在問題被核實後立即刪除"),
"Retry" : MessageLookupByLibrary.simpleMessage("重試"),
"Retry_Failed_Tasks" : MessageLookupByLibrary.simpleMessage("重試失敗工作"),
"Running" : MessageLookupByLibrary.simpleMessage("進行中"),
"Save" : MessageLookupByLibrary.simpleMessage("儲存"),
Expand Down Expand Up @@ -179,6 +180,7 @@ class MessageLookup extends MessageLookupByLibrary {
"popular_desc" : MessageLookupByLibrary.simpleMessage("熱度降序"),
"private" : MessageLookupByLibrary.simpleMessage("非公開"),
"public" : MessageLookupByLibrary.simpleMessage("公開"),
"refresh" : MessageLookupByLibrary.simpleMessage("刷新"),
"report" : MessageLookupByLibrary.simpleMessage("檢舉"),
"title_and_caption" : MessageLookupByLibrary.simpleMessage("標題和簡介"),
"total_bookmark" : MessageLookupByLibrary.simpleMessage("收藏量"),
Expand Down
20 changes: 20 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/l10n/intl_en_US.arb
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,7 @@
"Retry_Failed_Tasks": "Retry failed tasks",
"Clear_Completed_Tasks": "Clear completed tasks",
"Crosscount": "Crosscount",
"Need_To_Restart_App": "Need to restart app"
"Need_To_Restart_App": "Need to restart app",
"refresh": "Refresh",
"Retry": "Retry"
}
4 changes: 3 additions & 1 deletion lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,7 @@
"Retry_Failed_Tasks": "重试失败任务",
"Clear_Completed_Tasks": "清空已完成任务",
"Crosscount": "列数",
"Need_To_Restart_App": "需要重启app"
"Need_To_Restart_App": "需要重启app",
"refresh": "刷新",
"Retry": "重试"
}
4 changes: 3 additions & 1 deletion lib/l10n/intl_zh_TW.arb
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,7 @@
"Retry_Failed_Tasks": "重試失敗工作",
"Clear_Completed_Tasks": "清空已完成工作",
"Crosscount": "列數",
"Need_To_Restart_App": "需要重啟app"
"Need_To_Restart_App": "需要重啟app",
"refresh": "刷新",
"Retry": "重試"
}
8 changes: 7 additions & 1 deletion lib/lighting/lighting_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ class _LightingListState extends State<LightingList> {
Container(
height: 90,
),
Text(':(', style: Theme.of(context).textTheme.headline4),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(':(', style: Theme.of(context).textTheme.headline4),
),
FlatButton(onPressed: (){
_store.fetch();
}, child: Text(I18n.of(context).Retry)),
Padding(
padding: const EdgeInsets.all(16.0),
child: Text('${_store.errorMessage}'),
Expand Down
27 changes: 4 additions & 23 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,15 @@ class _MyAppState extends State<MyApp> {
muteStore.fetchBanIllusts();
muteStore.fetchBanTags();
time = _port.hashCode;
debugPrint('time${time}');
initMethod();
super.initState();
}

initMethod() async {
int portInt = 0;
bool success = IsolateNameServer.registerPortWithName(
_port.sendPort, 'downloader${portInt}');
while (!success && portInt <= 1) {
portInt++;
success = IsolateNameServer.registerPortWithName(
_port.sendPort, 'downloader${portInt}');
if(success) break;
}
print('final regitser :downloader${portInt}');
bool success =
IsolateNameServer.registerPortWithName(_port.sendPort, 'downloader');
if (!success) return;
_port.listen((dynamic data) async {
print('listen hash${saveStore.urls.hashCode}');
String id = data[0];
DownloadTaskStatus status = data[1];
if (status == DownloadTaskStatus.complete) {
Expand Down Expand Up @@ -122,25 +112,16 @@ class _MyAppState extends State<MyApp> {
removeUrl(String id) async {
saveStore.maps[id] = null;
String queryString = 'SELECT * FROM task WHERE task_id=\'${id}\'';
debugPrint(queryString);
final tasks =
await FlutterDownloader.loadTasksWithRawQuery(query: queryString);
if (tasks != null && tasks.isNotEmpty) {
print('remove hash${saveStore.urls.hashCode}');
print(saveStore.urls.remove(tasks.first.url));
saveStore.urls.remove(tasks.first.url);
}
}

static void downloadCallback(
String id, DownloadTaskStatus status, int progress) {
int portInt = 0;
SendPort send = IsolateNameServer.lookupPortByName('downloader${portInt}');
while (send == null && portInt <= 1) {
portInt++;
send = IsolateNameServer.lookupPortByName('downloader${portInt}'); //无奈之举
}

print('final regitsr :downloader${portInt}');
SendPort send = IsolateNameServer.lookupPortByName('downloader');
if (send != null) send.send([id, status, progress]);
final SendPort send1 = IsolateNameServer.lookupPortByName('downloader_pro');
if (send1 != null) send1.send([id, status, progress]);
Expand Down
16 changes: 8 additions & 8 deletions lib/page/hello/android_hello_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
int id = int.parse(idSource);
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return IllustPage(
id: id,
Expand All @@ -142,7 +142,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
int id = int.parse(idSource);
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return UsersPage(
id: id,
Expand All @@ -159,7 +159,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
int id = int.parse(paths[index + 1]);
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return IllustPage(id: id);
}));
Expand All @@ -174,7 +174,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
int id = int.parse(paths[index + 1]);
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return UsersPage(
id: id,
Expand All @@ -189,7 +189,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
var id = link.queryParameters['illust_id'];
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return IllustPage(id: int.parse(id));
}));
Expand All @@ -201,7 +201,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
var id = link.queryParameters['id'];
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return UsersPage(
id: int.parse(id),
Expand All @@ -217,7 +217,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
int id = int.parse(link.pathSegments[link.pathSegments.length - 1]);
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return IllustPage(id: id);
}));
Expand All @@ -229,7 +229,7 @@ class _AndroidHelloPageState extends State<AndroidHelloPage> {
try {
int id = int.parse(link.pathSegments[link.pathSegments.length - 1]);
Navigator.of(context, rootNavigator: true)
.push(MaterialPageRoute(builder: (context) {
.pushReplacement(MaterialPageRoute(builder: (context) {
saveStore.context = context;
return UsersPage(
id: id,
Expand Down
3 changes: 1 addition & 2 deletions lib/store/save_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ abstract class _SaveStoreBase with Store {
}

_joinQueue(String url, Illusts illusts, String fileName) async {
print('save hash${saveStore.urls.hashCode}');
if (saveStore.urls.contains(url)) {
streamController.add(SaveStream(SaveState.INQUEUE, illusts));
return;
Expand All @@ -198,7 +197,7 @@ abstract class _SaveStoreBase with Store {
},
fileName: fileName,
showNotification:
true, // show download progress in status bar (for Android)
false, // show download progress in status bar (for Android)
openFileFromNotification:
false, // click on notification to open downloaded file (for Android)
);
Expand Down

0 comments on commit e57a5b3

Please sign in to comment.