예제 #1
0
 @Override
 public boolean onNavigationItemSelected(MenuItem item) {
   int id = item.getItemId();
   if (currentNavigationId != id) {
     switch (id) {
       case R.id.drawerMenuSettings:
         getSupportFragmentManager()
             .beginTransaction()
             .replace(R.id.relativeLayoutFragmentContainer, fragments.get(id))
             .commit();
         toolbar.setTitle(getString(R.string.settings));
         break;
       case R.id.drawerMenuExit:
         DBHelper.getInstance(this).close();
         stopService(new Intent(getApplicationContext(), LANChatService.class));
         finishAffinity();
         break;
       default:
         BaseFragment baseFragment = (BaseFragment) fragments.get(id);
         toolbar.setTitle(baseFragment.getTitle());
         getSupportFragmentManager()
             .beginTransaction()
             .replace(R.id.relativeLayoutFragmentContainer, baseFragment)
             .commit();
     }
     currentNavigationId = id;
   }
   drawerLayout.closeDrawer(GravityCompat.START);
   return true;
 }
예제 #2
0
  private void initAdapters() {
    DBHelper dbHelper = DBHelper.getInstance(this);

    roomsAdapter = new RoomsAdapter(getApplicationContext(), dbHelper.getRooms());
    chatAdapter = new ChatAdapter(this, dbHelper.getPublicMessages());
    peopleAdapter = new PeopleAdapter(this);

    List<PeopleData> people = dbHelper.getPeople();
    for (PeopleData peopleData : people) {
      peopleData.setProfilePicture(
          StorageHelper.loadProfilePicture(
              getApplicationContext(), peopleData.getUid() + "_profile_picture.jpg"));
    }
    Iterator<PeopleData> iterator = people.iterator();
    while (iterator.hasNext()) {
      PeopleData peopleData = iterator.next();
      if (peopleData.getUid().equals(Utils.getAndroidID(getApplicationContext()))) {
        iterator.remove();
        break;
      }
    }
    peopleAdapter.addAll(people);
  }