kusha45

calendar

Feb 9th, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.80 KB | None | 0 0
  1. /**************************************************************************************************************************/
  2. SimpleDateFormat sdf = new SimpleDateFormat("M-dd-yyyy");
  3. calendar = Calendar.getInstance();
  4. week = calendar.get(Calendar.WEEK_OF_YEAR);
  5. year = calendar.get(Calendar.YEAR);
  6. monthName = months[calendar.get(Calendar.MONTH)];
  7. tvmonthName.setText(monthName);
  8.  
  9. calendar = Calendar.getInstance();
  10. calendar.clear();
  11. calendar.set(Calendar.YEAR, year);
  12. calendar.set(Calendar.WEEK_OF_YEAR, week);
  13. date = calendar.getTime();
  14. String dt;
  15.  
  16. dt = sdf.format(date);
  17. calendar.add(Calendar.DATE, 1);
  18. calendar.set(Calendar.YEAR, year);
  19. calendar.set(Calendar.WEEK_OF_YEAR, week);
  20.  
  21. try {
  22. calendar.setTime(sdf.parse(dt));
  23. } catch (ParseException e2) {
  24.  
  25. e2.printStackTrace();
  26. }
  27. calendar.add(Calendar.DATE, -1);
  28. //new AsyncIssue().execute();
  29. if(ConnectionStatus.equals("1")){
  30. try {
  31.  
  32. for(int i = 0; i < 7; i++) {
  33.  
  34. calendar.add(Calendar.DATE, 1);
  35. final String strDate = sdf.format(calendar.getTime());
  36. tvDate[i].setText(strDate);
  37.  
  38. //Create Simple Note
  39. tvCreateSimpleNote[i] = new Button(Calender.this);
  40. tvCreateSimpleNote[i].setText("Click Here for Notes");
  41. tvCreateSimpleNote[i].setTextColor(Color.parseColor("#800000"));
  42. tvCreateSimpleNote[i].setTypeface(null, Typeface.BOLD);
  43. tvCreateSimpleNote[i].setWidth(50);
  44. tvCreateSimpleNote[i].setHeight(1);
  45. tvCreateSimpleNote[i].setTextSize(11);
  46.  
  47. //tvCreateSimpleNote[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  48. layoutLinear[i].addView(tvCreateSimpleNote[i]);
  49.  
  50. tvCreateSimpleNote[i].setOnClickListener(new OnClickListener() {
  51. public void onClick(View v) {
  52. Intent intent = new Intent(Calender.this,NewCalendarNote.class);
  53. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  54. intent.putExtra("Flag", "Click for New Note");
  55. intent.putExtra("Start Date", strDate);
  56. startActivity(intent);
  57. }
  58. });
  59.  
  60. // Issues
  61. String LDID = "";
  62. JSONObject[] arrJSONCalData = null;
  63.  
  64. if(Getdata.connflag == false){
  65. arrJSONCalData = gd.FillCalendarData(Login.userId, strDate, Login.userName);
  66. }
  67. else{
  68. arrJSONCalData = gd.FillCalendarData(Login.userId, strDate, Login.userName);
  69. }
  70.  
  71. for(int k = 0 ; k < arrJSONCalData.length;k++){
  72.  
  73. String leaveTitle = arrJSONCalData[k].get("leaveTitle").toString();
  74. LDID = arrJSONCalData[k].get("LDID").toString();
  75.  
  76. final String calDisplay = arrJSONCalData[k].get("detail").toString();
  77. final String headerinIssue = arrJSONCalData[k].get("Header").toString();
  78. final String deleteReason = arrJSONCalData[k].get("Delete_reason").toString();
  79.  
  80. System.out.println(i + " :=> LeaveTitle : " + leaveTitle);
  81. System.out.println(i + " :=> Detail : " + arrJSONCalData[k].get("detail").toString());
  82. System.out.println(i + " :=> Header : " + arrJSONCalData[k].get("Header").toString());
  83. System.out.println(i + " :=> Delete_Reason : " + arrJSONCalData[k].get("Delete_reason").toString());
  84. System.out.println(i + " :=> LDID : " + arrJSONCalData[k].get("LDID").toString());
  85.  
  86. tvIssue[i] = new TextView(Calender.this);
  87. tvIssue[i].setText("> " + leaveTitle);
  88. tvIssue[i].setTag(LDID);
  89. tvIssue[i].setTextColor(Color.parseColor("#000000"));
  90.  
  91. if(k % 2 == 0 || k == 0){
  92. tvIssue[i].setBackgroundColor(Color.parseColor("#bdc3bd"));
  93. }
  94. tvIssue[i].setWidth(150);
  95. tvIssue[i].setTextSize(11);
  96. tvIssue[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  97. tvIssue[i].offsetTopAndBottom(5);
  98. layoutLinear[i].addView(tvIssue[i]);
  99.  
  100. tvIssue[i].setOnClickListener(new OnClickListener() {
  101. public void onClick(View v) {
  102. try {
  103.  
  104. System.out.println("Reason in CLick :"+deleteReason);
  105. System.out.println("LDID in CLick :"+ v.getTag().toString());
  106. System.out.println("calDisplay in CLick :" + calDisplay);
  107. System.out.println("headerinIssue in CLick :"+ headerinIssue);
  108.  
  109. Intent intent = new Intent(Calender.this,AddDisplayIssue.class);
  110. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  111. intent.putExtra("Detail",calDisplay);
  112. intent.putExtra("LDID", v.getTag().toString());
  113. intent.putExtra("Header", headerinIssue);
  114. intent.putExtra("Delete Reason",deleteReason);
  115. intent.putExtra("Flag", "DisplayIssueDetail");
  116.  
  117. startActivity(intent);
  118. }
  119. catch (Exception e) {
  120. System.out.println("Error on click of Issue :"+e);
  121. }
  122. }
  123. });
  124. }
  125.  
  126. //Simple Note
  127. String strNoteTitle = "";
  128. String strNoteID = "";
  129. reason = "";
  130. JSONObject[] arrJSONsimpleNote = null;
  131. if(Getdata.connflag == false){
  132. arrJSONsimpleNote = gd.displaySimpleNote(Login.userId,strDate);
  133. }
  134. else{
  135. arrJSONsimpleNote = gd.displaySimpleNote(Login.userId,strDate);
  136. }
  137.  
  138. for(int k = 0 ; k < arrJSONsimpleNote.length ; k++){
  139.  
  140. strNoteTitle = arrJSONsimpleNote[k].get("Note_Title").toString();
  141. strNoteID = arrJSONsimpleNote[k].get("Note_Id").toString();
  142. final String noteDetail = arrJSONsimpleNote[k].get("Note_Detail").toString();
  143. final String reason = arrJSONsimpleNote[k].get("Delete_reason").toString();
  144.  
  145. if(Getdata.connflag == true){
  146. final String strToDateInNote = gd.ViewtoDateinNote(Login.userId,strDate, strNoteID);
  147. tvSimpleNote[i] = new TextView(Calender.this);
  148.  
  149. if(k % 2 == 0 || k == 0){
  150. tvSimpleNote[i].setBackgroundColor(Color.parseColor("#bdc3bd"));
  151. }
  152.  
  153. tvSimpleNote[i].setText(strNoteTitle);
  154. tvSimpleNote[i].setTag(strNoteID);
  155. tvSimpleNote[i].setMaxLines(1);
  156. tvSimpleNote[i].setTextColor(Color.parseColor("#000000"));
  157. tvSimpleNote[i].setWidth(150);
  158. tvSimpleNote[i].setTextSize(11);
  159. tvSimpleNote[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  160. layoutLinear[i].addView(tvSimpleNote[i]);
  161.  
  162. tvSimpleNote[i].setOnClickListener(new OnClickListener() {
  163.  
  164. public void onClick(View v1) {
  165. Intent intent = new Intent(Calender.this,NewCalendarNote.class);
  166. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  167. intent.putExtra("Flag", "DisplayNote");
  168. System.out.println("Note Detail in Click :"+strNoteDetail);
  169. System.out.println("Reason in Click :"+reason);
  170. System.out.println("Dates in Click :"+strToDateInNote);
  171.  
  172. intent.putExtra("NoteDetail", noteDetail);
  173. intent.putExtra("NoteId", v1.getTag().toString());
  174. intent.putExtra("CurrentDate", strDate);
  175. intent.putExtra("Delete reason", reason);
  176. intent.putExtra("Todate", strToDateInNote);
  177. startActivity(intent);
  178. }
  179. });
  180. }
  181. }
  182.  
  183. /**************************************************************************************************************************************************/
  184. //Room Reservation
  185. if(Getdata.connflag == true){
  186. JSONObject[] RR_jsonobj = gd.DisplayRoomReservation(Login.userId,strDate);
  187.  
  188. for(int cnt = 0 ; cnt < RR_jsonobj.length ; cnt++){
  189. final String RR_Id = RR_jsonobj[cnt].get("RR_Id").toString();
  190. final String RR_CreateDate = RR_jsonobj[cnt].get("RR_CreateDate").toString();
  191. final String RR_userName = RR_jsonobj[cnt].get("UserName").toString();
  192. final String RR_Subject = RR_jsonobj[cnt].get("RR_Subject").toString();
  193. final String RR_recurrance = RR_jsonobj[cnt].get("RR_recurrance").toString();
  194. final String RR_Unit = RR_jsonobj[cnt].get("RR_Unit").toString();
  195. final String RR_Qty = RR_jsonobj[cnt].get("RR_Qty").toString();
  196. final String RR_FromDate = RR_jsonobj[cnt].get("RR_FromDate").toString();
  197. final String RR_ToDate = RR_jsonobj[cnt].get("RR_ToDate").toString();
  198. final String RR_Endless = RR_jsonobj[cnt].get("RR_Endless").toString();
  199. final String RR_FromTime = RR_jsonobj[cnt].get("RR_FromTime").toString();
  200. final String RR_ToTime = RR_jsonobj[cnt].get("RR_ToTime").toString();
  201. final String RR_Involvers = RR_jsonobj[cnt].get("RR_Involvers").toString();
  202. final String RR_DetailComment = RR_jsonobj[cnt].get("RR_DetailComment").toString();
  203.  
  204. tvRoomReservation[i] = new TextView(Calender.this);
  205.  
  206. if(cnt % 2 == 0 || cnt == 0 ){
  207. tvRoomReservation[i].setBackgroundColor(Color.parseColor("#bdc3bd"));
  208. }
  209.  
  210. tvRoomReservation[i].setText("RR:-" +RR_FromTime +"#"+RR_userName +"#");
  211. tvRoomReservation[i].setTag(RR_Id);
  212. tvRoomReservation[i].setTextColor(Color.parseColor("#000000"));
  213. tvRoomReservation[i].setWidth(150);
  214. tvRoomReservation[i].setTextSize(11);
  215. tvRoomReservation[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  216. layoutLinear[i].addView(tvRoomReservation[i]);
  217.  
  218. tvRoomReservation[i].setOnClickListener(new OnClickListener() {
  219. public void onClick(View v) {
  220.  
  221. Intent intent = new Intent(Calender.this,DisplayRoomReservation.class);
  222. intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  223. intent.putExtra("UserName", RR_userName);
  224. intent.putExtra("Create Date", RR_CreateDate);
  225. intent.putExtra("Subject", RR_Subject);
  226. intent.putExtra("Recurrance", RR_recurrance);
  227. intent.putExtra("Unit", RR_Unit);
  228. intent.putExtra("Qty", RR_Qty);
  229. intent.putExtra("Start Date", RR_FromDate);
  230. intent.putExtra("To Date", RR_ToDate);
  231. intent.putExtra("Endless", RR_Endless);
  232. intent.putExtra("From Time", RR_FromTime);
  233. intent.putExtra("To Time", RR_ToTime);
  234. intent.putExtra("Involvers", RR_Involvers);
  235. intent.putExtra("Comment", RR_DetailComment);
  236. startActivity(intent);
  237. }
  238. });
  239. }
  240. }
  241.  
  242. //Periodic Notes
  243. if(Getdata.connflag == true){
  244. final JSONObject[] arrJSONPeriodicNote = gd.DayInformation(Login.userId,strDate);
  245. String pnDetail = "";
  246. for(int j = 0 ; j < arrJSONPeriodicNote.length ; j++){
  247. pnDetail = arrJSONPeriodicNote[j].get("Name").toString();
  248.  
  249. String[] splitPN = pnDetail.split("~");
  250. final String PN_CreateDate = splitPN[0];
  251. final String PN_Sender = splitPN[1];
  252. final String PN_Subject = splitPN[2];
  253. final String PN_Involved = splitPN[3];
  254. String PN_Id = splitPN[4];
  255.  
  256. /*if(j % 2 == 0 || j == 0){
  257. tvPeriodicalNote[i].setBackgroundColor(Color.parseColor("#bdc3bd"));
  258. }*/
  259.  
  260. tvPeriodicalNote[i] = new TextView(Calender.this);
  261. tvPeriodicalNote[i].setText(PN_Subject);
  262. tvPeriodicalNote[i].setTag(PN_Id);
  263. tvPeriodicalNote[i].setTextColor(Color.parseColor("#0744f4"));
  264. tvPeriodicalNote[i].setWidth(150);
  265. tvPeriodicalNote[i].setTextSize(11);
  266. tvPeriodicalNote[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
  267.  
  268. layoutLinear[i].addView(tvPeriodicalNote[i]);
  269.  
  270. tvPeriodicalNote[i].setOnClickListener(new OnClickListener() {
  271. public void onClick(View v) {
  272. v.getTag();
  273. PeriodicNoteDisplay(PN_CreateDate, PN_Sender,PN_Subject,PN_Involved);
  274. }
  275. });
  276. }
  277. }
  278.  
  279. /******************************************************************************************************************************************************/
  280. //}
  281. }
  282. }
  283. catch (Exception e) {
  284. System.out.println("Error online Calendar:" + e);
  285. }
  286. }
Advertisement
Add Comment
Please, Sign In to add comment