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

import cgeo.geocaching.files.FileList;
import cgeo.geocaching.files.LocalStorage;
import cgeo.geocaching.ui.MapfileListAdapter;

import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;

import java.io.File;
import java.util.List;

public class cgSelectMapfile extends FileList<MapfileListAdapter> {

    public cgSelectMapfile() {
        super("map");
    }

    String mapFile;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mapFile = Settings.getMapFile();
    }

    public void close() {

        Intent intent = new Intent();
        intent.putExtra("mapfile", mapFile);

        setResult(RESULT_OK, intent);

        finish();
    }

    @Override
    protected MapfileListAdapter getAdapter(List<File> files) {
        return new MapfileListAdapter(this, files);
    }

    @Override
    protected File[] getBaseFolders() {
        final File base = Environment.getExternalStorageDirectory();
        return new File[] {
                new File(base, "mfmaps"),
                new File(new File(base, "Locus"), "mapsVector"),
                new File(base, LocalStorage.cache)
        };
    }

    @Override
    protected void setTitle() {
        setTitle(res.getString(R.string.map_file_select_title));
    }

    public String getCurrentMapfile() {
        return mapFile;
    }

    public void setMapfile(String newMapfile) {
        mapFile = newMapfile;
    }

}