1
0
mirror of https://github.com/stonega/tsacdop synced 2024-12-15 09:57:19 +01:00
tsacdop-podcast-app-android/lib/type/searchepisodes.dart
stonegate b619be9a9b Search ui changed a lot, add podcast detail panel.
Update audio service to latest version.
2020-07-22 17:34:32 +08:00

42 lines
1.1 KiB
Dart

import 'package:json_annotation/json_annotation.dart';
import 'package:tsacdop/type/searchpodcast.dart';
part 'searchepisodes.g.dart';
@JsonSerializable()
class SearchEpisodes<E> {
@_ConvertE()
final List<E> episodes;
@JsonKey(name: 'next_episode_pub_date')
final int nextEpisodeDate;
SearchEpisodes({this.episodes, this.nextEpisodeDate});
factory SearchEpisodes.fromJson(Map<String, dynamic> json) =>
_$SearchEpisodesFromJson<E>(json);
Map<String, dynamic> toJson() => _$SearchEpisodesToJson(this);
}
class _ConvertE<E> implements JsonConverter<E, Object> {
const _ConvertE();
@override
E fromJson(Object json) {
return OnlineEpisode.fromJson(json) as E;
}
@override
Object toJson(E object) {
return object;
}
}
@JsonSerializable()
class OnlineEpisode {
final String title;
@JsonKey(name: 'pub_date_ms')
final int pubDate;
@JsonKey(name: 'audio_length_sec')
final int length;
OnlineEpisode({this.title, this.pubDate, this.length});
factory OnlineEpisode.fromJson(Map<String, dynamic> json) =>
_$OnlineEpisodeFromJson(json);
Map<String, dynamic> toJson() => _$OnlineEpisodeToJson(this);
}