Entry.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * DSBDirect
  3. * Copyright (C) 2019 Fynn Godau
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. *
  18. * This software is not affiliated with heinekingmedia GmbH, the
  19. * developer of the DSB platform.
  20. */
  21. package godau.fynn.dsbdirect.table;
  22. import android.support.annotation.Nullable;
  23. import godau.fynn.dsbdirect.Utility;
  24. import java.util.Date;
  25. public class Entry {
  26. private String mAffectedClass;
  27. private String mLesson;
  28. private String mReplacementTeacher;
  29. private String mInfo;
  30. private Date mDate;
  31. public Entry(@Nullable String affectedClass, @Nullable String lesson, @Nullable String replacementTeacher,
  32. @Nullable String info, @Nullable Date date) {
  33. mAffectedClass = affectedClass;
  34. mLesson = lesson;
  35. mReplacementTeacher = replacementTeacher;
  36. mInfo = info;
  37. mDate = date;
  38. if (mAffectedClass == null) {
  39. mAffectedClass = "";
  40. }
  41. if (mLesson == null) {
  42. mLesson = "";
  43. } else {
  44. mLesson = mLesson.replaceAll(" ", "");
  45. }
  46. if (mReplacementTeacher == null) {
  47. mReplacementTeacher = "";
  48. }
  49. if (mInfo == null) {
  50. mInfo = "";
  51. }
  52. }
  53. public String getAffectedClass() {
  54. return mAffectedClass;
  55. }
  56. public void setAffectedClass(String affectedClass) {
  57. mAffectedClass = affectedClass;
  58. }
  59. public String getLesson() {
  60. return mLesson;
  61. }
  62. public void setLesson(String lesson) {
  63. mLesson = lesson;
  64. }
  65. public String getReplacementTeacher() {
  66. return mReplacementTeacher;
  67. }
  68. public void setReplacementTeacher(String replacementTeacher) {
  69. mReplacementTeacher = replacementTeacher;
  70. }
  71. public String getInfo() {
  72. return mInfo;
  73. }
  74. public void setInfo(String info) {
  75. mInfo = info;
  76. }
  77. public Date getDate() {
  78. return mDate;
  79. }
  80. public void setDate(Date date) {
  81. mDate = date;
  82. }
  83. public String getShareText(Utility u) {
  84. String text = Utility.smartConcatenate(new String[]{
  85. u.formatDate(mDate),
  86. mAffectedClass,
  87. mLesson,
  88. mReplacementTeacher,
  89. mInfo
  90. }, " · ");
  91. // There might be some html in there that needs to go away
  92. text = text.replaceAll("<br>", "\n");
  93. text = text.replaceAll("</*strike>", "~");
  94. return text;
  95. }
  96. }