Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GroupsListActivity extends Activity {
- private static final int REQUEST = 1;
- String loggedUserId = Model.getInstance().getLoggedUserId();
- ListView list;
- List<Group> data;
- MyAdapter adapter;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Set layout for this activity
- setContentView(R.layout.groups_list);
- // Show actionbar in this activity
- getActionBar().show();
- if(loggedUserId != null)
- Log.d("TAG", "My Groups for user ID: " + loggedUserId);
- // Connect between button to layout id
- list = (ListView) findViewById(R.id.my_group_list);
- // Setting adapter and creating group list
- if(loggedUserId != null) {
- Model.getInstance().getAllGroupsByUserId(loggedUserId, new Model.groupListReturnedListener() {
- @Override
- public void groupListReturned(List<Group> groupList) {
- data = groupList;
- adapter = new MyAdapter();
- list.setAdapter(adapter);
- Collections.sort(data, Group.Comparators.NAME); //Sort array
- }
- });
- }
- }
- private void onSearch() {
- Log.d("TAG", "Search button was pressed");
- Intent i = new
- Intent(getApplicationContext(),
- SearchActivity.class);
- startActivityForResult(i, REQUEST);
- overridePendingTransition(R.animator.slide_out_right, R.animator.slide_in_right);
- }
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == REQUEST) {
- if(resultCode == RESULT_OK) {
- adapter.notifyDataSetChanged();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement