project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java
branchhedgeroid
changeset 6350 41b0a9955c47
parent 6049 7bc38086d771
child 6432 ffb18b44415d
equal deleted inserted replaced
6348:162fec525764 6350:41b0a9955c47
    97 			hogDice.add((ImageButton) team_creation_entry
    97 			hogDice.add((ImageButton) team_creation_entry
    98 					.findViewById(R.id.btnTeam1));
    98 					.findViewById(R.id.btnTeam1));
    99 			hogName.add((EditText) team_creation_entry
    99 			hogName.add((EditText) team_creation_entry
   100 					.findViewById(R.id.txtTeam1));
   100 					.findViewById(R.id.txtTeam1));
   101 		}
   101 		}
   102 		ArrayList<HashMap<String, ?>> gravesData = FrontendDataUtils
   102 		ArrayList<HashMap<String, ?>> gravesData = FrontendDataUtils.getGraves(this);
   103 				.getGraves(this);
       
   104 		SimpleAdapter sa = new SimpleAdapter(this, gravesData,
   103 		SimpleAdapter sa = new SimpleAdapter(this, gravesData,
   105 				R.layout.spinner_textimg_entry, new String[] { "txt", "img" },
   104 				R.layout.spinner_textimg_entry, new String[] { "txt", "img" },
   106 				new int[] { R.id.spinner_txt, R.id.spinner_img });
   105 				new int[] { R.id.spinner_txt, R.id.spinner_img });
   107 
   106 		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
   108 		sa.setViewBinder(viewBinder);
   107 		sa.setViewBinder(viewBinder);
   109 		grave.setAdapter(sa);
   108 		grave.setAdapter(sa);
   110 		grave.setOnFocusChangeListener(focusser);
   109 		grave.setOnFocusChangeListener(focusser);
   111 
   110 
   112 		ArrayList<HashMap<String, ?>> flagsData = FrontendDataUtils
   111 		ArrayList<HashMap<String, ?>> flagsData = FrontendDataUtils
   113 				.getFlags(this);
   112 				.getFlags(this);
   114 		sa = new SimpleAdapter(this, flagsData, R.layout.spinner_textimg_entry,
   113 		sa = new SimpleAdapter(this, flagsData, R.layout.spinner_textimg_entry,
   115 				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
   114 				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
   116 						R.id.spinner_img });
   115 						R.id.spinner_img });
       
   116 		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
   117 		sa.setViewBinder(viewBinder);
   117 		sa.setViewBinder(viewBinder);
   118 		flag.setAdapter(sa);
   118 		flag.setAdapter(sa);
   119 		flag.setOnFocusChangeListener(focusser);
   119 		flag.setOnFocusChangeListener(focusser);
   120 
   120 
   121 		ArrayList<HashMap<String, ?>> typesData = FrontendDataUtils
   121 		ArrayList<HashMap<String, ?>> typesData = FrontendDataUtils
   122 				.getTypes(this);
   122 				.getTypes(this);
   123 		sa = new SimpleAdapter(this, typesData, R.layout.spinner_textimg_entry,
   123 		sa = new SimpleAdapter(this, typesData, R.layout.spinner_textimg_entry,
   124 				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
   124 				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
   125 						R.id.spinner_img });
   125 						R.id.spinner_img });
       
   126 		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
   126 		difficulty.setAdapter(sa);
   127 		difficulty.setAdapter(sa);
   127 		difficulty.setOnFocusChangeListener(focusser);
   128 		difficulty.setOnFocusChangeListener(focusser);
   128 
   129 
   129 		ArrayList<HashMap<String, ?>> hatsData = FrontendDataUtils
   130 		ArrayList<HashMap<String, ?>> hatsData = FrontendDataUtils
   130 				.getHats(this);
   131 				.getHats(this);
   131 		sa = new SimpleAdapter(this, hatsData, R.layout.spinner_textimg_entry,
   132 		sa = new SimpleAdapter(this, hatsData, R.layout.spinner_textimg_entry,
   132 				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
   133 				new String[] { "txt", "img" }, new int[] { R.id.spinner_txt,
   133 						R.id.spinner_img });
   134 						R.id.spinner_img });
       
   135 		sa.setDropDownViewResource(R.layout.spinner_textimg_dropdown_entry);
   134 		sa.setViewBinder(viewBinder);
   136 		sa.setViewBinder(viewBinder);
   135 		for (Spinner spin : hogHat) {
   137 		for (Spinner spin : hogHat) {
   136 			spin.setAdapter(sa);
   138 			spin.setAdapter(sa);
   137 		}
   139 		}
   138 
   140 
   139 		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
   141 		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
   140 				R.layout.listview_item, FrontendDataUtils.getVoices(this));
   142 				R.layout.listview_item, FrontendDataUtils.getVoices(this));
       
   143 		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   141 		voice.setAdapter(adapter);
   144 		voice.setAdapter(adapter);
   142 		voice.setOnFocusChangeListener(focusser);
   145 		voice.setOnFocusChangeListener(focusser);
   143 		voiceButton.setOnClickListener(voiceClicker);
   146 		voiceButton.setOnClickListener(voiceClicker);
   144 
   147 
   145 		adapter = new ArrayAdapter<String>(this, R.layout.listview_item,
   148 		adapter = new ArrayAdapter<String>(this, R.layout.listview_item,
   146 				FrontendDataUtils.getForts(this));
   149 				FrontendDataUtils.getForts(this));
       
   150 		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
   147 		fort.setAdapter(adapter);
   151 		fort.setAdapter(adapter);
   148 		fort.setOnItemSelectedListener(fortSelector);
   152 		fort.setOnItemSelectedListener(fortSelector);
   149 		fort.setOnFocusChangeListener(focusser);
   153 		fort.setOnFocusChangeListener(focusser);
   150 
   154 
   151 		Team t = this.getIntent().getParcelableExtra("team");
   155 		Team t = this.getIntent().getParcelableExtra("team");
   292 		public void onItemSelected(AdapterView<?> arg0, View arg1,
   296 		public void onItemSelected(AdapterView<?> arg0, View arg1,
   293 				int position, long arg3) {
   297 				int position, long arg3) {
   294 			settingsChanged = true;
   298 			settingsChanged = true;
   295 			String fortName = (String) arg0.getAdapter().getItem(position);
   299 			String fortName = (String) arg0.getAdapter().getItem(position);
   296 			Drawable fortIconDrawable = Drawable.createFromPath(Utils
   300 			Drawable fortIconDrawable = Drawable.createFromPath(Utils
   297 					.getDownloadPath(TeamCreatorActivity.this)
   301 					.getDataPath(TeamCreatorActivity.this)
   298 					+ "Forts/"
   302 					+ "Forts/"
   299 					+ fortName + "L.png");
   303 					+ fortName + "L.png");
   300 			imgFort.setImageDrawable(fortIconDrawable);
   304 			imgFort.setImageDrawable(fortIconDrawable);
   301 			scroller.fullScroll(ScrollView.FOCUS_DOWN);// Scroll the scrollview
   305 			scroller.fullScroll(ScrollView.FOCUS_DOWN);// Scroll the scrollview
   302 														// to the bottom, work
   306 														// to the bottom, work
   312 
   316 
   313 	private OnClickListener voiceClicker = new OnClickListener() {
   317 	private OnClickListener voiceClicker = new OnClickListener() {
   314 		public void onClick(View v) {
   318 		public void onClick(View v) {
   315 			try {
   319 			try {
   316 				File dir = new File(String.format("%sSounds/voices/%s",
   320 				File dir = new File(String.format("%sSounds/voices/%s",
   317 						Utils.getDownloadPath(TeamCreatorActivity.this),
   321 						Utils.getDataPath(TeamCreatorActivity.this),
   318 						voice.getSelectedItem()));
   322 						voice.getSelectedItem()));
   319 				String file = "";
   323 				String file = "";
   320 				File[] dirs = dir.listFiles();
   324 				File[] dirs = dir.listFiles();
   321 				File f = dirs[(int) Math.round(Math.random() * dirs.length)];
   325 				File f = dirs[(int) Math.round(Math.random() * dirs.length)];
   322 				if (f.getName().endsWith(".ogg"))
   326 				if (f.getName().endsWith(".ogg"))