aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/settings/AbstractClickablePreference.java
blob: 57fdf367877d1831fd94bdec84f8b0af354a70f0 (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
package cgeo.geocaching.settings;

import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

abstract class AbstractClickablePreference extends Preference {

    final SettingsActivity activity;

    public AbstractClickablePreference(final Context context, final AttributeSet attrs) {
        super(context, attrs);
        activity = (SettingsActivity) context;
    }

    public AbstractClickablePreference(final Context context, final AttributeSet attrs, final int defStyle) {
        super(context, attrs, defStyle);
        activity = (SettingsActivity) context;
    }

    @Override
    protected View onCreateView(final ViewGroup parent) {
        setOnPreferenceClickListener(getOnPreferenceClickListener(activity));
        return super.onCreateView(parent);
    }

    abstract protected OnPreferenceClickListener getOnPreferenceClickListener(final SettingsActivity activity);
}