Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //My Main Class - It's a Calendar
- final TextView tvDate[] = new TextView[7];
- final TextView tvIssue[] = new TextView[7];
- Class Calender extends Activity{
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.calender);
- tvDate[0] = (TextView) findViewById(R.id.tvFirstDate);
- tvDate[1] = (TextView) findViewById(R.id.tvSecondDate);
- tvDate[2] = (TextView) findViewById(R.id.tvThirdDate);
- tvDate[3] = (TextView) findViewById(R.id.tvFourthDate);
- tvDate[4] = (TextView) findViewById(R.id.tvFifthDate);
- tvDate[5] = (TextView) findViewById(R.id.tvSixthDate);
- tvDate[6] = (TextView) findViewById(R.id.tvSeventhDate);
- for (int i = 0; i < 7; i++) {
- tvIssue[i] = new TextView(Calender.this);
- }
- layoutLinear[0] = (LinearLayout) findViewById(R.id.Llfirstday);
- layoutLinear[1] = (LinearLayout) findViewById(R.id.LlSecondDay);
- layoutLinear[2] = (LinearLayout) findViewById(R.id.LlThirdDay);
- layoutLinear[3] = (LinearLayout) findViewById(R.id.LlFourthDay);
- layoutLinear[4] = (LinearLayout) findViewById(R.id.LlFifthDay);
- layoutLinear[5] = (LinearLayout) findViewById(R.id.LlSixthDay);
- layoutLinear[6] = (LinearLayout) findViewById(R.id.LlSeventhDay);
- calendar = Calendar.getInstance();
- calendar.clear();
- calendar.set(Calendar.YEAR, year);
- calendar.set(Calendar.WEEK_OF_YEAR, week);
- date = calendar.getTime();
- String dt;
- dt = sdf.format(date);
- calendar.add(Calendar.DATE, 1);
- calendar.set(Calendar.YEAR, year);
- calendar.set(Calendar.WEEK_OF_YEAR, week);
- try {
- calendar.setTime(sdf.parse(dt));
- } catch (ParseException e2) {
- e2.printStackTrace();
- }
- calendar.add(Calendar.DATE, -1);
- new AsyncIssue().execute();
- }
- class AsyncIssue extends AsyncTask<Void, Void, Void>{
- @Override
- protected Void doInBackground(Void... params) {
- for(int i = 0; i < 7; i++) {
- SimpleDateFormat sdf = new SimpleDateFormat("M-dd-yyyy");
- strDate = "";
- calendar.add(Calendar.DATE, 1);
- strDate = sdf.format(calendar.getTime());
- System.out.println("Date in AsyncIssue is :"+strDate);
- tvDate[i].setText(strDate);
- try{
- String LDID = "";
- JSONObject[] arrJSONCalData = null;
- arrJSONCalData = gd.FillCalendarData(Login.userId, strDate, Login.userName);
- for(int k = 0 ; k < arrJSONCalData.length;k++){
- String leaveTitle = arrJSONCalData[k].get("leaveTitle").toString();
- LDID = arrJSONCalData[k].get("LDID").toString();
- final String calDisplay = arrJSONCalData[k].get("detail").toString();
- final String headerinIssue = arrJSONCalData[k].get("Header").toString();
- final String deleteReason = arrJSONCalData[k].get("Delete_reason").toString();
- System.out.println(i + " :=> LeaveTitle : " + leaveTitle);
- System.out.println(i + " :=> Detail : " + arrJSONCalData[k].get("detail").toString());
- System.out.println(i + " :=> Header : " + arrJSONCalData[k].get("Header").toString());
- System.out.println(i + " :=> Delete_Reason : " + arrJSONCalData[k].get("Delete_reason").toString());
- System.out.println(i + " :=> LDID : " + arrJSONCalData[k].get("LDID").toString());
- tvIssue[i] = new TextView(Calender.this);
- tvIssue[i].setText("> " + leaveTitle);
- tvIssue[i].setTag(LDID);
- tvIssue[i].setTextColor(Color.parseColor("#000000"));
- if(k % 2 == 0 || k == 0){
- tvIssue[i].setBackgroundColor(Color.parseColor("#bdc3bd"));
- }
- tvIssue[i].setWidth(150);
- tvIssue[i].setTextSize(11);
- tvIssue[i].setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
- tvIssue[i].offsetTopAndBottom(5);
- layoutLinear[i].addView(tvIssue[i]);
- tvIssue[i].setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- try {
- System.out.println("Reason in CLick :"+deleteReason);
- System.out.println("LDID in CLick :"+ v.getTag().toString());
- System.out.println("calDisplay in CLick :" + calDisplay);
- System.out.println("headerinIssue in CLick :"+ headerinIssue);
- Intent intent = new Intent(Calender.this,AddDisplayIssue.class);
- intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- intent.putExtra("Detail",calDisplay);
- intent.putExtra("LDID", v.getTag().toString());
- intent.putExtra("Header", headerinIssue);
- intent.putExtra("Delete Reason",deleteReason);
- intent.putExtra("Flag", "DisplayIssueDetail");
- startActivity(intent);
- }
- catch (Exception e) {
- System.out.println("Error on click of Issue :"+e);
- }
- }
- });
- }
- }
- catch (Exception e) {
- System.out.println("Error in AsyncIssue :"+e);
- }
- }
- return null;
- }
- @Override
- protected void onPostExecute(Void result) {
- // new AsyncIssue().execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement