launch: do not wait for app names to initialize entries
This commit is contained in:
parent
510a7c8f5a
commit
bb5fae4c38
3 changed files with 22 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
||||||
import 'package:aves/services/android_app_service.dart';
|
import 'package:aves/services/android_app_service.dart';
|
||||||
import 'package:aves/services/android_file_service.dart';
|
import 'package:aves/services/android_file_service.dart';
|
||||||
|
import 'package:aves/utils/change_notifier.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
|
|
||||||
final AndroidFileUtils androidFileUtils = AndroidFileUtils._private();
|
final AndroidFileUtils androidFileUtils = AndroidFileUtils._private();
|
||||||
|
@ -9,6 +10,8 @@ class AndroidFileUtils {
|
||||||
Set<StorageVolume> storageVolumes = {};
|
Set<StorageVolume> storageVolumes = {};
|
||||||
Map appNameMap = {};
|
Map appNameMap = {};
|
||||||
|
|
||||||
|
AChangeNotifier appNameChangeNotifier = AChangeNotifier();
|
||||||
|
|
||||||
AndroidFileUtils._private();
|
AndroidFileUtils._private();
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
|
@ -19,8 +22,12 @@ class AndroidFileUtils {
|
||||||
downloadPath = join(primaryStorage, 'Download');
|
downloadPath = join(primaryStorage, 'Download');
|
||||||
moviesPath = join(primaryStorage, 'Movies');
|
moviesPath = join(primaryStorage, 'Movies');
|
||||||
picturesPath = join(primaryStorage, 'Pictures');
|
picturesPath = join(primaryStorage, 'Pictures');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> initAppNames() async {
|
||||||
appNameMap = await AndroidAppService.getAppNames()
|
appNameMap = await AndroidAppService.getAppNames()
|
||||||
..addAll({'KakaoTalkDownload': 'com.kakao.talk'});
|
..addAll({'KakaoTalkDownload': 'com.kakao.talk'});
|
||||||
|
appNameChangeNotifier.notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isCameraPath(String path) => path != null && path.startsWith(dcimPath) && (path.endsWith('Camera') || path.endsWith('100ANDRO'));
|
bool isCameraPath(String path) => path != null && path.startsWith(dcimPath) && (path.endsWith('Camera') || path.endsWith('100ANDRO'));
|
||||||
|
|
|
@ -33,16 +33,19 @@ class AlbumListPage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StreamBuilder(
|
return AnimatedBuilder(
|
||||||
stream: source.eventBus.on<AlbumsChangedEvent>(),
|
animation: androidFileUtils.appNameChangeNotifier,
|
||||||
builder: (context, snapshot) => FilterNavigationPage(
|
builder: (context, child) => StreamBuilder(
|
||||||
source: source,
|
stream: source.eventBus.on<AlbumsChangedEvent>(),
|
||||||
title: 'Albums',
|
builder: (context, snapshot) => FilterNavigationPage(
|
||||||
filterEntries: source.getAlbumEntries(),
|
source: source,
|
||||||
filterBuilder: (s) => AlbumFilter(s, source.getUniqueAlbumName(s)),
|
title: 'Albums',
|
||||||
emptyBuilder: () => EmptyContent(
|
filterEntries: source.getAlbumEntries(),
|
||||||
icon: AIcons.album,
|
filterBuilder: (s) => AlbumFilter(s, source.getUniqueAlbumName(s)),
|
||||||
text: 'No albums',
|
emptyBuilder: () => EmptyContent(
|
||||||
|
icon: AIcons.album,
|
||||||
|
text: 'No albums',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -47,7 +47,8 @@ class _HomePageState extends State<HomePage> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await androidFileUtils.init(); // 170ms
|
await androidFileUtils.init();
|
||||||
|
unawaited(androidFileUtils.initAppNames());
|
||||||
|
|
||||||
final intentData = await ViewerService.getIntentData();
|
final intentData = await ViewerService.getIntentData();
|
||||||
if (intentData != null) {
|
if (intentData != null) {
|
||||||
|
|
Loading…
Reference in a new issue