blob: 33c8a928adeeba3448b2c3fbd40a0bcf945fc132 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
package cgeo.geocaching.connector.gc;
import cgeo.geocaching.utils.Log;
import android.os.Handler;
import android.os.Message;
abstract public class AbstractSearchThread extends Thread {
private Handler recaptchaHandler = null;
private String recaptchaChallenge = null;
private String recaptchaText = null;
private final Handler handler;
private static AbstractSearchThread currentInstance;
public AbstractSearchThread(final Handler handler) {
this.handler = handler;
}
public void setRecaptchaHandler(Handler recaptchaHandlerIn) {
recaptchaHandler = recaptchaHandlerIn;
}
public void notifyNeed() {
if (recaptchaHandler != null) {
recaptchaHandler.sendEmptyMessage(1);
}
}
public synchronized void waitForUser() {
try {
wait();
} catch (InterruptedException e) {
Log.w("searchThread is not waiting for user...");
}
}
public void setChallenge(String challenge) {
recaptchaChallenge = challenge;
}
public String getChallenge() {
return recaptchaChallenge;
}
public synchronized void setText(String text) {
recaptchaText = text;
notify();
}
public synchronized String getText() {
return recaptchaText;
}
@Override
final public void run() {
super.run();
currentInstance = this;
runSearch();
handler.sendMessage(Message.obtain());
}
protected abstract void runSearch();
public static AbstractSearchThread getCurrentInstance() {
return currentInstance;
}
}
|