1 |
/**
|
2 |
* ZANavi, Zoff Android Navigation system.
|
3 |
* Copyright (C) 2011 Zoff <zoff@zoff.cc>
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* version 2 as published by the Free Software Foundation.
|
8 |
*
|
9 |
* This program is distributed in the hope that it will be useful,
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
* GNU General Public License for more details.
|
13 |
*
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the
|
16 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
17 |
* Boston, MA 02110-1301, USA.
|
18 |
*/
|
19 |
|
20 |
/**
|
21 |
* Navit, a modular navigation system.
|
22 |
* Copyright (C) 2005-2008 Navit Team
|
23 |
*
|
24 |
* This program is free software; you can redistribute it and/or
|
25 |
* modify it under the terms of the GNU General Public License
|
26 |
* version 2 as published by the Free Software Foundation.
|
27 |
*
|
28 |
* This program is distributed in the hope that it will be useful,
|
29 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
30 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
31 |
* GNU General Public License for more details.
|
32 |
*
|
33 |
* You should have received a copy of the GNU General Public License
|
34 |
* along with this program; if not, write to the
|
35 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
36 |
* Boston, MA 02110-1301, USA.
|
37 |
*/
|
38 |
|
39 |
package com.zoffcc.applications.zanavi;
|
40 |
|
41 |
import android.os.Handler;
|
42 |
import android.os.Message;
|
43 |
import android.util.Log;
|
44 |
|
45 |
public class NavitTimeout implements Runnable
|
46 |
{
|
47 |
private static Handler handler = new Handler()
|
48 |
{
|
49 |
public void handleMessage(Message m)
|
50 |
{
|
51 |
//Log.e("Navit", "Handler received message");
|
52 |
}
|
53 |
};
|
54 |
private boolean event_multi;
|
55 |
private int event_callbackid;
|
56 |
private int event_timeout;
|
57 |
|
58 |
public native void TimeoutCallback(int del, int id);
|
59 |
|
60 |
NavitTimeout(int timeout, boolean multi, int callbackid)
|
61 |
{
|
62 |
//Log.e("Navit","Create New Event - to=" + timeout + " mulit=" + multi + " cid=" + callbackid);
|
63 |
event_timeout = timeout;
|
64 |
event_multi = multi;
|
65 |
event_callbackid = callbackid;
|
66 |
handler.postDelayed(this, event_timeout);
|
67 |
}
|
68 |
|
69 |
public void run()
|
70 |
{
|
71 |
//Log.e("Navit","Handle Event - to=" + event_timeout + " mulit=" + event_multi + " cid=" + event_callbackid);
|
72 |
if (event_multi)
|
73 |
{
|
74 |
handler.postDelayed(this, event_timeout);
|
75 |
TimeoutCallback(0, event_callbackid);
|
76 |
}
|
77 |
else
|
78 |
{
|
79 |
TimeoutCallback(1, event_callbackid);
|
80 |
}
|
81 |
}
|
82 |
|
83 |
public void remove()
|
84 |
{
|
85 |
//Log.e("Navit","remove Event - to=" + event_timeout + " mulit=" + event_multi + " cid=" + event_callbackid);
|
86 |
handler.removeCallbacks(this);
|
87 |
}
|
88 |
}
|