Missing scrolling, homepage reload, sections page

This commit is contained in:
exttex 2020-08-16 22:17:22 +02:00
parent d4299f736f
commit 3e5641b3c2
7 changed files with 102 additions and 34 deletions

View file

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:dio/dio.dart';
import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
@ -29,6 +31,7 @@ class DeezerAPI {
"Accept-Language": "${settings.deezerLanguage??"en"}-${settings.deezerCountry??'US'},${settings.deezerLanguage??"en"};q=0.9,en-US;q=0.8,en;q=0.7",
"Connection": "keep-alive"
};
Future _authorizing;
CookieJar _cookieJar = new CookieJar();
@ -75,8 +78,16 @@ class DeezerAPI {
return response.data;
}
//Wrapper so it can be globally awaited
Future authorize() async {
if (_authorizing == null) {
this._authorizing = this._authorize();
}
return _authorizing;
}
//Authorize, bool = success
Future<bool> authorize() async {
Future<bool> _authorize() async {
try {
Map<dynamic, dynamic> data = await callApi('deezer.getUserData');
if (data['results']['USER']['USER_ID'] == 0) {

View file

@ -553,14 +553,24 @@ class HomePageSection {
String title;
HomePageSectionLayout layout;
//For loading more items
String pagePath;
bool hasMore;
@JsonKey(fromJson: _homePageItemFromJson, toJson: _homePageItemToJson)
List<HomePageItem> items;
HomePageSection({this.layout, this.items, this.title});
HomePageSection({this.layout, this.items, this.title, this.pagePath, this.hasMore});
//JSON
factory HomePageSection.fromPrivateJson(Map<dynamic, dynamic> json) {
HomePageSection hps = HomePageSection(title: json['title'], items: []);
HomePageSection hps = HomePageSection(
title: json['title'],
items: [],
pagePath: json['target'],
hasMore: json['hasMoreItems']??false
);
String layout = json['layout'];
//No ads there
if (layout == 'ads') return null;

View file

@ -273,6 +273,8 @@ HomePageSection _$HomePageSectionFromJson(Map<String, dynamic> json) {
_$enumDecodeNullable(_$HomePageSectionLayoutEnumMap, json['layout']),
items: HomePageSection._homePageItemFromJson(json['items']),
title: json['title'] as String,
pagePath: json['pagePath'] as String,
hasMore: json['hasMore'] as bool,
);
}
@ -280,6 +282,8 @@ Map<String, dynamic> _$HomePageSectionToJson(HomePageSection instance) =>
<String, dynamic>{
'title': instance.title,
'layout': _$HomePageSectionLayoutEnumMap[instance.layout],
'pagePath': instance.pagePath,
'hasMore': instance.hasMore,
'items': HomePageSection._homePageItemToJson(instance.items),
};

View file

@ -62,12 +62,12 @@ class PlayerHelper {
await AudioService.start(
backgroundTaskEntrypoint: backgroundTaskEntrypoint,
androidEnableQueue: true,
androidStopForegroundOnPause: false,
androidStopForegroundOnPause: true,
androidNotificationOngoing: false,
androidNotificationClickStartsActivity: true,
androidNotificationChannelDescription: 'Freezer',
androidNotificationChannelName: 'Freezer',
androidNotificationIcon: 'drawable/ic_logo'
androidNotificationIcon: 'drawable/ic_logo',
);
}
@ -470,6 +470,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
@override
Future onClose() async {
print('onClose');
await onStop();
}
@ -478,7 +479,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
_player.stop();
if (_eventSub != null) _eventSub.cancel();
super.onStop();
await super.onStop();
}
//Get queue save file path