Advertisement
jasperlow

Untitled

Apr 7th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. public static class FRDESC {
  2.  
  3. // public static String getNotifEvent(String rpt_amt) {
  4. // String event =
  5. // getCtx().getRString(R.string.notif_lbl_desc_event_number);
  6. // rpt_amt = (TextUtils.isEmpty(rpt_amt)) ? "1" : rpt_amt;
  7. // if ("1".equals(rpt_amt)) {
  8. // event = String.format(event, rpt_amt, "");
  9. // // .replace("1", "");
  10. // } else {
  11. // event = String.format(event, rpt_amt, "s");
  12. // }
  13. // return (event);
  14. // }
  15.  
  16. public static String getRptDay(String rpt_amt) {
  17. String day = getCtx().getRString(R.string.rpt_lbl_desc_format_day);
  18. if ("1".equals(rpt_amt)) {
  19. day = String.format(day, rpt_amt, "").replace("1", "");
  20. } else {
  21. day = String.format(day, rpt_amt, "s");
  22. }
  23. day = String.format(getCtx().getRString(R.string.rpt_lbl_desc_day), day);
  24. return (day);
  25. }
  26.  
  27. public static String getRptWeek(String rpt_amt) {
  28. String week = getCtx().getRString(R.string.rpt_lbl_desc_format_week);
  29. if ("1".equals(rpt_amt)) {
  30. week = String.format(week, rpt_amt, "").replace("1", "");
  31. } else {
  32. week = String.format(week, rpt_amt, "s");
  33. }
  34. week = String.format(getCtx().getRString(R.string.rpt_lbl_desc_week), week);
  35. return (week);
  36. }
  37.  
  38. public static String getRptMonth(String rpt_amt) {
  39. String month = getCtx().getRString(R.string.rpt_lbl_desc_format_month);
  40. if ("1".equals(rpt_amt)) {
  41. month = String.format(month, rpt_amt, "").replace("1", "");
  42. } else {
  43. month = String.format(month, rpt_amt, "s");
  44. }
  45. month = String.format(getCtx().getRString(R.string.rpt_lbl_desc_month), month);
  46. return (month);
  47. }
  48.  
  49. public static String getRptMonth(String rpt_amt, String rpt_fallon, String rpt_weekday, Set<String> rpt_oneach,
  50. boolean isCertainDate) {
  51. String month = getCtx().getRString(R.string.rpt_lbl_desc_format_month);
  52. if ("1".equals(rpt_amt)) {
  53. month = String.format(month, rpt_amt, "").replace("1", "");
  54. } else {
  55. month = String.format(month, rpt_amt, "s");
  56. }
  57. String txt_update = "";
  58. if (isCertainDate) {
  59. String ofSth = getTxtDates(rpt_oneach);
  60. txt_update = String.format(getCtx().getRString(R.string.rpt_lbl_desc_month_each), month, ofSth);
  61. } else {
  62. String ofSth = getRankSuffix(rpt_fallon);
  63. ofSth += rpt_weekday;
  64. txt_update = String.format(getCtx().getRString(R.string.rpt_lbl_desc_month_onthe), month, ofSth);
  65. }
  66. return (txt_update);
  67. }
  68.  
  69. public static String getRptYear(String rpt_amt) {
  70. String year = getCtx().getRString(R.string.rpt_lbl_desc_format_year);
  71. if ("1".equals(rpt_amt)) {
  72. year = String.format(year, rpt_amt, "").replace("1", "");
  73. } else {
  74. year = String.format(year, rpt_amt, "s");
  75. }
  76. year = String.format(getCtx().getRString(R.string.rpt_lbl_desc_year), year);
  77. return (year);
  78. }
  79.  
  80. public static String getRptYear(String rpt_amt, String rpt_fallon, String rpt_weekday, Set<String> rpt_oneach) {
  81. String year = getCtx().getRString(R.string.rpt_lbl_desc_format_year);
  82. if ("1".equals(rpt_amt)) {
  83. year = String.format(year, rpt_amt, "").replace("1", "");
  84. } else {
  85. year = String.format(year, rpt_amt, "s");
  86. }
  87. String month = getTxtMonths(rpt_oneach);
  88. String dayofweeks = getRankSuffix(rpt_fallon);
  89. dayofweeks += rpt_weekday;
  90. String txt_update = String.format(getCtx().getRString(R.string.rpt_lbl_desc_year_onthe_of), year,
  91. dayofweeks, month);
  92. return (txt_update);
  93. }
  94.  
  95. private static String getTxtDates(Set<String> lst) {
  96. String month = "";
  97. for (String mth : lst) {
  98. month += ", " + mth;
  99. }
  100. try {
  101. int index = month.indexOf(",");
  102. month = new StringBuilder(month).replace(index, index + 1, "").toString();
  103. } catch (Exception e) {
  104. }
  105. try {
  106. int index = month.lastIndexOf(",");
  107. month = new StringBuilder(month)
  108. .replace(index, index + 1, " " + getCtx().getRString(R.string.rpt_lbl_desc_and)).toString();
  109. } catch (Exception e) {
  110. }
  111. return month.trim();
  112. }
  113.  
  114. private static String getTxtMonths(Set<String> lst) {
  115. String month = "";
  116. for (String mth : lst) {
  117. month += ", " + mth;
  118. }
  119. try {
  120. int index = month.indexOf(",");
  121. month = new StringBuilder(month).replace(index, index + 1, "").toString();
  122. } catch (Exception e) {
  123. }
  124.  
  125. try {
  126. int index = month.lastIndexOf(",");
  127. month = new StringBuilder(month)
  128. .replace(index, index + 1, " " + getCtx().getRString(R.string.rpt_lbl_desc_and)).toString();
  129. } catch (Exception e) {
  130. }
  131. return month.trim();
  132. }
  133.  
  134. private static String getRankSuffix(String text) {
  135. final String ending = "%1$s<sup>%2$s</sup> ";
  136.  
  137. final String rank_1 = getCtx().getRString(R.string.rpt_opt_rank1);
  138. final String rank_2 = getCtx().getRString(R.string.rpt_opt_rank2);
  139. final String rank_3 = getCtx().getRString(R.string.rpt_opt_rank3);
  140. final String rank_4 = getCtx().getRString(R.string.rpt_opt_rank4);
  141. final String rank_5 = getCtx().getRString(R.string.rpt_opt_rank5);
  142.  
  143. if (rank_1.equals(text)) {
  144. return String.format(ending, "1", getCtx().getRString(R.string.rpt_lbl_desc_rank1));
  145. } else if (rank_2.equals(text)) {
  146. return String.format(ending, "2", getCtx().getRString(R.string.rpt_lbl_desc_rank2));
  147. } else if (rank_3.equals(text)) {
  148. return String.format(ending, "3", getCtx().getRString(R.string.rpt_lbl_desc_rank3));
  149. } else if (rank_4.equals(text)) {
  150. return String.format(ending, "4", getCtx().getRString(R.string.rpt_lbl_desc_rank4_5));
  151. } else if (rank_5.equals(text)) {
  152. return String.format(ending, "5", getCtx().getRString(R.string.rpt_lbl_desc_rank4_5));
  153. } else {
  154. return String.format(ending, text, getCtx().getRString(R.string.rpt_lbl_desc_rank_6));
  155. }
  156.  
  157. }
  158.  
  159. public static String getNotifDue(String text) {
  160. String txt_update = getCtx().getRString(R.string.notif_lbl_desc_format_day);
  161. if ("1".equals(text)) {
  162. txt_update = String.format(txt_update, text, "");
  163. } else {
  164. txt_update = String.format(txt_update, text, "s");
  165. }
  166. txt_update = String.format(getCtx().getRString(R.string.notif_lbl_desc_day), txt_update);
  167. return (txt_update);
  168. }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement