aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/OwnerActionsClickListener.java
blob: 9aa6becba56830339e87e89faf0c43ba2c3283a9 (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
package cgeo.geocaching.ui;

import cgeo.geocaching.Geocache;
import cgeo.geocaching.connector.ConnectorFactory;

import org.apache.commons.lang3.StringUtils;

import android.view.View;
import android.widget.TextView;

/**
 * Listener for clicks on owner name
 */
public class OwnerActionsClickListener extends AbstractUserClickListener {

    private final Geocache cache;

    public OwnerActionsClickListener(final Geocache cache) {
        super(ConnectorFactory.getConnector(cache).getUserActions());
        this.cache = cache;
    }

    @Override
    protected String getUserName(final View view) {
        // Use real owner name vice the one owner chose to display
        if (StringUtils.isNotBlank(cache.getOwnerUserId())) {
            return cache.getOwnerUserId();
        }
        return ((TextView) view).getText().toString();
    }
}