Advertisement
Guest User

Untitled

a guest
May 27th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public class GroupsListActivity extends Activity {
  2.  
  3. private static final int REQUEST = 1;
  4.  
  5. String loggedUserId = Model.getInstance().getLoggedUserId();
  6. ListView list;
  7. List<Group> data;
  8. MyAdapter adapter;
  9.  
  10. @Override
  11. protected void onCreate(Bundle savedInstanceState) {
  12. super.onCreate(savedInstanceState);
  13.  
  14. // Set layout for this activity
  15. setContentView(R.layout.groups_list);
  16.  
  17. // Show actionbar in this activity
  18. getActionBar().show();
  19.  
  20. if(loggedUserId != null)
  21. Log.d("TAG", "My Groups for user ID: " + loggedUserId);
  22.  
  23. // Connect between button to layout id
  24. list = (ListView) findViewById(R.id.my_group_list);
  25.  
  26. // Setting adapter and creating group list
  27. if(loggedUserId != null) {
  28. Model.getInstance().getAllGroupsByUserId(loggedUserId, new Model.groupListReturnedListener() {
  29. @Override
  30. public void groupListReturned(List<Group> groupList) {
  31. data = groupList;
  32. adapter = new MyAdapter();
  33. list.setAdapter(adapter);
  34. Collections.sort(data, Group.Comparators.NAME); //Sort array
  35. }
  36. });
  37. }
  38. }
  39.  
  40.  
  41. private void onSearch() {
  42. Log.d("TAG", "Search button was pressed");
  43. Intent i = new
  44. Intent(getApplicationContext(),
  45. SearchActivity.class);
  46.  
  47. startActivityForResult(i, REQUEST);
  48. overridePendingTransition(R.animator.slide_out_right, R.animator.slide_in_right);
  49. }
  50.  
  51.  
  52.  
  53. @Override
  54. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  55. if (requestCode == REQUEST) {
  56. if(resultCode == RESULT_OK) {
  57. adapter.notifyDataSetChanged();
  58. }
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement