Clover Coverage Report - AnCal Coverage Report
Coverage timestamp: gio dic 18 2014 12:18:42 EST
../../../../../img/srcFileCovDistChart9.png 40% of files have more coverage
103   301   40   4,68
36   236   0,39   11
22     1,82  
2    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  AgendaView       Line # 20 103 40 89,4% 0.89440995
  AgendaView.OnViewItemClick       Line # 23 0 0 - -1.0
 
No Tests
 
1    package pl.magot.vetch.ancal.agenda;
2   
3   
4    import java.util.Calendar;
5    import pl.magot.vetch.ancal.AnCal;
6    import pl.magot.vetch.ancal.CommonActivity;
7    import pl.magot.vetch.ancal.R;
8    import pl.magot.vetch.ancal.dataview.DataView;
9    import pl.magot.vetch.ancal.views.ViewTodayItemAppointment;
10    import pl.magot.vetch.ancal.views.ViewTodayItemTask;
11    import pl.magot.vetch.ancal.views.ViewTodayItemNote;
12    import pl.magot.vetch.ancal.views.ViewTodayItem;
13    import pl.magot.vetch.ancal.views.ViewTodayItemHeader;
14    import android.os.*;
15    import android.view.*;
16    import android.view.ViewGroup.LayoutParams;
17    import android.widget.LinearLayout;
18   
19   
 
20    public abstract class AgendaView
21    {
22    //types
 
23    public interface OnViewItemClick
24    {
25    public void OnClick(View v, Bundle extras);
26    }
27   
28    //appointment click listener
29    public ViewTodayItemAppointment.OnItemClick onApptItemClick = new ViewTodayItemAppointment.OnItemClick()
30    {
 
31  2 toggle public void OnClick(ViewTodayItem item) {
32  2 doSubItemClick(item, ViewTodayItemHeader.ViewType.Appointments, item.GetRowId());
33    }
34    };
35   
36    //task click listener
37    public ViewTodayItemTask.OnItemClick onTaskItemClick = new ViewTodayItemTask.OnItemClick()
38    {
 
39  3 toggle public void OnClick(ViewTodayItem item) {
40  3 doSubItemClick(item, ViewTodayItemHeader.ViewType.Tasks, item.GetRowId());
41    }
42    };
43   
44    //note click listener
45    public ViewTodayItemNote.OnItemClick onNoteItemClick = new ViewTodayItemNote.OnItemClick()
46    {
 
47  2 toggle public void OnClick(ViewTodayItem item) {
48  2 doSubItemClick(item, ViewTodayItemHeader.ViewType.Notes, item.GetRowId());
49    }
50    };
51   
52   
53    //fields
54    protected AnCal main = null;
55    protected LinearLayout llayParent = null;
56    protected LinearLayout.LayoutParams lpParent = null;
57    protected LinearLayout.LayoutParams lparams = null;
58   
59    //fields
60    protected LinearLayout llayParentAppt = null;
61    protected LinearLayout llayParentTask = null;
62    protected LinearLayout llayParentNote = null;
63   
64    //fields
65    protected static OnViewItemClick itemAgendaViewClick = null;
66   
67    //fields
68    protected String sTextNone = "";
69    private boolean bLastTimeFormat = false;
70   
71    //fields
72    private Calendar calDateToday = Calendar.getInstance();
73    private Calendar calViewStartDate = Calendar.getInstance();
74    protected Calendar calCurrMonth = Calendar.getInstance();
75   
76    //fields
77    private int iMonthViewCurrentMonth = -1;
78    private int iMonthViewCurrentYear = -1;
79   
80    //methods
 
81  4 toggle AgendaView(AnCal main)
82    {
83  4 this.main = main;
84   
85    //layout params
86  4 lpParent = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
87  4 lparams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
88   
89    //create parent layout
90  4 llayParent = new LinearLayout(main);
91  4 llayParent.setPadding(0, 0, 0, 0);
92  4 llayParent.setOrientation(LinearLayout.VERTICAL);
93  4 llayParent.setLayoutParams(lpParent);
94   
95    //create parent appointment layout
96  4 llayParentAppt = new LinearLayout(main);
97  4 llayParentAppt.setPadding(0, 0, 0, 2);
98  4 llayParentAppt.setOrientation(LinearLayout.VERTICAL);
99  4 llayParentAppt.setLayoutParams(lparams);
100    //create parent task layout
101  4 llayParentTask = new LinearLayout(main);
102  4 llayParentTask.setPadding(0, 0, 0, 2);
103  4 llayParentTask.setOrientation(LinearLayout.VERTICAL);
104  4 llayParentTask.setLayoutParams(lparams);
105    //create parent note layout
106  4 llayParentNote = new LinearLayout(main);
107  4 llayParentNote.setPadding(0, 0, 0, 2);
108  4 llayParentNote.setOrientation(LinearLayout.VERTICAL);
109  4 llayParentNote.setLayoutParams(lparams);
110   
111    //init strings
112  4 sTextNone = main.utils.GetResStr(R.string.labTodayItemNone);
113   
114  4 bLastTimeFormat = main.prefs.b24HourMode;
115    }
116   
 
117  1 toggle public static void SetItemClick(OnViewItemClick itemClick)
118    {
119  1 itemAgendaViewClick = itemClick;
120    }
121   
 
122  20 toggle public LinearLayout GetParentLayout()
123    {
124  20 return llayParent;
125    }
126   
127    public abstract void Rebuild();
128    public abstract AgendaViewType GetViewType();
129    public abstract int GetViewIndex();
130   
 
131  9 toggle public void doHeaderItemClick(View v, ViewTodayItemHeader.ViewType type)
132    {
133  9 if (itemAgendaViewClick != null)
134    {
135  9 Bundle extras = new Bundle();
136  9 extras.putString("type", type.toString());
137  9 extras.putLong(CommonActivity.bundleRowId, -1L);
138  9 itemAgendaViewClick.OnClick(v, extras);
139    }
140    }
141   
 
142  7 toggle public void doSubItemClick(View v, ViewTodayItemHeader.ViewType type, long lRowId)
143    {
144  7 if (itemAgendaViewClick != null)
145    {
146  7 Bundle extras = new Bundle();
147  7 extras.putString("type", type.toString());
148  7 extras.putLong(CommonActivity.bundleRowId, lRowId);
149  7 itemAgendaViewClick.OnClick(v, extras);
150    }
151    }
152   
 
153  0 toggle public void doHourOfDayClick(View v, ViewTodayItemHeader.ViewType type, int iHourOfDay, int iMinutes)
154    {
155  0 if (itemAgendaViewClick != null)
156    {
157  0 Bundle extras = new Bundle();
158  0 extras.putString("type", type.toString());
159  0 extras.putLong(CommonActivity.bundleRowId, -1L);
160  0 extras.putInt(CommonActivity.bundleHourOfDay, iHourOfDay);
161  0 extras.putInt(CommonActivity.bundleMinutes, iMinutes);
162  0 itemAgendaViewClick.OnClick(v, extras);
163    }
164    }
165   
166    public abstract void RebuildViewAppointments(DataView dataView);
167    public abstract void RebuildViewTasks(DataView dataView);
168    public abstract void RebuildViewNotes(DataView dataView);
169   
170    public abstract void UpdateTimeFormat();
171   
 
172  44 toggle public void SetViewStartDate(Calendar date)
173    {
174  44 if (date == null)
175    {
176  19 calViewStartDate.setTimeInMillis(System.currentTimeMillis());
177    } else {
178  25 calViewStartDate.setTimeInMillis(date.getTimeInMillis());
179    }
180   
181  44 calViewStartDate.setFirstDayOfWeek(main.prefs.iFirstDayOfWeek);
182   
183  44 if (GetViewType() == AgendaViewType.WEEK)
184  18 UpdateStartDateForWeek();
185  44 if (GetViewType() == AgendaViewType.MONTH)
186  9 UpdateStartDateForMonth();
187    }
188   
 
189  39 toggle private void UpdateStartDateForWeek()
190    {
191  39 int iDay = calViewStartDate.get(Calendar.DAY_OF_WEEK) - main.prefs.iFirstDayOfWeek;
192  39 calViewStartDate.add(Calendar.DAY_OF_WEEK, -iDay);
193    }
194   
 
195  21 toggle private void UpdateStartDateForMonth()
196    {
197  21 iMonthViewCurrentMonth = calViewStartDate.get(Calendar.MONTH);
198  21 iMonthViewCurrentYear = calViewStartDate.get(Calendar.YEAR);
199  21 calViewStartDate.set(Calendar.DAY_OF_MONTH, 1);
200  21 UpdateStartDateForWeek();
201    }
202   
 
203  388 toggle public Calendar GetViewStartDate()
204    {
205  388 return calViewStartDate;
206    }
207   
 
208  19 toggle public void SetPrevViewItem()
209    {
210  19 if (GetViewType() == AgendaViewType.DAY)
211  6 calViewStartDate.add(Calendar.DAY_OF_YEAR, -1);
212  19 if (GetViewType() == AgendaViewType.WEEK)
213  6 calViewStartDate.add(Calendar.WEEK_OF_YEAR, -1);
214   
215  19 if (GetViewType() == AgendaViewType.MONTH)
216    {
217  7 iMonthViewCurrentMonth--;
218  7 if (iMonthViewCurrentMonth == -1)
219    {
220  1 iMonthViewCurrentMonth = 11;
221  1 iMonthViewCurrentYear--;
222    }
223  7 calViewStartDate.set(Calendar.DAY_OF_MONTH, 1);
224  7 calViewStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth);
225  7 calViewStartDate.set(Calendar.YEAR, iMonthViewCurrentYear);
226   
227  7 UpdateStartDateForMonth();
228    }
229    }
230   
 
231  19 toggle public void SetTodayViewItem()
232    {
233  19 SetViewStartDate(null);
234    }
235   
 
236  21 toggle public void SetNextViewItem()
237    {
238  21 if (GetViewType() == AgendaViewType.DAY)
239  4 calViewStartDate.add(Calendar.DAY_OF_YEAR, 1);
240  21 if (GetViewType() == AgendaViewType.WEEK)
241  12 calViewStartDate.add(Calendar.WEEK_OF_YEAR, 1);
242   
243  21 if (GetViewType() == AgendaViewType.MONTH)
244    {
245  5 iMonthViewCurrentMonth++;
246  5 if (iMonthViewCurrentMonth == 12)
247    {
248  1 iMonthViewCurrentMonth = 0;
249  1 iMonthViewCurrentYear++;
250    }
251  5 calViewStartDate.set(Calendar.DAY_OF_MONTH, 1);
252  5 calViewStartDate.set(Calendar.MONTH, iMonthViewCurrentMonth);
253  5 calViewStartDate.set(Calendar.YEAR, iMonthViewCurrentYear);
254   
255  5 UpdateStartDateForMonth();
256    }
257    }
258   
 
259  126 toggle public int GetCurrentSelectedMonth()
260    {
261  126 return iMonthViewCurrentMonth;
262    }
263   
 
264  0 toggle public int GetCurrentSelectedYear()
265    {
266  0 return iMonthViewCurrentYear;
267    }
268   
 
269  21 toggle public Calendar GetCurrentSelectedMonthAsCalendar()
270    {
271  21 calCurrMonth.set(Calendar.DAY_OF_MONTH, 1);
272  21 calCurrMonth.set(Calendar.MONTH, iMonthViewCurrentMonth);
273  21 calCurrMonth.set(Calendar.YEAR, iMonthViewCurrentYear);
274  21 return calCurrMonth;
275    }
276   
 
277  1 toggle public boolean TimeFormatChanged()
278    {
279  1 if (bLastTimeFormat == main.prefs.b24HourMode)
280  0 return false;
281  1 bLastTimeFormat = main.prefs.b24HourMode;
282  1 return true;
283    }
284   
 
285  61 toggle protected boolean IsViewToday()
286    {
287  61 calDateToday.setTimeInMillis(System.currentTimeMillis());
288  61 if (calDateToday.get(Calendar.YEAR) == calViewStartDate.get(Calendar.YEAR))
289  52 if (calDateToday.get(Calendar.MONTH) == calViewStartDate.get(Calendar.MONTH))
290  52 if (calDateToday.get(Calendar.DAY_OF_MONTH) == calViewStartDate.get(Calendar.DAY_OF_MONTH))
291  27 return true;
292  34 return false;
293    }
294   
 
295  61 toggle protected int getTodayCurrentHour()
296    {
297  61 calDateToday.setTimeInMillis(System.currentTimeMillis());
298  61 return calDateToday.get(Calendar.HOUR_OF_DAY);
299    }
300   
301    }