Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
90 Kevin 1
package ioio.debugger;
2
 
3
import android.graphics.Color;
4
import android.os.Handler;
5
import android.view.View;
6
import android.widget.TextView;
7
 
8
public class ViewWidgetSimpleText implements ViewWidget {
9
 
10
	private View view;
11
	private Runnable run;
12
	private Thread thread;
13
	private Handler handler = new Handler();
14
	private int pin;
15
 
16
	public ViewWidgetSimpleText() {
17
 
18
	}
19
 
20
	@Override
21
	public void stopThread() {
22
		thread.interrupt();
23
	}
24
 
25
	@Override
26
	public void startThread() {
27
		// Kill the thread if it is already running
28
		if (thread != null && thread.isAlive())
29
			thread.interrupt();
30
		// Start a new thread and run the passed Runnable
31
		thread = new Thread (run);
32
		thread.start();
33
	}
34
 
35
	@Override
36
	public View getView() {
37
		return view;
38
	}
39
 
40
	@Override
41
	public Thread getThread() {
42
		return thread;
43
	}
44
 
45
	@Override
46
	public void clearData() {
47
 
48
	}
49
 
50
	@Override
51
	public void setStopSignal() {
52
		handler.post(new Runnable() {
53
 
54
			@Override
55
			public void run() {
56
				TextView tv = (TextView)view.findViewById(R.id.layout_simpleText_status);
57
				tv.setTextColor(Color.RED);
58
			}
59
		});
60
	}
61
 
62
	@Override
63
	public void resetStopSignal() {
64
		handler.post(new Runnable() {
65
 
66
			@Override
67
			public void run() {
68
				TextView tv = (TextView)view.findViewById(R.id.layout_simpleText_status);
69
				tv.setTextColor(Color.WHITE);
70
			}
71
		});
72
	}
73
 
74
	@Override
75
	public void sendDataHistory() {
76
 
77
	}
78
 
79
	@Override
80
	public int getPin() {
81
		return pin;
82
	}
83
 
84
	public void setPin(int pin) {
85
		this.pin = pin;
86
	}
87
 
88
	public void updateText(final String str) {
89
		handler.post(new Runnable() {
90
 
91
			@Override
92
			public void run() {
93
				TextView tv = (TextView)view.findViewById(R.id.layout_simpleText_text);
94
				tv.setText(str);
95
			}
96
		});
97
	}
98
 
99
	public void updateStatus(final String str) {
100
		handler.post(new Runnable() {
101
 
102
			@Override
103
			public void run() {
104
				TextView tv = (TextView)view.findViewById(R.id.layout_simpleText_status);
105
				tv.setText(str);
106
			}
107
		});
108
	}
109
 
110
	public void setView(View view) {
111
		this.view = view;
112
	}
113
 
114
	public void setRunnable(Runnable r) {
115
		this.run = r;
116
	}
117
}