aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/activity/AbstractActivity.java
blob: 5792fbeb4d76a2fa99bdfe6df725dfe375f86a30 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package cgeo.geocaching.activity;

import cgeo.geocaching.Settings;
import cgeo.geocaching.cgBase;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgeoapplication;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;

public abstract class AbstractActivity extends Activity implements IAbstractActivity {

    private String helpTopic;

    protected cgeoapplication app = null;
    protected Resources res = null;
    protected cgBase base = null;
    protected SharedPreferences prefs = null;

    protected AbstractActivity() {
        this(null);
    }

    protected AbstractActivity(final String helpTopic) {
        this.helpTopic = helpTopic;
    }

    final public void goHome(final View view) {
        ActivityMixin.goHome(this);
    }

    public void goManual(final View view) {
        ActivityMixin.goManual(this, helpTopic);
    }

    final public void setTitle(final String title) {
        ActivityMixin.setTitle(this, title);
    }

    final public void showProgress(final boolean show) {
        ActivityMixin.showProgress(this, show);
    }

    final public void setTheme() {
        ActivityMixin.setTheme(this);
    }

    public final void showToast(String text) {
        ActivityMixin.showToast(this, text);
    }

    public final void showShortToast(String text) {
        ActivityMixin.showShortToast(this, text);
    }

    public final void helpDialog(final String title, final String message) {
        ActivityMixin.helpDialog(this, title, message, null);
    }

    public final void helpDialog(final String title, final String message, final Drawable icon) {
        ActivityMixin.helpDialog(this, title, message, icon);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // init
        res = this.getResources();
        app = (cgeoapplication) this.getApplication();
        prefs = getSharedPreferences(Settings.preferences, Context.MODE_PRIVATE);
        base = cgBase.getInstance(app);

        // Restore cookie store if needed
        cgBase.restoreCookieStore(Settings.getCookieStore());
    }

    public void addVisitMenu(Menu menu, cgCache cache) {
        ActivityMixin.addVisitMenu(this, menu, cache);
    }

}