I am trying to create a label in a Titanium developed Android app that automatically updates the time remaining based on my inputs (from current date to 30 May 2014). I've used JavaScript to create the following countdown function:
var current = 'Today is the day!';
var montharray = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
function countdown(yr,m,d){
theyear = yr;
themonth = m;
theday = d;
var today = new Date();
var todayy = today.getYear();
var todaym = today.getMonth();
var todayd = today.getDate();
var todayh = today.getHours();
var todaymin = today.getMinutes();
var todaysec = today.getSeconds();
var todaystring = montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec;
futurestring = montharray[m-1]+" "+d+", "+yr;
dd = Date.parse(futurestring) - Date.parse(todaystring);
dday = Math.floor(dd/(60*60*1000*24)*1);
dhour = Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
dmin = Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
dsec = Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
if (dday==0 && dhour==0 && dmin==0 && dsec==1){
homeLabel6.text = current;
return;
} else {
homeLabel6.text = dday + 'd:'+ dhour + 'h:' + dmin + 'm:' + dsec + 's';
setTimeout('countdown(theyear,themonth,theday)',1000);
}
}
countdown(2014,05,30);
Unfortunately when I build the app on my phone I receive the following errors:
[ERROR] : TiApplication: (KrollRuntimeThread) [821,821] Sending event: exception on thread: KrollRuntimeThread msg:java.lang.IncompatibleClassChangeError: interface not implemented; Titanium 3.2.2,2014/03/05 12:22,96e9a07
[ERROR] : TiApplication: java.lang.IncompatibleClassChangeError: interface not implemented
[ERROR] : TiApplication: at ti.modules.titanium.TitaniumModule$Timer.run(TitaniumModule.java:152)
[ERROR] : TiApplication: at android.os.Handler.handleCallback(Handler.java:615)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:92)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:112)
It could be great if someone could explain it to me where are the incompatibilities in order to make this work. I just want one label displaying this with no start/stop buttons ot something similar. Like it is mentioned above in the code snippet the label where I want the information is called: homeLabel6
. I've tried aswell other options but none of them seems to suits my needs.