@Override protected void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.activity_stdents); helpButton = (ImageView) findViewById(R.id.helpButton); addStudentButton = (TextView) findViewById(R.id.addStudentButton); className = (TextView) findViewById(R.id.className); studentListView = (ExpandableListView) findViewById(R.id.studentListView); sharedPreferences = AndroidUtils.getCommonSharedPrefs(getApplicationContext()); userUtils = new UserUtils(ShowClassEventCompanyUsersActivity.this); user = userUtils.getUserFromSharedPrefs(); Bundle bundle = getIntent().getExtras(); int role = bundle.getInt(AppConstants.EXTRA_USER_ROLE); if (role == 0) { throw new RuntimeException("must pass role!"); } else { userRole = UserRole.valueOf(role); setRoleBasedProperties(userRole); } int index = bundle.getInt(AppConstants.EXTRA_SELECTED_INDEX, -1); if (index == -1) { throw new RuntimeException("must pass EXTRA_SELECTED_INDEX!"); } else { classEventCompany = user.getClassEventCompanyArrayList().get(index); } setAdapter(); studentListView.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {} }); studentListView.setOnGroupExpandListener( new ExpandableListView.OnGroupExpandListener() { int previousGroup = -1; @Override public void onGroupExpand(int groupPosition) { if (groupPosition != previousGroup) studentListView.collapseGroup(previousGroup); previousGroup = groupPosition; } }); addStudentButton.setOnClickListener(this); helpButton.setOnClickListener(this); className.setText(classEventCompany.getName()); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.helpButton: makeToast("Show help"); break; case R.id.addStudentButton: Bundle bundle = new Bundle(); bundle.putInt(AppConstants.EXTRA_USER_ROLE, UserRole.Manager.getRole()); bundle.putString(InviteUser.EXTRA_CLASS_CODE, classEventCompany.getUniqueCode()); bundle.putString(InviteUser.EXTRA_CLASS_ID, classEventCompany.getId()); bundle.putBoolean(InviteUser.EXTRA_IS_FIRST_TIME, false); Intent addStudentIntent = new Intent(ShowClassEventCompanyUsersActivity.this, InviteUser.class); addStudentIntent.putExtras(bundle); startActivityForResult(addStudentIntent, REQUEST_ADD_STUDENT); break; } }