project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/LobbyActivity.java
equal
deleted
inserted
replaced
46 tabHost = (TabHost)findViewById(android.R.id.tabhost); |
46 tabHost = (TabHost)findViewById(android.R.id.tabhost); |
47 if(tabHost != null) { |
47 if(tabHost != null) { |
48 tabHost.setup(); |
48 tabHost.setup(); |
49 tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL); |
49 tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL); |
50 |
50 |
51 tabHost.addTab(tabHost.newTabSpec("rooms").setIndicator(createIndicatorView(tabHost, "Rooms", null)).setContent(R.id.roomListFragment)); |
51 tabHost.addTab(tabHost.newTabSpec("rooms").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_rooms, getResources().getDrawable(R.drawable.roomlist_ingame))).setContent(R.id.roomListFragment)); |
52 tabHost.addTab(tabHost.newTabSpec("chat").setIndicator(createIndicatorView(tabHost, "Chat", null)).setContent(R.id.chatFragment)); |
52 tabHost.addTab(tabHost.newTabSpec("chat").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_chat, getResources().getDrawable(R.drawable.edit))).setContent(R.id.chatFragment)); |
53 tabHost.addTab(tabHost.newTabSpec("players").setIndicator(createIndicatorView(tabHost, "Players", null)).setContent(R.id.playerListFragment)); |
53 tabHost.addTab(tabHost.newTabSpec("players").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_players, getResources().getDrawable(R.drawable.human))).setContent(R.id.playerListFragment)); |
54 |
54 |
55 if (icicle != null) { |
55 if (icicle != null) { |
56 tabHost.setCurrentTabByTag(icicle.getString("currentTab")); |
56 tabHost.setCurrentTabByTag(icicle.getString("currentTab")); |
57 } |
57 } |
58 } |
58 } |
62 protected void onDestroy() { |
62 protected void onDestroy() { |
63 super.onDestroy(); |
63 super.onDestroy(); |
64 LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(disconnectReceiver); |
64 LocalBroadcastManager.getInstance(getApplicationContext()).unregisterReceiver(disconnectReceiver); |
65 } |
65 } |
66 |
66 |
67 private View createIndicatorView(TabHost tabHost, CharSequence label, Drawable icon) { |
67 private View createIndicatorView(TabHost tabHost, int label, Drawable icon) { |
68 LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
68 LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
69 |
69 |
70 View tabIndicator = inflater.inflate(R.layout.tab_indicator, |
70 View tabIndicator = inflater.inflate(R.layout.tab_indicator, |
71 tabHost.getTabWidget(), // tab widget is the parent |
71 tabHost.getTabWidget(), // tab widget is the parent |
72 false); // no inflate params |
72 false); // no inflate params |
120 @Override |
120 @Override |
121 public void onBackPressed() { |
121 public void onBackPressed() { |
122 netconn.disconnect(); |
122 netconn.disconnect(); |
123 super.onBackPressed(); |
123 super.onBackPressed(); |
124 } |
124 } |
125 |
|
126 /*@Override |
|
127 protected void onCreate(Bundle arg0) { |
|
128 super.onCreate(arg0); |
|
129 setContentView(R.layout.activity_lobby); |
|
130 ViewPager pager = (ViewPager)findViewById(R.id.pager); |
|
131 if(pager != null) { |
|
132 pager.setAdapter(new Adapter(getSupportFragmentManager())); |
|
133 } |
|
134 } |
|
135 |
|
136 private static class Adapter extends FragmentPagerAdapter { |
|
137 public Adapter(FragmentManager mgr) { |
|
138 super(mgr); |
|
139 } |
|
140 |
|
141 @Override |
|
142 public int getCount() { |
|
143 return 3; |
|
144 } |
|
145 |
|
146 @Override |
|
147 public Fragment getItem(int arg0) { |
|
148 switch(arg0) { |
|
149 case 0: return new RoomlistFragment(); |
|
150 case 1: return new LobbyChatFragment(); |
|
151 case 2: return new PlayerlistFragment(); |
|
152 default: throw new IndexOutOfBoundsException(); |
|
153 } |
|
154 } |
|
155 }*/ |
|
156 |
125 |
157 @Override |
126 @Override |
158 protected void onSaveInstanceState(Bundle icicle) { |
127 protected void onSaveInstanceState(Bundle icicle) { |
159 super.onSaveInstanceState(icicle); |
128 super.onSaveInstanceState(icicle); |
160 if(tabHost != null) { |
129 if(tabHost != null) { |