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.

52 lignes
1.4 KiB

  1. import 'package:webfeed/util/datetime.dart';
  2. import 'package:webfeed/util/xml.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. if (element == null) {
  16. return null;
  17. }
  18. SyndicationUpdatePeriod updatePeriod;
  19. switch (findFirstElement(element, 'sy:updatePeriod')?.text) {
  20. case 'hourly':
  21. updatePeriod = SyndicationUpdatePeriod.hourly;
  22. break;
  23. case 'daily':
  24. updatePeriod = SyndicationUpdatePeriod.daily;
  25. break;
  26. case 'weekly':
  27. updatePeriod = SyndicationUpdatePeriod.weekly;
  28. break;
  29. case 'monthly':
  30. updatePeriod = SyndicationUpdatePeriod.monthly;
  31. break;
  32. case 'yearly':
  33. updatePeriod = SyndicationUpdatePeriod.yearly;
  34. break;
  35. default:
  36. updatePeriod = SyndicationUpdatePeriod.daily;
  37. break;
  38. }
  39. return Syndication(
  40. updatePeriod: updatePeriod,
  41. updateFrequency: int.tryParse(
  42. findFirstElement(element, 'sy:updateFrequency')?.text ?? '1'),
  43. updateBase:
  44. parseDateTime(findFirstElement(element, 'sy:updateBase')?.text),
  45. );
  46. }
  47. }