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