View difference between Paste ID: RnH9Drvd and ce96rWKu
SHOW: | | - or go back to the newest paste.
1
adapter class
2
3
4
  public View getView(int position, View convertView, ViewGroup parent) {
5
        View v = convertView;
6
        TextView dayView;
7
8
        if (convertView == null) { // if it's not recycled, initialize some
9
            // attributes
10
            LayoutInflater vi = (LayoutInflater) mContext
11
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
12
           v = vi.inflate(R.layout.calendar_item, null);
13
14
        }
15
        dayView = (TextView) v.findViewById(R.id.date);
16
        // separates daystring into parts.
17
        String[] separatedTime = dayString.get(position).split("-");
18
        // taking last part of date. ie; 2 from 2012-12-02
19
        String gridvalue = separatedTime[2].replaceFirst("^0*", "");
20
        // checking whether the day is in current month or not.
21
        if ((Integer.parseInt(gridvalue) > 1) && (position < firstDay)) {
22
            // setting offdays to white color.
23
            dayView.setTextColor(Color.WHITE);
24
            dayView.setClickable(false);
25
            dayView.setFocusable(false);
26
        } else if ((Integer.parseInt(gridvalue) < 7) && (position > 28)) {
27
            dayView.setTextColor(Color.WHITE);
28
            dayView.setClickable(false);
29
            dayView.setFocusable(false);
30
        } else {
31
            // setting curent month's days in black color.
32
            dayView.setTextColor(Color.BLACK);
33
        }
34
35
        if (dayString.get(position).equals(curentDateString)) {
36
            setSelected(v);
37
            previousView = v;
38
        } else {
39
            v.setBackgroundResource(R.drawable.list_item_background);
40
            //  v.setBackgroundResource(Integer.parseInt("#64DD17"));
41
        }
42
        dayView.setText(gridvalue);
43
44
        // create date string for comparison
45
        String date = dayString.get(position);
46
47
        if (date.length() == 1) {
48
            date = "0" + date;
49
        }
50
        String monthStr = "" + (month.get(GregorianCalendar.MONTH) + 1);
51
        if (monthStr.length() == 1) {
52
            monthStr = "0" + monthStr;
53
        }
54
        if((position==0 || position==7 || position==14 || position==21 || position==28 || position==35)) {
55
            dayView.setTextColor(Color.RED);
56
        }
57
58
        // show icon if date is not empty and it exists in the items array
59
        ImageView iw = (ImageView) v.findViewById(R.id.date_icon);
60
        //iw.setBackgroundResource(R.drawable.calendar_cel_select3);
61
        iw.setImageResource(R.drawable.calendar_cel_select3);
62
        //textView2= (TextView) v.findViewById(R.id.evntnm);
63
        textView= (TextView) v.findViewById(R.id.date);
64
       // ViewGroup viewGroup=(ViewGroup) v.getParent();
65
66
        if (date.length() > 0 && items != null && items.contains(date)) {
67
            iw.setVisibility(View.VISIBLE);
68
69
           // viewGroup.removeView(iw);
70
            v.setBackgroundColor(Color.parseColor("#00695C"));
71
            //textView2.setVisibility(View.VISIBLE);
72
            //textView.setBackgroundResource(R.drawable.calendar_cel_select3);
73
            //textView.setBackgroundResource(R.drawable.calendar_cel_select3);
74
//				textView.setBackgroundColor(Color.parseColor("#rrggbb"));
75
            textView.setVisibility(View.VISIBLE);
76
            textView.setDrawingCacheBackgroundColor(Color.parseColor("#1DE9B6"));
77
        } else {
78
           // viewGroup.addView(iw);
79
            iw.setVisibility(View.INVISIBLE);
80
            //textView2.setVisibility(View.INVISIBLE);
81
            textView.setVisibility(View.VISIBLE);
82
        }
83
        return v;
84
    }
85
86
    public View setSelected(View view) {
87
        if (previousView != null) {
88
            previousView.setBackgroundResource(R.drawable.list_item_background);
89
            //view.setBackgroundColor(Integer.parseInt("#64DD17"));
90
            //view.setBackgroundResource(R.drawable.calendar_cel_select3);
91
        }
92
        previousView = view;
93
        view.setBackgroundResource(R.color.colorPrimary);
94
        return view;
95-
    }
95+
96
mainactivity adding to arraylist
97
  public Runnable calendarUpdater = new Runnable() {
98
            DataDisplayActivity dataDisplayActivity=new DataDisplayActivity();
99
100
            @Override
101
            public void run() {
102
                items.clear();
103
104
                // Print dates of the current week
105
                DateFormat df = new SimpleDateFormat("yyyy-MM-dd",Locale.US);
106
                String itemvalue;
107
                for (int i = 0; i < 7; i++) {
108
                    itemvalue = df.format(itemmonth.getTime());
109
                    itemmonth.add(GregorianCalendar.DATE, 1);
110
                 items.add("2016-05-03");
111
112
 adapter.setItems(items);
113
                adapter.notifyDataSetChanged();
114
}
115
116
retriving data
117
118
  try {
119
                    JSONArray jsonArray = new JSONArray(data);
120
                    for(int i=0;i<jsonArray.length();i++) {
121
                        JSONObject jsonObject = jsonArray.getJSONObject(i);
122
                        date = jsonObject.getString("startdt");
123
                        String toTime = jsonObject.getString("enddt");
124
                   /* String fromTime = jsonObject.getString("");
125
                    String seats = jsonObject.getString("");
126
                    String venue = jsonObject.getString("");
127
                    String address = jsonObject.getString("");*/
128
                        data += "Node"+i+" : \n id= "+ date +" \n Name= "+ toTime +"" ;
129
130
                        textView1.setText(date);
131
                        textView2.setText(toTime);
132
                    }
133
                    if(data!=null && data.equals(CalendarAdapter.getMaxP())) {
134
                       {
135
                         CalendarAdapter.dayString.add(date);
136
137
                        }