package nl.computerhuys.tabnavui;_x000D_
_x000D_
import java.util.Map;_x000D_
_x000D_
import android.app.Activity;_x000D_
import android.app.AlertDialog;_x000D_
import android.app.Dialog;_x000D_
import android.content.ComponentName;_x000D_
import android.content.DialogInterface;_x000D_
import android.content.SharedPreferences;_x000D_
import android.os.Bundle;_x000D_
import android.support.v4.app.DialogFragment;_x000D_
import android.support.v4.app.FragmentActivity;_x000D_
import android.view.LayoutInflater;_x000D_
import android.view.View;_x000D_
import android.widget.EditText;_x000D_
_x000D_
public class VraagBanenDialogFragment extends DialogFragment {_x000D_
	_x000D_
	private View v;_x000D_
	private EditText editText1; _x000D_
	private EditText editText2; _x000D_
	//private ArrayList<Baan> banen;_x000D_
	private int[] oldBanen;_x000D_
	private int[] currentBanen;_x000D_
	private SharedPreferences prefs;_x000D_
	private int baan1;_x000D_
	private int baan2;_x000D_
	private int aantalParallel;_x000D_
_x000D_
	/*	public VraagBanenDialogFragment(ArrayList<Baan> banen) {_x000D_
		this.baanNummers = banen;_x000D_
	}_x000D_
*/_x000D_
    @Override_x000D_
    public Dialog onCreateDialog(Bundle savedInstanceState) {_x000D_
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());_x000D_
        // Restore preferences_x000D_
        _x000D_
        // Dit zou ook kunnen:_x000D_
        // prefs = InitSpel.prefsBanen;  _x000D_
        // en dan verderop InitSpel.addPreference(prefs, "BAAN_01", baan1); om te bewaren_x000D_
        prefs = getActivity().getSharedPreferences("numberPicker.preferences", 0);_x000D_
        baan1 = prefs.getInt( "BAAN_01", 0 );_x000D_
        baan2 = prefs.getInt( "BAAN_02", 0 );_x000D_
        //aantalParallel = InitSpel.prefs.getInt( "AANTAL_PARALLEL", 0 );_x000D_
        aantalParallel = prefs.getInt( "AANTAL_PARALLEL", 0 );_x000D_
        //oldBanen = new int[InitSpel.aantalParallel];_x000D_
        oldBanen = new int[aantalParallel]; _x000D_
        oldBanen[0] = baan1;_x000D_
        oldBanen[1] = baan2;_x000D_
		_x000D_
	    // Get the layout inflater_x000D_
	    LayoutInflater inflater = getActivity().getLayoutInflater();_x000D_
_x000D_
	    // Inflate and set the layout for the dialog_x000D_
	    // Pass null as the parent view because its going in the dialog layout_x000D_
	    v = inflater.inflate(R.layout.vraag_banen, null);_x000D_
	    // velden vullen met opgeslagen waarden_x000D_
 	    editText1 = (EditText) v.findViewById(R.id.editText1); _x000D_
 	    editText2 = (EditText) v.findViewById(R.id.editText2); _x000D_
 	    editText1.setText(String.valueOf(baan1));_x000D_
 	    editText2.setText(String.valueOf(baan2));_x000D_
 	    //editText1.setText(String.valueOf(banen.get(0).getBaanNummer()));_x000D_
 	    //editText2.setText(String.valueOf(banen.get(1).getBaanNummer()));_x000D_
	    builder.setView(v)_x000D_
		// Add action buttons_x000D_
		.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {_x000D_
		    @Override_x000D_
		    public void onClick(DialogInterface dialog, int id) {_x000D_
		    	   _x000D_
		 	   baan1 = Integer.valueOf(editText1.getText().toString());_x000D_
		 	   baan2 = Integer.valueOf(editText2.getText().toString());_x000D_
		 	   InitSpel.setBaanNummer(0, baan1);_x000D_
		 	   InitSpel.setBaanNummer(1, baan2);_x000D_
		    	   _x000D_
		 	   // en banen nog bij de preferences op schijf opslaan._x000D_
		 	   prefs.edit()_x000D_
		 	     	.putInt("BAAN_01", baan1)_x000D_
		 	     	.putInt("BAAN_02", baan2)_x000D_
		 	     	.commit();_x000D_
		    }_x000D_
		})_x000D_
		.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {_x000D_
		    public void onClick(DialogInterface dialog, int id) {_x000D_
		 	   // TODO cancel;_x000D_
		    }_x000D_
		});      _x000D_
		return builder.create();_x000D_
	}	_x000D_
 }_x000D_

//private ArrayList<Baan> banen;_x000D_
package nl.computerhuys.tabnavui;_x000D_
_x000D_
import java.util.Map;_x000D_
_x000D_
import android.app.Activity;_x000D_
import android.app.AlertDialog;_x000D_
import android.app.Dialog;_x000D_
import android.content.ComponentName;_x000D_
import android.content.DialogInterface;_x000D_
import android.content.SharedPreferences;_x000D_
import android.os.Bundle;_x000D_
import android.support.v4.app.DialogFragment;_x000D_
import android.support.v4.app.FragmentActivity;_x000D_
import android.view.LayoutInflater;_x000D_
import android.view.View;_x000D_
import android.widget.EditText;_x000D_
_x000D_
public class VraagBanenDialogFragment extends DialogFragment {_x000D_
	_x000D_
	private View v;_x000D_
	private EditText editText1; _x000D_
	private EditText editText2; _x000D_
	//private ArrayList<Baan><SUF>
	private int[] oldBanen;_x000D_
	private int[] currentBanen;_x000D_
	private SharedPreferences prefs;_x000D_
	private int baan1;_x000D_
	private int baan2;_x000D_
	private int aantalParallel;_x000D_
_x000D_
	/*	public VraagBanenDialogFragment(ArrayList<Baan> banen) {_x000D_
		this.baanNummers = banen;_x000D_
	}_x000D_
*/_x000D_
    @Override_x000D_
    public Dialog onCreateDialog(Bundle savedInstanceState) {_x000D_
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());_x000D_
        // Restore preferences_x000D_
        _x000D_
        // Dit zou ook kunnen:_x000D_
        // prefs = InitSpel.prefsBanen;  _x000D_
        // en dan verderop InitSpel.addPreference(prefs, "BAAN_01", baan1); om te bewaren_x000D_
        prefs = getActivity().getSharedPreferences("numberPicker.preferences", 0);_x000D_
        baan1 = prefs.getInt( "BAAN_01", 0 );_x000D_
        baan2 = prefs.getInt( "BAAN_02", 0 );_x000D_
        //aantalParallel = InitSpel.prefs.getInt( "AANTAL_PARALLEL", 0 );_x000D_
        aantalParallel = prefs.getInt( "AANTAL_PARALLEL", 0 );_x000D_
        //oldBanen = new int[InitSpel.aantalParallel];_x000D_
        oldBanen = new int[aantalParallel]; _x000D_
        oldBanen[0] = baan1;_x000D_
        oldBanen[1] = baan2;_x000D_
		_x000D_
	    // Get the layout inflater_x000D_
	    LayoutInflater inflater = getActivity().getLayoutInflater();_x000D_
_x000D_
	    // Inflate and set the layout for the dialog_x000D_
	    // Pass null as the parent view because its going in the dialog layout_x000D_
	    v = inflater.inflate(R.layout.vraag_banen, null);_x000D_
	    // velden vullen met opgeslagen waarden_x000D_
 	    editText1 = (EditText) v.findViewById(R.id.editText1); _x000D_
 	    editText2 = (EditText) v.findViewById(R.id.editText2); _x000D_
 	    editText1.setText(String.valueOf(baan1));_x000D_
 	    editText2.setText(String.valueOf(baan2));_x000D_
 	    //editText1.setText(String.valueOf(banen.get(0).getBaanNummer()));_x000D_
 	    //editText2.setText(String.valueOf(banen.get(1).getBaanNummer()));_x000D_
	    builder.setView(v)_x000D_
		// Add action buttons_x000D_
		.setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {_x000D_
		    @Override_x000D_
		    public void onClick(DialogInterface dialog, int id) {_x000D_
		    	   _x000D_
		 	   baan1 = Integer.valueOf(editText1.getText().toString());_x000D_
		 	   baan2 = Integer.valueOf(editText2.getText().toString());_x000D_
		 	   InitSpel.setBaanNummer(0, baan1);_x000D_
		 	   InitSpel.setBaanNummer(1, baan2);_x000D_
		    	   _x000D_
		 	   // en banen nog bij de preferences op schijf opslaan._x000D_
		 	   prefs.edit()_x000D_
		 	     	.putInt("BAAN_01", baan1)_x000D_
		 	     	.putInt("BAAN_02", baan2)_x000D_
		 	     	.commit();_x000D_
		    }_x000D_
		})_x000D_
		.setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {_x000D_
		    public void onClick(DialogInterface dialog, int id) {_x000D_
		 	   // TODO cancel;_x000D_
		    }_x000D_
		});      _x000D_
		return builder.create();_x000D_
	}	_x000D_
 }_x000D_
