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

import cgeo.geocaching.activity.AbstractActivity;
import cgeo.geocaching.files.GPXImporter;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;

public class GPXImportActivity extends AbstractActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if ("content".equals(getIntent().getScheme())) {
            importGPXFromIntent();
        }
    }

    private void importGPXFromIntent() {
        new AlertDialog.Builder(this)
                .setTitle(res.getString(R.string.gpx_import_title))
                .setMessage(res.getString(R.string.gpx_import_confirm))
                .setCancelable(false)
                .setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        (new GPXImporter(GPXImportActivity.this, cgList.STANDARD_LIST_ID)).importGPX(getIntent().getData(), getContentResolver());
                    }
                })
                .setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                })
                .create()
                .show();
    }
}