src/main/java/de/blau/android/dialogs/Layers.java
/**
     * Show a list of available tracks (starting point in the current view), then download on selection
     * 
     * @param activity the calling activity
     * @param prefs the current Preferences
     * @param map the current map object
     */
Show a list of available tracks (starting point in the current view), then download on selection

@param activity the calling activity
@param prefs the current Preferences
@param map the current map object
Show a list of available tracks ( starting point in the current view ) then download on selection @param activity the calling activity @param prefs the current Preferences @param map the current map object
private void downloadGpxTrack(@NonNull final FragmentActivity activity, @NonNull final Preferences prefs, @NonNull final Map map) {
        final Logic logic = App.getLogic();
        final Server server = prefs.getServer();
        ExecutorTask<Void, Void, List<GpxFile>> download = new ExecutorTask<Void, Void, List<GpxFile>>(logic.getExecutorService(), logic.getHandler()) {
            @Override
            protected List<GpxFile> doInBackground(Void input) throws Exception {
                return OsmGpxApi.getUserGpxFiles(server, map.getViewBox());
            }
            @Override
            protected void onPostExecute(List<GpxFile> result) {
                if (!result.isEmpty()) {
                    Builder builder = new AlertDialog.Builder(activity);
                    builder.setTitle(R.string.layer_available_tracks);
                    builder.setAdapter(new GpxFileAdapter(activity, result), (DialogInterface dialog, int which) -> {
                        final long id = result.get(which).getId();
                        new ExecutorTask<Void, Void, Uri>(logic.getExecutorService(), logic.getHandler()) {
                            @Override
                            protected Uri doInBackground(Void input) throws Exception {
                                return OsmGpxApi.downloadTrack(prefs.getServer(), id,
                                        FileUtil.getPublicDirectory(FileUtil.getPublicDirectory(), Paths.DIRECTORY_PATH_GPX).getAbsolutePath(),
                                        result.get(which).getName());
                            }
                            @Override
                            protected void onPostExecute(Uri result) {
                                if (result != null) {
                                    addStyleableLayerFromUri(activity, prefs, map, LayerType.GPX, result);
                                }
                            }
                        }.execute();
                    });
                    builder.setPositiveButton(R.string.Done, null);
                    builder.show();
                } else {
                    Tip.showDialog(activity, R.string.tip_empty_gpx_download_key, R.string.tip_empty_gpx_download);
                    Snack.toastTopWarning(activity, R.string.toast_nothing_found);
                }
            }
        };
        if (Server.checkOsmAuthentication(activity, server, download::execute)) {
            download.execute();
        }
    }
private void downloadGpxTrack ( @ NonNull final FragmentActivity activity , @ NonNull final Preferences prefs , @ NonNull final Map map ) { final Logic logic = App . getLogic ( ) ; final Server server = prefs . getServer ( ) ; ExecutorTask < Void , Void , List < GpxFile > > download = new ExecutorTask < Void , Void , List < GpxFile > > ( logic . getExecutorService ( ) , logic . getHandler ( ) ) { @ Override protected List < GpxFile > doInBackground ( Void input ) throws Exception { return OsmGpxApi . getUserGpxFiles ( server , map . getViewBox ( ) ) ; } @ Override protected void onPostExecute ( List < GpxFile > result ) { if ( ! result . isEmpty ( ) ) { Builder builder = new AlertDialog . Builder ( activity ) ; builder . setTitle ( R . string . layer_available_tracks ) ; builder . setAdapter ( new GpxFileAdapter ( activity , result ) , ( DialogInterface dialog , int which ) -> { final long id = result . get ( which ) . getId ( ) ; new ExecutorTask < Void , Void , Uri > ( logic . getExecutorService ( ) , logic . getHandler ( ) ) { @ Override protected Uri doInBackground ( Void input ) throws Exception { return OsmGpxApi . downloadTrack ( prefs . getServer ( ) , id , FileUtil . getPublicDirectory ( FileUtil . getPublicDirectory ( ) , Paths . DIRECTORY_PATH_GPX ) . getAbsolutePath ( ) , result . get ( which ) . getName ( ) ) ; } @ Override protected void onPostExecute ( Uri result ) { if ( result != null ) { addStyleableLayerFromUri ( activity , prefs , map , LayerType . GPX , result ) ; } } } . execute ( ) ; } ) ; builder . setPositiveButton ( R . string . Done , null ) ; builder . show ( ) ; } else { Tip . showDialog ( activity , R . string . tip_empty_gpx_download_key , R . string . tip_empty_gpx_download ) ; Snack . toastTopWarning ( activity , R . string . toast_nothing_found ) ; } } } ; if ( Server . checkOsmAuthentication ( activity , server , download :: execute ) ) { download . execute ( ) ; } }
Show a list of available tracks (starting point in the current view), then download on selection
Show a list of available tracks ( starting point in the current view ) then download on selection