여러가지 방법이 있을 수 있을 듯 한데, 가장 쉽게 해볼 수 있는 건 FindIdPw 에 ID를 찾는지 Password를 찾는지 구분자를 넘기는 겁니다.
Intent intent = new Intent(getApplicationContext(), findIdPw.class);
startActivity(intent);
아무튼 위의 중복된 부분의 별도의 메소드로 만드세요.
// 더 적절한 이름이 있다면 그걸 사용하세요.
private void navigateToFindId() {
navigateToFindIdPw(ForgotLoginType.ID);
}
private void navigateToFindPassword() {
navigateToFindIdPw(ForgotLoginType.PASSWORD);
}
private void navigateToFindIdPw(FindIdPwdType findIdPwdType) {
Intent intent = new Intent(getApplicationContext(), findIdPw.class);
intent.putSerializable(FindPw.EXTRA_FIND_TYPE, findIdPwdType);
startActivity(intent);
}
public enum FindIdPwdType {
ID,
PASSWORD
}
다른 방법은 ID 찾기 화면과 Password 찾기 화면을 분리하고 로직부분을 공통된 부분을 재사용하는 겁니다. 제 생각으로는 두 화면의 구성이 거의 비슷할 것으로 보이네요. 그런데 API호출같은 비지니스 로직이 다르다면 화면을 분리하시는게 맞습니다. 이 경우는 레이아웃만 재활용하는 것이 맞다고 보여지네요.