# HG changeset patch # User Xeli # Date 1326658072 -3600 # Node ID 54e19cefcdac0c62bc756edf86ad54ebed77b6bc # Parent bc1214f66ee4b13a04ca1fcbfa80c2863126865b Load the TeamCreationmenu's contents in a different thread diff -r bc1214f66ee4 -r 54e19cefcdac project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Sun Jan 15 21:04:31 2012 +0100 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Sun Jan 15 21:07:52 2012 +0100 @@ -67,8 +67,12 @@ private boolean saved = false; private String fileName = null; - private List> flagsData, typesData, gravesData, hatsData; - private List voicesData, fortsData; + private final List> flagsData = new ArrayList>(); + private final List> typesData = new ArrayList>(); + private final List> gravesData = new ArrayList>(); + private final List> hatsData = new ArrayList>(); + private final List voicesData = new ArrayList(); + private final List fortsData = new ArrayList(); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -104,7 +108,6 @@ .findViewById(R.id.txtTeam1)); } - gravesData = new ArrayList>(); SimpleAdapter sa = new SimpleAdapter(this, gravesData, R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, R.id.spinner_img }); @@ -113,7 +116,6 @@ grave.setAdapter(sa); grave.setOnFocusChangeListener(focusser); - flagsData = new ArrayList>(); sa = new SimpleAdapter(this, flagsData, R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, R.id.spinner_img }); @@ -122,7 +124,6 @@ flag.setAdapter(sa); flag.setOnFocusChangeListener(focusser); - typesData = new ArrayList>(); sa = new SimpleAdapter(this, typesData, R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, R.id.spinner_img }); @@ -130,7 +131,6 @@ difficulty.setAdapter(sa); difficulty.setOnFocusChangeListener(focusser); - hatsData = new ArrayList>(); sa = new SimpleAdapter(this, hatsData, R.layout.spinner_textimg_entry, new String[] { "txt", "img" }, new int[] { R.id.spinner_txt, R.id.spinner_img }); @@ -140,14 +140,12 @@ spin.setAdapter(sa); } - voicesData = new ArrayList(); ArrayAdapter adapter = new ArrayAdapter(this, R.layout.listview_item, voicesData); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); voice.setAdapter(adapter); voice.setOnFocusChangeListener(focusser); voiceButton.setOnClickListener(voiceClicker); - fortsData = new ArrayList(); adapter = new ArrayAdapter(this, R.layout.listview_item, fortsData); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); fort.setAdapter(adapter); @@ -158,28 +156,33 @@ } public void run(){ - ArrayList> gravesData = FrontendDataUtils.getGraves(this); - ArrayList> flagsData = FrontendDataUtils.getFlags(this); - ArrayList> typesData = FrontendDataUtils.getTypes(this); - ArrayList> hatsData = FrontendDataUtils.getHats(this); - ArrayList voicesData = FrontendDataUtils.getVoices(this); - ArrayList fortsData = FrontendDataUtils.getForts(this); + final ArrayList> gravesDataNew = FrontendDataUtils.getGraves(this); + final ArrayList> flagsDataNew = FrontendDataUtils.getFlags(this); + final ArrayList> typesDataNew = FrontendDataUtils.getTypes(this); + final ArrayList> hatsDataNew = FrontendDataUtils.getHats(this); + final ArrayList voicesDataNew = FrontendDataUtils.getVoices(this); + final ArrayList fortsDataNew = FrontendDataUtils.getForts(this); - copy(this.gravesData, gravesData); - copy(this.flagsData, flagsData); - copy(this.typesData, typesData); - copy(this.hatsData, hatsData); - copy(this.voicesData, voicesData); - copy(this.fortsData, fortsData); this.runOnUiThread(new Runnable(){ public void run() { + copy(gravesData, gravesDataNew); ((SimpleAdapter)grave.getAdapter()).notifyDataSetChanged(); + + copy(flagsData, flagsDataNew); ((SimpleAdapter)flag.getAdapter()).notifyDataSetChanged(); + + copy(typesData, typesDataNew); ((SimpleAdapter)difficulty.getAdapter()).notifyDataSetChanged(); - ((SimpleAdapter)hogHat.get(0).getAdapter()).notifyDataSetChanged(); + + copy(hatsData, hatsDataNew); + ((SimpleAdapter)hogHat.get(0).getAdapter()).notifyDataSetChanged(); + + copy(voicesData, voicesDataNew); ((ArrayAdapter)fort.getAdapter()).notifyDataSetChanged(); - ((ArrayAdapter)voice.getAdapter()).notifyDataSetChanged(); + + copy(fortsData, fortsDataNew); + ((ArrayAdapter)voice.getAdapter()).notifyDataSetChanged(); } });