Automatische Erkennung: neue Dateien auf dem Geraet und neue Alben am Server
- AutoScan: beim Zurueckkehren in die App wird die Zahl der Musikdateien mit der Bibliothek verglichen; nur bei Abweichung laeuft ein Scan, und hoechstens alle 5 Minuten. Gleich viele Loeschungen wie Neuzugaenge bleiben unbemerkt - dafuer gibt es den Scan von Hand. - ServerNeuheiten: meldet neu auf Navidrome aufgetauchte Alben im Online-Tab. Der erste Abruf meldet bewusst nichts, sonst waere die ganze Sammlung "neu"; er nutzt die ohnehin geladenen Alben statt eines zweiten Serveraufrufs. - Neu: MeloDb.countSongs(), countAndroidMediaStoreSongs(). 189 Tests gruen, flutter analyze ohne Befund. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018NLW1q1hzEC9goDQ1dJ98d
This commit is contained in:
co-authored by
Claude Opus 5
parent
6200c77614
commit
15e3d44453
+33
-1
@@ -1,8 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:audio_service/audio_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'downloads/downloads_screen.dart';
|
||||
import 'library/android_scan.dart';
|
||||
import 'library/auto_scan.dart';
|
||||
import 'library/category_service.dart';
|
||||
import 'library/database.dart';
|
||||
import 'library/favorites_screen.dart';
|
||||
@@ -107,11 +111,39 @@ class HomeShell extends StatefulWidget {
|
||||
State<HomeShell> createState() => _HomeShellState();
|
||||
}
|
||||
|
||||
class _HomeShellState extends State<HomeShell> {
|
||||
class _HomeShellState extends State<HomeShell> with WidgetsBindingObserver {
|
||||
int _index = 0;
|
||||
late final AutoScan _autoScan;
|
||||
|
||||
void _goTo(int index) => setState(() => _index = index);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final db = context.read<MeloDb>();
|
||||
final lib = context.read<LibraryService>();
|
||||
_autoScan = AutoScan(
|
||||
geraeteAnzahl: countAndroidMediaStoreSongs,
|
||||
bekannteAnzahl: db.countSongs,
|
||||
scanne: lib.rescan,
|
||||
);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
// Zurück in der App: nachsehen, ob inzwischen Musik dazugekommen ist.
|
||||
if (state == AppLifecycleState.resumed && Platform.isAndroid) {
|
||||
_autoScan.pruefe();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tabs = <Widget>[
|
||||
|
||||
Reference in New Issue
Block a user