aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/cgSearchThread.java
blob: 732275cc6d7d85b4e95814dd35fcd126618e2aa8 (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
package cgeo.geocaching;

import android.os.Handler;
import android.util.Log;

public class cgSearchThread extends Thread {
    private Handler recaptchaHandler = null;
    private String recaptchaChallenge = null;
    private String recaptchaText = null;

    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(cgSettings.tag, "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;
    }
}