package de.apps4ics.mountainnavigation.pois;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;

import de.apps4ics.mountainnavigation.Features;
import de.apps4ics.mountainnavigation.adapters.ImageListAdapter;
import de.apps4ics.mountainnavigation.MainActivity;
import de.apps4ics.mountainnavigation.R;
import de.apps4ics.mountainnavigation.handlers.PoiHandler;

/**
 * Created by Vinz on 03.11.2015.
 */
public class AddFountainDialog extends DialogFragment {
    PoiHandler poiHandler;

    public AddFountainDialog(PoiHandler poiHandler){
        this.poiHandler = poiHandler;
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.fountain_size_dialog_title)
                //.setIcon(res.getDrawable(R.drawable.water))
                .setAdapter(new ImageListAdapter(getActivity(), PoiHandler.getFountainSizes(), PoiHandler.getFountainImgs(), true), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        int size = 0;
                        switch (which) {
                            case 0:
                                size = Features.FOUNTAIN_SMALL;
                                break;
                            case 1:
                                size = Features.FOUNTAIN_MEDIUM;
                                break;
                            case 2:
                                size = Features.FOUNTAIN_LARGE;
                                break;
                            default:
                                Log.e(MainActivity.TAG, "Wrong fountain size " + which);
                        }
                        poiHandler.addPoi(new Fountain(0, size, null));
                    }
                });
        return builder.create();
    }
}
