Improved layout initialization

This commit is contained in:
VanitasVitae 2015-09-26 16:51:19 +02:00
parent 95f449d743
commit e4a0e3ccb8
15 changed files with 202 additions and 492 deletions

View file

@ -98,52 +98,52 @@ public class Reflector
switch (type) switch (type)
{ {
//Enigma I //Enigma I
case 10: return new ReflectorA().setTypeNumer(type); case 10: return new ReflectorA().setNumber(type);
case 11: return new ReflectorB().setTypeNumer(type); case 11: return new ReflectorB().setNumber(type);
case 12: return new ReflectorC().setTypeNumer(type); case 12: return new ReflectorC().setNumber(type);
//Enigma M3 //Enigma M3
case 20: return new ReflectorB().setTypeNumer(type); case 20: return new ReflectorB().setNumber(type);
case 21: return new ReflectorC().setTypeNumer(type); case 21: return new ReflectorC().setNumber(type);
//Enigma M4 //Enigma M4
case 30: return new ReflectorThinB().setTypeNumer(type); case 30: return new ReflectorThinB().setNumber(type);
case 31: return new ReflectorThinC().setTypeNumer(type); case 31: return new ReflectorThinC().setNumber(type);
//Enigma G31 //Enigma G31
case 40: return new ReflectorEnigma_D_KD_G31().setTypeNumer(type); case 40: return new ReflectorEnigma_D_KD_G31().setNumber(type);
//Enigma G312 //Enigma G312
case 50: return new Reflector_G312().setTypeNumer(type); case 50: return new Reflector_G312().setNumber(type);
//Enigma G260 //Enigma G260
case 60: return new Reflector_G260().setTypeNumer(type); case 60: return new Reflector_G260().setNumber(type);
//Enigma D //Enigma D
case 70: return new ReflectorEnigma_D_KD_G31().setTypeNumer(type); case 70: return new ReflectorEnigma_D_KD_G31().setNumber(type);
//Enigma K //Enigma K
case 80: return new ReflectorEnigma_K().setTypeNumer(type); case 80: return new ReflectorEnigma_K().setNumber(type);
//Enigma K Swiss //Enigma K Swiss
case 90: return new ReflectorEnigma_K().setTypeNumer(type); case 90: return new ReflectorEnigma_K().setNumber(type);
//Enigma K Swiss Airforce //Enigma K Swiss Airforce
case 100: return new ReflectorEnigma_K().setTypeNumer(type); case 100: return new ReflectorEnigma_K().setNumber(type);
//Enigma R //Enigma R
case 110: return new Reflector_R().setTypeNumer(type); case 110: return new Reflector_R().setNumber(type);
//Enigma T //Enigma T
case 120: return new ReflectorEnigma_T().setTypeNumer(type); case 120: return new ReflectorEnigma_T().setNumber(type);
default: default:
Log.d("Reflector:","Fail! "+type); Log.e("Reflector:"," Tried to create Reflector of invalid type "+type);
return null; return null;
} }
} }
public Reflector setTypeNumer(int nr) public Reflector setNumber(int nr)
{ {
this.number = nr; this.number = nr;
return this; return this;

View file

@ -84,89 +84,89 @@ public class Rotor
{ {
switch (type) switch (type)
{ {
case 1: Log.d("Rotor", "created " + type); return new EntryWheel_QWERTZ().setTypeNumber(type); case 1: return new EntryWheel_QWERTZ().setTypeNumber(type);
case 2: Log.d("Rotor","created "+type); return new EntryWheel_T().setTypeNumber(type); case 2: return new EntryWheel_T().setTypeNumber(type);
//Enigma I //Enigma I
case 10: Log.d("Rotor","created "+type); return new Rotor_I(rotation, ringSetting).setTypeNumber(type); case 10: return new Rotor_I(rotation, ringSetting).setTypeNumber(type);
case 11: Log.d("Rotor","created "+type); return new Rotor_II(rotation, ringSetting).setTypeNumber(type); case 11: return new Rotor_II(rotation, ringSetting).setTypeNumber(type);
case 12: Log.d("Rotor","created "+type); return new Rotor_III(rotation, ringSetting).setTypeNumber(type); case 12: return new Rotor_III(rotation, ringSetting).setTypeNumber(type);
case 13: Log.d("Rotor","created "+type); return new Rotor_IV(rotation, ringSetting).setTypeNumber(type); case 13: return new Rotor_IV(rotation, ringSetting).setTypeNumber(type);
case 14: Log.d("Rotor","created "+type); return new Rotor_V(rotation, ringSetting).setTypeNumber(type); case 14: return new Rotor_V(rotation, ringSetting).setTypeNumber(type);
//Enigma M3 //Enigma M3
case 20: Log.d("Rotor","created "+type); return new Rotor_I(rotation, ringSetting).setTypeNumber(type); case 20: return new Rotor_I(rotation, ringSetting).setTypeNumber(type);
case 21: Log.d("Rotor","created "+type); return new Rotor_II(rotation, ringSetting).setTypeNumber(type); case 21: return new Rotor_II(rotation, ringSetting).setTypeNumber(type);
case 22: Log.d("Rotor","created "+type); return new Rotor_III(rotation, ringSetting).setTypeNumber(type); case 22: return new Rotor_III(rotation, ringSetting).setTypeNumber(type);
case 23: Log.d("Rotor","created "+type); return new Rotor_IV(rotation, ringSetting).setTypeNumber(type); case 23: return new Rotor_IV(rotation, ringSetting).setTypeNumber(type);
case 24: Log.d("Rotor","created "+type); return new Rotor_V(rotation, ringSetting).setTypeNumber(type); case 24: return new Rotor_V(rotation, ringSetting).setTypeNumber(type);
case 25: Log.d("Rotor","created "+type); return new Rotor_VI(rotation, ringSetting).setTypeNumber(type); case 25: return new Rotor_VI(rotation, ringSetting).setTypeNumber(type);
case 26: Log.d("Rotor","created "+type); return new Rotor_VII(rotation, ringSetting).setTypeNumber(type); case 26: return new Rotor_VII(rotation, ringSetting).setTypeNumber(type);
case 27: Log.d("Rotor","created "+type); return new Rotor_VIII(rotation, ringSetting).setTypeNumber(type); case 27: return new Rotor_VIII(rotation, ringSetting).setTypeNumber(type);
//Enigma M4 //Enigma M4
case 30: Log.d("Rotor","created "+type); return new Rotor_I(rotation, ringSetting).setTypeNumber(type); case 30: return new Rotor_I(rotation, ringSetting).setTypeNumber(type);
case 31: Log.d("Rotor","created "+type); return new Rotor_II(rotation, ringSetting).setTypeNumber(type); case 31: return new Rotor_II(rotation, ringSetting).setTypeNumber(type);
case 32: Log.d("Rotor","created "+type); return new Rotor_III(rotation, ringSetting).setTypeNumber(type); case 32: return new Rotor_III(rotation, ringSetting).setTypeNumber(type);
case 33: Log.d("Rotor","created "+type); return new Rotor_IV(rotation, ringSetting).setTypeNumber(type); case 33: return new Rotor_IV(rotation, ringSetting).setTypeNumber(type);
case 34: Log.d("Rotor","created "+type); return new Rotor_V(rotation, ringSetting).setTypeNumber(type); case 34: return new Rotor_V(rotation, ringSetting).setTypeNumber(type);
case 35: Log.d("Rotor","created "+type); return new Rotor_VI(rotation, ringSetting).setTypeNumber(type); case 35: return new Rotor_VI(rotation, ringSetting).setTypeNumber(type);
case 36: Log.d("Rotor","created "+type); return new Rotor_VII(rotation, ringSetting).setTypeNumber(type); case 36: return new Rotor_VII(rotation, ringSetting).setTypeNumber(type);
case 37: Log.d("Rotor","created "+type); return new Rotor_VIII(rotation, ringSetting).setTypeNumber(type); case 37: return new Rotor_VIII(rotation, ringSetting).setTypeNumber(type);
case 38: Log.d("Rotor","created "+type); return new Rotor_M4_Beta(rotation, ringSetting).setTypeNumber(type); case 38: return new Rotor_M4_Beta(rotation, ringSetting).setTypeNumber(type);
case 39: Log.d("Rotor","created "+type); return new Rotor_M4_Gamma(rotation, ringSetting).setTypeNumber(type); case 39: return new Rotor_M4_Gamma(rotation, ringSetting).setTypeNumber(type);
//Enigma G31 //Enigma G31
case 40: Log.d("Rotor","created "+type); return new Rotor_G31_I(rotation, ringSetting).setTypeNumber(type); case 40: return new Rotor_G31_I(rotation, ringSetting).setTypeNumber(type);
case 41: Log.d("Rotor","created "+type); return new Rotor_G31_II(rotation, ringSetting).setTypeNumber(type); case 41: return new Rotor_G31_II(rotation, ringSetting).setTypeNumber(type);
case 42: Log.d("Rotor","created "+type); return new Rotor_G31_III(rotation, ringSetting).setTypeNumber(type); case 42: return new Rotor_G31_III(rotation, ringSetting).setTypeNumber(type);
//Enigma G312 //Enigma G312
case 50: Log.d("Rotor","created "+type); return new Rotor_G312_I(rotation, ringSetting).setTypeNumber(type); case 50: return new Rotor_G312_I(rotation, ringSetting).setTypeNumber(type);
case 51: Log.d("Rotor","created "+type); return new Rotor_G312_II(rotation, ringSetting).setTypeNumber(type); case 51: return new Rotor_G312_II(rotation, ringSetting).setTypeNumber(type);
case 52: Log.d("Rotor","created "+type); return new Rotor_G312_III(rotation, ringSetting).setTypeNumber(type); case 52: return new Rotor_G312_III(rotation, ringSetting).setTypeNumber(type);
//Enigma G260 //Enigma G260
case 60: Log.d("Rotor","created "+type); return new Rotor_G260_I(rotation, ringSetting).setTypeNumber(type); case 60: return new Rotor_G260_I(rotation, ringSetting).setTypeNumber(type);
case 61: Log.d("Rotor","created "+type); return new Rotor_G260_II(rotation, ringSetting).setTypeNumber(type); case 61: return new Rotor_G260_II(rotation, ringSetting).setTypeNumber(type);
case 62: Log.d("Rotor","created "+type); return new Rotor_G260_III(rotation, ringSetting).setTypeNumber(type); case 62: return new Rotor_G260_III(rotation, ringSetting).setTypeNumber(type);
//Enigma D //Enigma D
case 70: Log.d("Rotor","created "+type); return new Rotor_D_I(rotation, ringSetting).setTypeNumber(type); case 70: return new Rotor_D_I(rotation, ringSetting).setTypeNumber(type);
case 71: Log.d("Rotor","created "+type); return new Rotor_D_II(rotation, ringSetting).setTypeNumber(type); case 71: return new Rotor_D_II(rotation, ringSetting).setTypeNumber(type);
case 72: Log.d("Rotor","created "+type); return new Rotor_D_III(rotation, ringSetting).setTypeNumber(type); case 72: return new Rotor_D_III(rotation, ringSetting).setTypeNumber(type);
//Enigma K //Enigma K
case 80: Log.d("Rotor","created "+type); return new Rotor_K_I(rotation, ringSetting).setTypeNumber(type); case 80: return new Rotor_K_I(rotation, ringSetting).setTypeNumber(type);
case 81: Log.d("Rotor","created "+type); return new Rotor_K_II(rotation, ringSetting).setTypeNumber(type); case 81: return new Rotor_K_II(rotation, ringSetting).setTypeNumber(type);
case 82: Log.d("Rotor","created "+type); return new Rotor_K_III(rotation, ringSetting).setTypeNumber(type); case 82: return new Rotor_K_III(rotation, ringSetting).setTypeNumber(type);
//Enigma K Swiss //Enigma K Swiss
case 90: Log.d("Rotor","created "+type); return new Rotor_KSwiss_Standard_I(rotation, ringSetting).setTypeNumber(type); case 90: return new Rotor_KSwiss_Standard_I(rotation, ringSetting).setTypeNumber(type);
case 91: Log.d("Rotor","created "+type); return new Rotor_KSwiss_Standard_II(rotation, ringSetting).setTypeNumber(type); case 91: return new Rotor_KSwiss_Standard_II(rotation, ringSetting).setTypeNumber(type);
case 92: Log.d("Rotor","created "+type); return new Rotor_KSwiss_Standard_III(rotation, ringSetting).setTypeNumber(type); case 92: return new Rotor_KSwiss_Standard_III(rotation, ringSetting).setTypeNumber(type);
//Enigma K Swiss Airforce //Enigma K Swiss Airforce
case 100: Log.d("Rotor","created "+type); return new Rotor_K_Swiss_Airforce_I(rotation, ringSetting).setTypeNumber(type); case 100: return new Rotor_K_Swiss_Airforce_I(rotation, ringSetting).setTypeNumber(type);
case 101: Log.d("Rotor","created "+type); return new Rotor_K_Swiss_Airforce_II(rotation, ringSetting).setTypeNumber(type); case 101: return new Rotor_K_Swiss_Airforce_II(rotation, ringSetting).setTypeNumber(type);
case 102: Log.d("Rotor","created "+type); return new Rotor_K_Swiss_Airforce_III(rotation, ringSetting).setTypeNumber(type); case 102: return new Rotor_K_Swiss_Airforce_III(rotation, ringSetting).setTypeNumber(type);
//Enigma R //Enigma R
case 110: Log.d("Rotor","created "+type); return new Rotor_R_I(rotation, ringSetting).setTypeNumber(type); case 110: return new Rotor_R_I(rotation, ringSetting).setTypeNumber(type);
case 111: Log.d("Rotor","created "+type); return new Rotor_R_II(rotation, ringSetting).setTypeNumber(type); case 111: return new Rotor_R_II(rotation, ringSetting).setTypeNumber(type);
case 112: Log.d("Rotor","created "+type); return new Rotor_R_III(rotation, ringSetting).setTypeNumber(type); case 112: return new Rotor_R_III(rotation, ringSetting).setTypeNumber(type);
//Enigma T //Enigma T
case 120: Log.d("Rotor","created "+type); return new Rotor_T_I(rotation, ringSetting).setTypeNumber(type); case 120: return new Rotor_T_I(rotation, ringSetting).setTypeNumber(type);
case 121: Log.d("Rotor","created "+type); return new Rotor_T_II(rotation, ringSetting).setTypeNumber(type); case 121: return new Rotor_T_II(rotation, ringSetting).setTypeNumber(type);
case 122: Log.d("Rotor","created "+type); return new Rotor_T_III(rotation, ringSetting).setTypeNumber(type); case 122: return new Rotor_T_III(rotation, ringSetting).setTypeNumber(type);
case 123: Log.d("Rotor","created "+type); return new Rotor_T_IV(rotation, ringSetting).setTypeNumber(type); case 123: return new Rotor_T_IV(rotation, ringSetting).setTypeNumber(type);
case 124: Log.d("Rotor","created "+type); return new Rotor_T_V(rotation, ringSetting).setTypeNumber(type); case 124: return new Rotor_T_V(rotation, ringSetting).setTypeNumber(type);
case 125: Log.d("Rotor","created "+type); return new Rotor_T_VI(rotation, ringSetting).setTypeNumber(type); case 125: return new Rotor_T_VI(rotation, ringSetting).setTypeNumber(type);
case 126: Log.d("Rotor","created "+type); return new Rotor_T_VII(rotation, ringSetting).setTypeNumber(type); case 126: return new Rotor_T_VII(rotation, ringSetting).setTypeNumber(type);
case 127: Log.d("Rotor","created "+type); return new Rotor_T_VIII(rotation, ringSetting).setTypeNumber(type); case 127: return new Rotor_T_VIII(rotation, ringSetting).setTypeNumber(type);
default: Log.d("Rotor:"," Fail! "+type); default: Log.e("Rotor:"," Tried to create Rotor of invalid type "+type);
return null; return null;
} }
} }

View file

@ -1,6 +1,8 @@
package de.vanitasvitae.enigmandroid.layout; package de.vanitasvitae.enigmandroid.layout;
import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Spinner;
import de.vanitasvitae.enigmandroid.MainActivity; import de.vanitasvitae.enigmandroid.MainActivity;
import de.vanitasvitae.enigmandroid.R; import de.vanitasvitae.enigmandroid.R;
@ -135,6 +137,35 @@ public abstract class LayoutContainer
} }
} }
/**
* Add ArrayAdapter, contents and layouts to Spinner
* @param view Spinner
* @param resourceID ID of the referenced array (eg. R.array.rotor_1_8)
*/
protected void prepareSpinnerAdapter(Spinner view, int resourceID) {
MainActivity main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(main, resourceID,
android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
view.setAdapter(adapter);
}
/**
* Add ArrayAdapter, contents and layouts to Spinner
* @param view Spinner
* @param array Character array
*/
protected void prepareSpinnerAdapter(Spinner view, Character[] array)
{
MainActivity main = (MainActivity) MainActivity.ActivitySingleton.getInstance().getActivity();
ArrayAdapter<Character> adapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, array);
adapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
view.setAdapter(adapter);
}
public void setInputPreparer(InputPreparer inputPreparer) public void setInputPreparer(InputPreparer inputPreparer)
{ {
this.inputPreparer = inputPreparer; this.inputPreparer = inputPreparer;

View file

@ -61,28 +61,12 @@ public class LayoutContainer_D extends LayoutContainer
}); });
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(), prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item,rotorPositionArray); prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource( prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -66,42 +66,15 @@ public class LayoutContainer_G260 extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -66,42 +66,15 @@ public class LayoutContainer_G31 extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -66,42 +66,15 @@ public class LayoutContainer_G312 extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -67,41 +67,15 @@ public class LayoutContainer_I extends LayoutContainer
}); });
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_5, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_5);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_5);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_5);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(reflectorView, R.array.reflectors_a_c);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_5, prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_5,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<CharSequence> reflectorAdapter = ArrayAdapter.createFromResource(main, R.array.reflectors_a_c,
android.R.layout.simple_spinner_item);
reflectorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
reflectorView.setAdapter(reflectorAdapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
} }
@Override @Override

View file

@ -65,42 +65,16 @@ public class LayoutContainer_K extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
rotor1View.setAdapter(rotor1Adapter);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(), prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item, rotorPositionArray); prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource( prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -65,42 +65,16 @@ public class LayoutContainer_K_Swiss extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
rotor1View.setAdapter(rotor1Adapter);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(), prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item, rotorPositionArray); prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource( prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -65,42 +65,16 @@ public class LayoutContainer_K_Swiss_Airforce extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
rotor1View.setAdapter(rotor1Adapter);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(), prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item, rotorPositionArray); prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource( prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -59,41 +59,15 @@ public class LayoutContainer_M3 extends LayoutContainer_I
}); });
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_8);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_8);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_8);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(reflectorView, R.array.reflectors_b_c);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8, prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<CharSequence> reflectorAdapter = ArrayAdapter.createFromResource(main, R.array.reflectors_b_c,
android.R.layout.simple_spinner_item);
reflectorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
reflectorView.setAdapter(reflectorAdapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
} }
@Override @Override

View file

@ -77,57 +77,17 @@ public class LayoutContainer_M4 extends LayoutContainer
}); });
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_8);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_8);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_8);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(rotor4View, R.array.rotors_beta_gamma);
prepareSpinnerAdapter(reflectorView, R.array.reflectors_b_c);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8, prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter); prepareSpinnerAdapter(rotor4PositionView, rotorPositionArray);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<CharSequence> rotor4Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_beta_gamma,
android.R.layout.simple_spinner_item);
rotor4Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor4View.setAdapter(rotor4Adapter);
ArrayAdapter<CharSequence> reflectorAdapter = ArrayAdapter.createFromResource(main, R.array.reflectors_b_c,
android.R.layout.simple_spinner_item);
reflectorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
reflectorView.setAdapter(reflectorAdapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> rotor4PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item,rotorPositionArray);
rotor4PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor4PositionView.setAdapter(rotor4PositionAdapter);
} }
@Override @Override

View file

@ -64,42 +64,15 @@ public class LayoutContainer_R extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_3);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_3);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_3);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3, prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_3,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override

View file

@ -64,42 +64,15 @@ public class LayoutContainer_T extends LayoutContainer
this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position); this.reflectorPositionView = (Spinner) main.findViewById(R.id.reflector_position);
Character[] rotorPositionArray = new Character[26]; Character[] rotorPositionArray = new Character[26];
for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /**Fill with A..Z*/} for(int i=0; i<26; i++) {rotorPositionArray[i] = (char) (65+i); /*Fill with A..Z*/}
ArrayAdapter<CharSequence> rotor1Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8, prepareSpinnerAdapter(rotor1View, R.array.rotors_1_8);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor2View, R.array.rotors_1_8);
rotor1Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(rotor3View, R.array.rotors_1_8);
rotor1View.setAdapter(rotor1Adapter); prepareSpinnerAdapter(rotor1PositionView, rotorPositionArray);
ArrayAdapter<CharSequence> rotor2Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8, prepareSpinnerAdapter(rotor2PositionView, rotorPositionArray);
android.R.layout.simple_spinner_item); prepareSpinnerAdapter(rotor3PositionView, rotorPositionArray);
rotor2Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); prepareSpinnerAdapter(reflectorPositionView, rotorPositionArray);
rotor2View.setAdapter(rotor2Adapter);
ArrayAdapter<CharSequence> rotor3Adapter = ArrayAdapter.createFromResource(main, R.array.rotors_1_8,
android.R.layout.simple_spinner_item);
rotor3Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
rotor3View.setAdapter(rotor3Adapter);
ArrayAdapter<Character> rotor1PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor1PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor1PositionView.setAdapter(rotor1PositionAdapter);
ArrayAdapter<Character> rotor2PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor2PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor2PositionView.setAdapter(rotor2PositionAdapter);
ArrayAdapter<Character> rotor3PositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
rotor3PositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
rotor3PositionView.setAdapter(rotor3PositionAdapter);
ArrayAdapter<Character> reflectorPositionAdapter = new ArrayAdapter<>(main.getApplicationContext(),
android.R.layout.simple_spinner_item, rotorPositionArray);
reflectorPositionAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
reflectorPositionView.setAdapter(reflectorPositionAdapter);
} }
@Override @Override