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_file_service.dart';
|
||||
import 'package:aves/utils/change_notifier.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
final AndroidFileUtils androidFileUtils = AndroidFileUtils._private();
|
||||
|
@ -9,6 +10,8 @@ class AndroidFileUtils {
|
|||
Set<StorageVolume> storageVolumes = {};
|
||||
Map appNameMap = {};
|
||||
|
||||
AChangeNotifier appNameChangeNotifier = AChangeNotifier();
|
||||
|
||||
AndroidFileUtils._private();
|
||||
|
||||
Future<void> init() async {
|
||||
|
@ -19,8 +22,12 @@ class AndroidFileUtils {
|
|||
downloadPath = join(primaryStorage, 'Download');
|
||||
moviesPath = join(primaryStorage, 'Movies');
|
||||
picturesPath = join(primaryStorage, 'Pictures');
|
||||
}
|
||||
|
||||
Future<void> initAppNames() async {
|
||||
appNameMap = await AndroidAppService.getAppNames()
|
||||
..addAll({'KakaoTalkDownload': 'com.kakao.talk'});
|
||||
appNameChangeNotifier.notifyListeners();
|
||||
}
|
||||
|
||||
bool isCameraPath(String path) => path != null && path.startsWith(dcimPath) && (path.endsWith('Camera') || path.endsWith('100ANDRO'));
|
||||
|
|
|
@ -33,16 +33,19 @@ class AlbumListPage extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return StreamBuilder(
|
||||
stream: source.eventBus.on<AlbumsChangedEvent>(),
|
||||
builder: (context, snapshot) => FilterNavigationPage(
|
||||
source: source,
|
||||
title: 'Albums',
|
||||
filterEntries: source.getAlbumEntries(),
|
||||
filterBuilder: (s) => AlbumFilter(s, source.getUniqueAlbumName(s)),
|
||||
emptyBuilder: () => EmptyContent(
|
||||
icon: AIcons.album,
|
||||
text: 'No albums',
|
||||
return AnimatedBuilder(
|
||||
animation: androidFileUtils.appNameChangeNotifier,
|
||||
builder: (context, child) => StreamBuilder(
|
||||
stream: source.eventBus.on<AlbumsChangedEvent>(),
|
||||
builder: (context, snapshot) => FilterNavigationPage(
|
||||
source: source,
|
||||
title: 'Albums',
|
||||
filterEntries: source.getAlbumEntries(),
|
||||
filterBuilder: (s) => AlbumFilter(s, source.getUniqueAlbumName(s)),
|
||||
emptyBuilder: () => EmptyContent(
|
||||
icon: AIcons.album,
|
||||
text: 'No albums',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -47,7 +47,8 @@ class _HomePageState extends State<HomePage> {
|
|||
return;
|
||||
}
|
||||
|
||||
await androidFileUtils.init(); // 170ms
|
||||
await androidFileUtils.init();
|
||||
unawaited(androidFileUtils.initAppNames());
|
||||
|
||||
final intentData = await ViewerService.getIntentData();
|
||||
if (intentData != null) {
|
||||
|
|
Loading…
Reference in a new issue