Feat(main): Toggle Display Mode
This commit is contained in:
		@@ -48,15 +48,15 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			|||||||
        studentProfileDBHelper = new StudentProfileDBHelper(getApplicationContext());
 | 
					        studentProfileDBHelper = new StudentProfileDBHelper(getApplicationContext());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        initAddProfileActionButton(showDialogButton);
 | 
					        initAddProfileActionButton(showDialogButton);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // surname when true, ID when false
 | 
				
			||||||
 | 
					        profileNameDisplayMode = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected void onStart() {
 | 
					    protected void onStart() {
 | 
				
			||||||
        super.onStart();
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // surname when true, ID when false
 | 
					 | 
				
			||||||
        profileNameDisplayMode = true;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        List<StudentProfile> studentProfiles = studentProfileDBHelper.getAllStudentProfile(getApplicationContext());
 | 
					        List<StudentProfile> studentProfiles = studentProfileDBHelper.getAllStudentProfile(getApplicationContext());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // by default sort by surname
 | 
					        // by default sort by surname
 | 
				
			||||||
@@ -86,6 +86,26 @@ public class MainActivity extends AppCompatActivity {
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // toggle Display mode
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onOptionsItemSelected(MenuItem item) {
 | 
				
			||||||
 | 
					        int id = item.getItemId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (id == R.id.toggle_profiles_display_mode && toggle.getTitle() == "By ID") {
 | 
				
			||||||
 | 
					            profileNameDisplayMode = false;
 | 
				
			||||||
 | 
					            onStart();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } else if (id == R.id.toggle_profiles_display_mode && toggle.getTitle() == "By Surname"){
 | 
				
			||||||
 | 
					            profileNameDisplayMode = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            onStart();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return super.onOptionsItemSelected(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    protected String[] showStudentProfileList(List<StudentProfile> studentProfiles, boolean profileNameDisplayMode){
 | 
					    protected String[] showStudentProfileList(List<StudentProfile> studentProfiles, boolean profileNameDisplayMode){
 | 
				
			||||||
        // Create a new list for sorted profiles
 | 
					        // Create a new list for sorted profiles
 | 
				
			||||||
        List<StudentProfile> sortedProfiles = new ArrayList<>(studentProfiles);
 | 
					        List<StudentProfile> sortedProfiles = new ArrayList<>(studentProfiles);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user