Compare commits

..

2 Commits

Author SHA1 Message Date
Cursor Agent
a9fcba5ca0 feat: add initState logging to downloads screen
Added missing logging in DownloadsScreen.initState():
- 📥 Log initState() call
- 📥 Log postFrameCallback triggered
- 📥 Log before calling refreshDownloads()

This completes the logging chain to track full initialization flow.
2025-10-05 17:36:06 +00:00
Cursor Agent
185980083a feat: add comprehensive logging for downloads debugging
Added extensive logging throughout DownloadsProvider and DownloadsScreen
to diagnose why downloads screen appears empty.

DownloadsProvider.refreshDownloads():
- 📥 Log function call
- 📥 Log state changes (loading, error)
- 📥 Log TorrentPlatformService.getAllDownloads() call
- 📥 Log number of torrents received
- 📥 Log each torrent processing with index
- 📥 Log success/failure for each torrent info fetch
- 📥 Log final torrents count
- 📥 Log completion or error state

DownloadsScreen.initState() and Consumer:
- 📥 Log initState call
- 📥 Log postFrameCallback execution
- 📥 Log Consumer builder invocations
- 📥 Log provider state (isLoading, error, torrents.length)
- 📥 Log which UI is displayed:
  * CircularProgressIndicator
  * ErrorDisplay
  * Empty state message
  * Torrent list with count

All logs prefixed with 📥 for easy filtering in logcat.

Example output:
---
📥 DownloadsScreen: initState() called
📥 DownloadsScreen: postFrameCallback, calling refreshDownloads()
📥 DownloadsProvider: refreshDownloads() called
📥 Setting loading=true, error=null
📥 Calling TorrentPlatformService.getAllDownloads()...
📥 Got 0 torrents from platform service
📥 Cleared _torrents list
📥 Final torrents count: 0
📥 Setting loading=false
📥  refreshDownloads() completed successfully
📥 DownloadsScreen: Consumer builder called
📥   isLoading: false
📥   error: null
📥   torrents.length: 0
📥   → Showing empty state

This will help identify:
- Is refreshDownloads being called?
- Does TorrentPlatformService return any data?
- Are torrents parsed correctly?
- Is the correct UI state shown?
- Where does the process fail?

Usage:
Run app → Open Downloads screen → Check logcat for 📥 logs
2025-10-05 17:35:07 +00:00
3 changed files with 69 additions and 11 deletions

View File

@@ -4,6 +4,26 @@
[![Download](https://img.shields.io/github/v/release/Neo-Open-Source/neomovies-mobile?label=Download&style=for-the-badge&logo=github)](https://github.com/Neo-Open-Source/neomovies-mobile/releases/latest) [![Download](https://img.shields.io/github/v/release/Neo-Open-Source/neomovies-mobile?label=Download&style=for-the-badge&logo=github)](https://github.com/Neo-Open-Source/neomovies-mobile/releases/latest)
## Возможности
- 📱 Кроссплатформенное приложение (Android/iOS(пока не реализовано))
- 🎥 Просмотр фильмов и сериалов через WebView
- 🌙 Поддержка динамической темы
- 💾 Локальное кэширование данных
- 🔒 Безопасное хранение данных
- 🚀 Быстрая загрузка контента
- 🎨 Современный Material Design интерфейс
## Технологии
- **Flutter** - основной фреймворк
- **Provider** - управление состоянием
- **Hive** - локальная база данных
- **HTTP** - сетевые запросы
- **WebView** - воспроизведение видео
- **Cached Network Image** - кэширование изображений
- **Google Fonts** - красивые шрифты
## Установка ## Установка
1. Клонируйте репозиторий: 1. Клонируйте репозиторий:
@@ -19,7 +39,7 @@ flutter pub get
3. Создайте файл `.env` в корне проекта: 3. Создайте файл `.env` в корне проекта:
``` ```
API_URL=api.neomovies.ru API_URL=your_api_url_here
``` ```
4. Запустите приложение: 4. Запустите приложение:
@@ -34,6 +54,11 @@ flutter run
flutter build apk --release flutter build apk --release
``` ```
### iOS
```bash
flutter build ios --release
```
## Структура проекта ## Структура проекта
``` ```
@@ -52,15 +77,20 @@ lib/
- **Flutter SDK**: 3.8.1+ - **Flutter SDK**: 3.8.1+
- **Dart**: 3.8.1+ - **Dart**: 3.8.1+
- **Android**: API 21+ (Android 5.0+) - **Android**: API 21+ (Android 5.0+)
- **iOS**: iOS 11.0+
## Участие в разработке
1. Форкните репозиторий
2. Создайте ветку для новой функции (`git checkout -b feature/amazing-feature`)
3. Внесите изменения и закоммитьте (`git commit -m 'Add amazing feature'`)
4. Отправьте изменения в ветку (`git push origin feature/amazing-feature`)
5. Создайте Pull Request
## Лицензия ## Лицензия
Apache 2.0 License - [LICENSE](LICENSE). Этот проект лицензирован под Apache 2.0 License - подробности в файле [LICENSE](LICENSE).
## Контакты ## Контакты
neo.movies.mail@gmail.com Если у вас есть вопросы или предложения, создайте issue в этом репозитории.
## Благодарность
Огромная благодарность создателям проекта [LAMPAC](https://github.com/immisterio/Lampac)

View File

@@ -36,15 +36,23 @@ class DownloadsProvider with ChangeNotifier {
/// Загрузить список активных загрузок /// Загрузить список активных загрузок
Future<void> refreshDownloads() async { Future<void> refreshDownloads() async {
print('📥 DownloadsProvider: refreshDownloads() called');
try { try {
print('📥 Setting loading=true, error=null');
_setLoading(true); _setLoading(true);
_setError(null); _setError(null);
print('📥 Calling TorrentPlatformService.getAllDownloads()...');
final progress = await TorrentPlatformService.getAllDownloads(); final progress = await TorrentPlatformService.getAllDownloads();
print('📥 Got ${progress.length} torrents from platform service');
// Получаем полную информацию о каждом торренте // Получаем полную информацию о каждом торренте
_torrents.clear(); _torrents.clear();
for (final progressItem in progress) { print('📥 Cleared _torrents list');
for (int i = 0; i < progress.length; i++) {
final progressItem = progress[i];
print('📥 Processing torrent $i: ${progressItem.infoHash.substring(0, 8)}...');
try { try {
final torrentInfo = await TorrentPlatformService.getTorrent(progressItem.infoHash); final torrentInfo = await TorrentPlatformService.getTorrent(progressItem.infoHash);
if (torrentInfo != null) { if (torrentInfo != null) {
@@ -64,14 +72,22 @@ class DownloadsProvider with ChangeNotifier {
state: progressItem.state, state: progressItem.state,
savePath: '/storage/emulated/0/Download/NeoMovies', savePath: '/storage/emulated/0/Download/NeoMovies',
files: [], files: [],
)); );
print('📥 ✅ Created basic info: ${basicInfo.name}');
_torrents.add(basicInfo);
} }
} }
print('📥 Final torrents count: ${_torrents.length}');
print('📥 Setting loading=false');
_setLoading(false); _setLoading(false);
} catch (e) { print('📥 ✅ refreshDownloads() completed successfully');
_setError(e.toString()); } catch (e, stackTrace) {
print('📥 ❌ Error refreshing downloads: $e');
print('📥 Stack trace: $stackTrace');
_setError(e.toString(), stackTrace.toString());
_setLoading(false); _setLoading(false);
print('📥 Error state set, loading=false');
} }
} }

View File

@@ -16,7 +16,10 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
print('📥 DownloadsScreen: initState() called');
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
print('📥 DownloadsScreen: postFrameCallback triggered');
print('📥 DownloadsScreen: calling refreshDownloads()');
context.read<DownloadsProvider>().refreshDownloads(); context.read<DownloadsProvider>().refreshDownloads();
}); });
} }
@@ -40,13 +43,20 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
), ),
body: Consumer<DownloadsProvider>( body: Consumer<DownloadsProvider>(
builder: (context, provider, child) { builder: (context, provider, child) {
print('📥 DownloadsScreen: Consumer builder called');
print('📥 isLoading: ${provider.isLoading}');
print('📥 error: ${provider.error}');
print('📥 torrents.length: ${provider.torrents.length}');
if (provider.isLoading) { if (provider.isLoading) {
print('📥 → Showing CircularProgressIndicator');
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
); );
} }
if (provider.error != null) { if (provider.error != null) {
print('📥 → Showing ErrorDisplay');
return ErrorDisplay( return ErrorDisplay(
title: 'Ошибка загрузки торрентов', title: 'Ошибка загрузки торрентов',
error: provider.error!, error: provider.error!,
@@ -58,6 +68,7 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
} }
if (provider.torrents.isEmpty) { if (provider.torrents.isEmpty) {
print('📥 → Showing empty state');
return Center( return Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
@@ -87,6 +98,7 @@ class _DownloadsScreenState extends State<DownloadsScreen> {
); );
} }
print('📥 → Showing ${provider.torrents.length} torrents in list');
return RefreshIndicator( return RefreshIndicator(
onRefresh: () async { onRefresh: () async {
await provider.refreshDownloads(); await provider.refreshDownloads();