1
1
2
2
package ndejaco .pollgeo ;
3
3
4
- import android .app .Activity ;
5
- import android .app .ListActivity ;
4
+
6
5
import android .os .Bundle ;
7
6
import android .content .Intent ;
8
7
import android .support .v4 .widget .DrawerLayout ;
9
- import android .util .Log ;
8
+ import android .support .v7 .app .ActionBar ;
9
+ import android .support .v7 .app .AppCompatActivity ;
10
+ import android .support .v7 .widget .Toolbar ;
11
+ import android .view .Gravity ;
12
+ import android .view .Menu ;
13
+ import android .view .MenuItem ;
10
14
import android .view .View ;
11
15
import android .widget .AdapterView ;
12
16
import android .widget .Button ;
13
17
import android .widget .ListView ;
14
- import android .widget .RelativeLayout ;
15
- import android .widget .TextView ;
16
- import android .widget .Toast ;
18
+
17
19
18
20
import com .baoyz .widget .PullRefreshLayout ;
19
21
import com .facebook .login .widget .ProfilePictureView ;
34
36
* GroupActivity is the activity that will handle Group Poll functionality
35
37
* It will display group polls are in and the option to make a group poll
36
38
*/
37
- public class GroupActivity extends ListActivity {
39
+ public class GroupActivity extends AppCompatActivity {
38
40
39
41
// TAG used for debugging
40
42
private static final String TAG = GroupActivity .class .getSimpleName ();
@@ -47,33 +49,21 @@ public class GroupActivity extends ListActivity {
47
49
private GroupViewAdapter mGroupViewAdapter ;
48
50
private ProfilePictureView fbPhoto ;
49
51
private ListView groupList ;
52
+ private Toolbar toolBar ;
50
53
51
54
52
55
@ Override
53
56
protected void onCreate (Bundle savedInstanceState ) {
54
57
super .onCreate (savedInstanceState );
55
58
setContentView (R .layout .activity_group_home );
56
59
57
- create_button = (Button ) findViewById (R .id .makeGroup );
58
- create_button .setOnClickListener (new View .OnClickListener () {
59
- @ Override
60
- public void onClick (View v ) {
61
- navigateToMakeGroup ();
62
- }
63
- });
64
60
65
- logOutButton = (Button ) findViewById (R .id .logOutButton );
66
- logOutButton .setOnClickListener (new View .OnClickListener () {
67
- @ Override
68
- public void onClick (View v ) {
69
- navigateToLogin ();
70
- }
71
- });
72
61
73
62
mDrawerLayout = (DrawerLayout ) findViewById (R .id .drawer_layout );
74
63
75
64
mGroupViewAdapter = new GroupViewAdapter (this , new ArrayList <Group >());
76
- setListAdapter (mGroupViewAdapter );
65
+ groupList = (ListView ) findViewById (R .id .list );
66
+ groupList .setAdapter (mGroupViewAdapter );
77
67
78
68
swipeLayout = (PullRefreshLayout ) findViewById (R .id .swipe_container );
79
69
swipeLayout .setOnRefreshListener (new PullRefreshLayout .OnRefreshListener () {
@@ -96,7 +86,6 @@ public void onRefresh() {
96
86
}
97
87
}
98
88
99
- groupList = getListView ();
100
89
groupList .setOnItemClickListener (new AdapterView .OnItemClickListener () {
101
90
@ Override
102
91
public void onItemClick (AdapterView <?> parent , View view , int position , long id ) {
@@ -111,6 +100,18 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
111
100
mSections = getResources ().getStringArray (R .array .sections_array );
112
101
mDrawerList .setAdapter (new DrawerAdapter (this , mSections ));
113
102
103
+ toolBar = (Toolbar ) findViewById (R .id .toolbar );
104
+ setSupportActionBar (toolBar );
105
+
106
+ ActionBar actionBar = getSupportActionBar ();
107
+
108
+
109
+ actionBar .setDisplayHomeAsUpEnabled (true );
110
+ actionBar .setHomeButtonEnabled (true );
111
+ actionBar .setHomeAsUpIndicator (R .drawable .ic_drawer );
112
+ actionBar .setDisplayShowTitleEnabled (true );
113
+ actionBar .setTitle ("Pollgeo" );
114
+
114
115
updateData ();
115
116
116
117
@@ -148,8 +149,6 @@ public void done(List<Group> objects, ParseException e) {
148
149
*/
149
150
private void navigateToMakeGroup () {
150
151
Intent intent = new Intent (this , MakeGroupActivity .class );
151
- intent .addFlags (Intent .FLAG_ACTIVITY_NEW_TASK );
152
- intent .addFlags (Intent .FLAG_ACTIVITY_CLEAR_TASK );
153
152
startActivity (intent );
154
153
}
155
154
@@ -160,4 +159,34 @@ private void navigateToLogin() {
160
159
startActivity (intent );
161
160
}
162
161
162
+ @ Override
163
+ public boolean onCreateOptionsMenu (Menu menu ) {
164
+ // Inflate the menu; this adds items to the action bar if it is present.
165
+ getMenuInflater ().inflate (R .menu .menu_group_make , menu );
166
+ return true ;
167
+ }
168
+
169
+ @ Override
170
+ public boolean onOptionsItemSelected (MenuItem item ) {
171
+ // Handle action bar item clicks here. The action bar will
172
+ // automatically handle clicks on the Home/Up button, so long
173
+ // as you specify a parent activity in AndroidManifest.xml.
174
+ int id = item .getItemId ();
175
+
176
+ //noinspection SimplifiableIfStatement
177
+ if (id == R .id .action_settings ) {
178
+ return true ;
179
+ }
180
+
181
+ if (id == android .R .id .home ) {
182
+ mDrawerLayout .openDrawer (Gravity .LEFT );
183
+ }
184
+
185
+ if (id == R .id .create_group ) {
186
+ navigateToMakeGroup ();
187
+ }
188
+
189
+ return super .onOptionsItemSelected (item );
190
+ }
191
+
163
192
}
0 commit comments