author | nemo |
Thu, 12 Mar 2020 15:07:32 -0400 | |
changeset 15571 | 608b5de819a5 |
parent 10017 | de822cd3df3a |
permissions | -rw-r--r-- |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
1 |
/* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
2 |
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com> |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
4 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
6 |
* modify it under the terms of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
7 |
* as published by the Free Software Foundation; either version 2 |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
8 |
* of the License, or (at your option) any later version. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
9 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
13 |
* GNU General Public License for more details. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
14 |
* |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
18 |
*/ |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
19 |
|
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
20 |
package org.hedgewars.hedgeroid; |
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
|
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
22 |
import org.hedgewars.hedgeroid.R; |
7508
763d3961400b
Hedgeroid: Frantic scrabbling toward the deadline
Medo <smaxein@googlemail.com>
parents:
7476
diff
changeset
|
23 |
import org.hedgewars.hedgeroid.netplay.Netplay; |
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
24 |
|
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
25 |
import android.os.Bundle; |
7342
0e29eec2df5c
Hedgeroid: Got the roomlist working... more or less.
Medo <smaxein@googlemail.com>
parents:
7330
diff
changeset
|
26 |
import android.os.CountDownTimer; |
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
import android.support.v4.app.ListFragment; |
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
import android.view.LayoutInflater; |
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
29 |
import android.view.View; |
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
30 |
import android.view.ViewGroup; |
7358
57a508884052
Hedgeroid: Major overhaul of the network connection code. Now it is threaded and
Medo <smaxein@googlemail.com>
parents:
7355
diff
changeset
|
31 |
import android.widget.AdapterView; |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
32 |
import android.widget.AdapterView.OnItemClickListener; |
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
33 |
|
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
34 |
/** |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
35 |
* Displays the list of all rooms in the lobby |
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
36 |
*/ |
7352
641f11cdd319
Hedgeroid: Reworked player and room lists, added menus, added playername query
Medo <smaxein@googlemail.com>
parents:
7349
diff
changeset
|
37 |
public class RoomlistFragment extends ListFragment implements OnItemClickListener { |
10017 | 38 |
private static final int AUTO_REFRESH_INTERVAL_MS = 15000; |
39 |
||
40 |
private Netplay netplay; |
|
41 |
private RoomlistAdapter adapter; |
|
42 |
private CountDownTimer autoRefreshTimer = new CountDownTimer(Long.MAX_VALUE, AUTO_REFRESH_INTERVAL_MS) { |
|
43 |
@Override |
|
44 |
public void onTick(long millisUntilFinished) { |
|
45 |
netplay.sendRoomlistRequest(); |
|
46 |
} |
|
47 |
||
48 |
@Override |
|
49 |
public void onFinish() { } |
|
50 |
}; |
|
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
51 |
|
10017 | 52 |
@Override |
53 |
public void onCreate(Bundle savedInstanceState) { |
|
54 |
super.onCreate(savedInstanceState); |
|
55 |
netplay = Netplay.getAppInstance(getActivity().getApplicationContext()); |
|
56 |
adapter = new RoomlistAdapter(getActivity()); |
|
57 |
adapter.setSource(netplay.roomList); |
|
58 |
setListAdapter(adapter); |
|
59 |
} |
|
60 |
||
61 |
@Override |
|
62 |
public View onCreateView(LayoutInflater inflater, ViewGroup container, |
|
63 |
Bundle savedInstanceState) { |
|
64 |
return inflater.inflate(R.layout.fragment_roomlist, container, false); |
|
65 |
} |
|
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
66 |
|
10017 | 67 |
@Override |
68 |
public void onActivityCreated(Bundle savedInstanceState) { |
|
69 |
super.onActivityCreated(savedInstanceState); |
|
70 |
getListView().setOnItemClickListener(this); |
|
71 |
} |
|
72 |
||
73 |
@Override |
|
74 |
public void onResume() { |
|
75 |
super.onResume(); |
|
76 |
autoRefreshTimer.start(); |
|
77 |
} |
|
78 |
||
79 |
@Override |
|
80 |
public void onPause() { |
|
81 |
super.onPause(); |
|
82 |
autoRefreshTimer.cancel(); |
|
83 |
} |
|
84 |
||
85 |
@Override |
|
86 |
public void onDestroy() { |
|
87 |
super.onDestroy(); |
|
88 |
adapter.invalidate(); |
|
89 |
} |
|
90 |
||
91 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
|
92 |
netplay.sendJoinRoom(adapter.getItem(position).room.name); |
|
93 |
} |
|
7330
867e4fda496e
Hedgeroid: Layout experiments for the lobby page
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
94 |
} |