The Webfeed Flutter package for Appeto SDK.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

49 lignes
1.4 KiB

  1. import 'package:webfeed/util/datetime.dart';
  2. import 'package:webfeed/util/iterable.dart';
  3. import 'package:xml/xml.dart';
  4. enum SyndicationUpdatePeriod { hourly, daily, weekly, monthly, yearly }
  5. class Syndication {
  6. final SyndicationUpdatePeriod? updatePeriod;
  7. final int? updateFrequency;
  8. final DateTime? updateBase;
  9. Syndication({
  10. this.updatePeriod,
  11. this.updateFrequency,
  12. this.updateBase,
  13. });
  14. factory Syndication.parse(XmlElement element) {
  15. SyndicationUpdatePeriod updatePeriod;
  16. switch (element.findElements('sy:updatePeriod').firstOrNull?.text) {
  17. case 'hourly':
  18. updatePeriod = SyndicationUpdatePeriod.hourly;
  19. break;
  20. case 'daily':
  21. updatePeriod = SyndicationUpdatePeriod.daily;
  22. break;
  23. case 'weekly':
  24. updatePeriod = SyndicationUpdatePeriod.weekly;
  25. break;
  26. case 'monthly':
  27. updatePeriod = SyndicationUpdatePeriod.monthly;
  28. break;
  29. case 'yearly':
  30. updatePeriod = SyndicationUpdatePeriod.yearly;
  31. break;
  32. default:
  33. updatePeriod = SyndicationUpdatePeriod.daily;
  34. break;
  35. }
  36. return Syndication(
  37. updatePeriod: updatePeriod,
  38. updateFrequency: int.tryParse(
  39. element.findElements('sy:updateFrequency').firstOrNull?.text ?? '1'),
  40. updateBase: parseDateTime(
  41. element.findElements('sy:updateBase').firstOrNull?.text),
  42. );
  43. }
  44. }