mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-04 01:00:44 +02:00
refactor(core): reduce generated and duplicate code
This commit is contained in:
@@ -216,16 +216,4 @@ class CacheStats {
|
||||
final int totalSizeBytes;
|
||||
|
||||
const CacheStats({required this.fileCount, required this.totalSizeBytes});
|
||||
|
||||
String get formattedSize {
|
||||
if (totalSizeBytes < 1024) {
|
||||
return '$totalSizeBytes B';
|
||||
} else if (totalSizeBytes < 1024 * 1024) {
|
||||
return '${(totalSizeBytes / 1024).toStringAsFixed(1)} KB';
|
||||
} else if (totalSizeBytes < 1024 * 1024 * 1024) {
|
||||
return '${(totalSizeBytes / (1024 * 1024)).toStringAsFixed(1)} MB';
|
||||
} else {
|
||||
return '${(totalSizeBytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:spotiflac_android/services/sqlite_helpers.dart' as sqlite;
|
||||
import 'package:spotiflac_android/utils/isrc_utils.dart' as isrc;
|
||||
import 'package:spotiflac_android/utils/logger.dart';
|
||||
import 'package:spotiflac_android/utils/path_match_keys.dart';
|
||||
|
||||
@@ -286,9 +287,7 @@ class HistoryDatabase {
|
||||
static String normalizeLookupText(String? value) =>
|
||||
sqlite.normalizeLookupText(value);
|
||||
|
||||
static String normalizeIsrc(String? value) {
|
||||
return (value ?? '').trim().toUpperCase().replaceAll(RegExp(r'[-\s]'), '');
|
||||
}
|
||||
static String normalizeIsrc(String? value) => isrc.normalizeIsrc(value);
|
||||
|
||||
static String normalizeSpotifyId(String? value) {
|
||||
return (value ?? '').trim().toLowerCase();
|
||||
|
||||
@@ -240,8 +240,6 @@ class LocalLibrarySource {
|
||||
|
||||
enum LocalLibrarySortMode { album, title, artist, latest, quality }
|
||||
|
||||
enum LocalLibraryFilterMode { all, albums, singles }
|
||||
|
||||
class LocalLibraryLookupIndex {
|
||||
final Set<String> isrcs;
|
||||
final Set<String> matchKeys;
|
||||
|
||||
Reference in New Issue
Block a user