I am planning to block the time picker to a particular start time and end Time. For that i am setting TimeChangedListener and overriding onTimeChanged method. below is implementation on the onTimeChanged ().
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
// TODO Auto-generated method stub
//;super.onTimeChanged(view, hourOfDay, minute);
try{
boolean flag = true;
if (hourOfDay <= maxHour && hourOfDay >= minHour) {
if (hourOfDay == maxHour && hourOfDay == minHour) {
if (minute > maxMin)
flag = false;
else if (minute < minMin)
flag = false;
else if (minute == maxMin && minute == minMin) {
flag = false;
} else if (minute == maxMin) {
flag = false;
} else if (minute == minMin) {
flag = false;
}
} else if (hourOfDay == maxHour) {
if (minute > maxMin)
{
flag = false;
}
} else if (hourOfDay == minHour) {
if (minute < minMin)
flag = false;
}
if (flag) {
curHour = hourOfDay;
curMin = minute;
} else {
updateTime(curHour, curMin);
}
//(curYear, curMonth);
} else {
updateTime(curHour, curMin);
}
//view.updateDate(curYear, curMonth, curDay);
} catch (Exception e) {
Log.e("CustomTimePicker","error");
}
}
but with this code snippet when i reached to minimum time and and trying to decrease minutes time again it going to a continues loop from first
updateTime(curHour, curMin);
method call and getting stack overflow exception.bot working fine(like expected) for hours update.
So if some one look at the code snippet and find out the problem please let me know.
any help will be appreciated.
Thanks in Advance.
I thing it this the problem with the updateTime(curHour, curMin); or onTimeChanged(TimePicker view, int hourOfDay, int minute); method in android OS-v2.3.6 and below. because when i tested the same on a device with android OS-v3.1 and above its working fine. But in OS-v2.3.6 and below when i called updateTime(curHour, curMin); with some 10 mins, onTimeChanged is getting called with 9 mins only. So when i reached to minimum hours after that minimum minutes it going to continues loop.
So its a but with updateTime(curHour, curMin); or onTimeChanged(TimePicker view, int hourOfDay, int minute); method in android OS-v2.3.6 and below.