author | Medo <smaxein@googlemail.com> |
Sat, 18 Aug 2012 13:39:05 +0200 | |
changeset 7558 | 983ff426f91e |
parent 7508 | 763d3961400b |
child 7568 | 75ba91f14ed5 |
permissions | -rw-r--r-- |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
1 |
package org.hedgewars.hedgeroid; |
7449 | 2 |
|
3 |
import org.hedgewars.hedgeroid.R; |
|
7485 | 4 |
import org.hedgewars.hedgeroid.Datastructures.Team; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
5 |
import org.hedgewars.hedgeroid.NetplayStateFragment.NetplayStateListener; |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
6 |
import org.hedgewars.hedgeroid.netplay.Netplay; |
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
7 |
import org.hedgewars.hedgeroid.netplay.Netplay.State; |
7449 | 8 |
|
9 |
import android.os.Bundle; |
|
10 |
import android.support.v4.app.FragmentActivity; |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
11 |
import android.support.v4.app.FragmentTransaction; |
7449 | 12 |
import android.widget.TabHost; |
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
13 |
import android.widget.Toast; |
7449 | 14 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
15 |
public class RoomActivity extends FragmentActivity implements NetplayStateListener, TeamAddDialog.Listener, RoomStateManager.Provider { |
7449 | 16 |
private TabHost tabHost; |
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
17 |
private Netplay netplay; |
7449 | 18 |
|
19 |
@Override |
|
20 |
protected void onCreate(Bundle icicle) { |
|
21 |
super.onCreate(icicle); |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
22 |
netplay = Netplay.getAppInstance(getApplicationContext()); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
23 |
|
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
24 |
setContentView(R.layout.activity_netroom); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
25 |
ChatFragment chatFragment = (ChatFragment)getSupportFragmentManager().findFragmentById(R.id.chatFragment); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
26 |
chatFragment.setInRoom(true); |
7449 | 27 |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
28 |
FragmentTransaction trans = getSupportFragmentManager().beginTransaction(); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
29 |
trans.add(new NetplayStateFragment(), "netplayFragment"); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
30 |
trans.commit(); |
7449 | 31 |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
32 |
/*tabHost = (TabHost)findViewById(android.R.id.tabhost); |
7449 | 33 |
if(tabHost != null) { |
34 |
tabHost.setup(); |
|
35 |
tabHost.getTabWidget().setOrientation(LinearLayout.VERTICAL); |
|
36 |
||
37 |
//tabHost.addTab(tabHost.newTabSpec("chat").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_chat, getResources().getDrawable(R.drawable.edit))).setContent(R.id.chatFragment)); |
|
38 |
//tabHost.addTab(tabHost.newTabSpec("players").setIndicator(createIndicatorView(tabHost, R.string.lobby_tab_players, getResources().getDrawable(R.drawable.human))).setContent(R.id.playerListFragment)); |
|
39 |
||
40 |
if (icicle != null) { |
|
41 |
tabHost.setCurrentTabByTag(icicle.getString("currentTab")); |
|
42 |
} |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
43 |
}*/ |
7449 | 44 |
} |
45 |
||
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
46 |
@Override |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
47 |
public void onBackPressed() { |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
48 |
netplay.sendLeaveRoom(null); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
49 |
} |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
50 |
|
7449 | 51 |
@Override |
52 |
protected void onSaveInstanceState(Bundle icicle) { |
|
53 |
super.onSaveInstanceState(icicle); |
|
54 |
if(tabHost != null) { |
|
55 |
icicle.putString("currentTab", tabHost.getCurrentTabTag()); |
|
56 |
} |
|
57 |
} |
|
7461
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
58 |
|
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
59 |
public void onNetplayStateChanged(State newState) { |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
60 |
switch(newState) { |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
61 |
case NOT_CONNECTED: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
62 |
case CONNECTING: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
63 |
case LOBBY: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
64 |
finish(); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
65 |
break; |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
66 |
case ROOM: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
67 |
// Do nothing |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
68 |
break; |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
69 |
case INGAME: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
70 |
//startActivity(new Intent(getApplicationContext(), RoomActivity.class)); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
71 |
Toast.makeText(getApplicationContext(), R.string.not_implemented_yet, Toast.LENGTH_SHORT).show(); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
72 |
break; |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
73 |
default: |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
74 |
throw new IllegalStateException("Unknown connection state: "+newState); |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
75 |
} |
38acbfdb484f
Hedgeroid: Started to implement RoomActivity
Medo <smaxein@googlemail.com>
parents:
7449
diff
changeset
|
76 |
} |
7485 | 77 |
|
78 |
public void onTeamAddDialogSubmitted(Team newTeam) { |
|
79 |
netplay.sendAddTeam(newTeam); |
|
80 |
} |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
81 |
|
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
82 |
public RoomStateManager getRoomStateManager() { |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
83 |
return netplay.getRoomStateManager(); |
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7485
diff
changeset
|
84 |
} |
7449 | 85 |
} |