use of com.example.nftscmers.fragments.YesNoDialogFragment in project HackFest2022-Pretzel by chuanshaof.
the class ProfileActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_applicant_profile);
title = findViewById(R.id.applicant_title);
back = findViewById(R.id.applicant_back_arrow);
editProfile = findViewById(R.id.applicant_edit_profile);
profilePic = findViewById(R.id.applicant_profile_pic);
name = findViewById(R.id.applicant_name);
email = findViewById(R.id.applicant_email);
about = findViewById(R.id.applicant_about);
linkedIn = findViewById(R.id.applicant_linkedIn);
logout = findViewById(R.id.button_logout);
// Loading of previous applicant data
new ApplicantDb(ProfileActivity.this, new ApplicantDb.OnApplicantModel() {
@Override
public void onResult(ApplicantModel applicantModel) {
Log.d(TAG, "onResult: " + applicantModel);
applicant = applicantModel;
Utils.loadImage(profilePic, applicant.getImage());
Utils.setValid(name, applicant.getName());
Utils.setValid(about, applicant.getAbout());
Utils.setValid(linkedIn, applicant.getLinkedIn());
Utils.setValid(email, applicant.getEmail());
SkillsFragment skillsFragment = new SkillsFragment(applicant.getSkills());
getSupportFragmentManager().beginTransaction().replace(R.id.applicant_skills, skillsFragment).commit();
}
}).getApplicantModel(getIntent().getStringExtra(ProfileActivity.TAG));
if (!getIntent().getStringExtra(ProfileActivity.TAG).equals(LoggedInUser.getInstance().getEmail())) {
Utils.disableButton(editProfile);
Utils.disableButton(logout);
}
editProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(ProfileActivity.this, EditProfileActivity.class);
startActivity(intent);
}
});
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new YesNoDialogFragment("Confirm Logout?", new YesNoDialogFragment.OnClickListener() {
@Override
public void onResult(boolean bool) {
if (bool == true) {
LoggedInUser.getInstance().setUser(null, null, null);
Intent intent = new Intent(ProfileActivity.this, LoginActivity.class);
startActivity(intent);
}
}
}).show(getSupportFragmentManager(), TAG);
}
});
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
if (LoggedInUser.getInstance().getAccountType() == Globals.APPLICANT) {
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(ProfileActivity.this, ScrollJobActivity.class);
startActivity(intent);
}
});
// Set Home selected
bottomNavigationView.setSelectedItemId(R.id.profile);
// Perform item selected listener
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()) {
case R.id.history:
startActivity(new Intent(getApplicationContext(), ApplicationHistoryActivity.class));
overridePendingTransition(0, 0);
return true;
case R.id.home:
startActivity(new Intent(getApplicationContext(), ScrollJobActivity.class));
overridePendingTransition(0, 0);
return true;
case R.id.profile:
return true;
}
return false;
}
});
} else {
title.setText(getString(R.string.applicant_profile));
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(ProfileActivity.this, ScrollApplicationActivity.class);
startActivity(intent);
}
});
Utils.disableButton(bottomNavigationView);
}
}
use of com.example.nftscmers.fragments.YesNoDialogFragment in project HackFest2022-Pretzel by chuanshaof.
the class ProfileActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_employer_profile);
back = findViewById(R.id.employer_back_arrow);
editProfile = findViewById(R.id.employer_edit_profile);
profilePic = findViewById(R.id.employer_profile_pic);
name = findViewById(R.id.employer_name);
email = findViewById(R.id.employer_email);
about = findViewById(R.id.employer_about);
linkedIn = findViewById(R.id.employer_linkedIn);
logout = findViewById(R.id.button_logout);
// Loading of previous employer data
new EmployerDb(ProfileActivity.this, new EmployerDb.OnEmployerModel() {
@Override
public void onResult(EmployerModel employerModel) {
Log.d(TAG, "onResult: " + employerModel);
employer = employerModel;
Utils.loadImage(profilePic, employer.getImage());
Utils.setValid(name, employer.getName());
Utils.setValid(about, employer.getAbout());
Utils.setValid(linkedIn, employer.getWebsite());
Utils.setValid(email, employer.getEmail());
}
}).getEmployerModel(getIntent().getStringExtra(TAG));
if (!getIntent().getStringExtra(TAG).equals(LoggedInUser.getInstance().getEmail())) {
Utils.disableButton(editProfile);
Utils.disableButton(logout);
}
editProfile.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(ProfileActivity.this, EditProfileActivity.class);
startActivity(intent);
}
});
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new YesNoDialogFragment("Confirm Logout?", new YesNoDialogFragment.OnClickListener() {
@Override
public void onResult(boolean bool) {
if (bool == true) {
LoggedInUser.getInstance().setUser(null, null, null);
Intent intent = new Intent(ProfileActivity.this, LoginActivity.class);
startActivity(intent);
}
}
}).show(getSupportFragmentManager(), TAG);
}
});
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
if (LoggedInUser.getInstance().getAccountType() == Globals.EMPLOYER) {
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(com.example.nftscmers.employeractivities.ProfileActivity.this, ScrollApplicationActivity.class);
startActivity(intent);
}
});
// Set Home selected
bottomNavigationView.setSelectedItemId(R.id.profile);
// Perform item selected listener
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()) {
case R.id.history:
startActivity(new Intent(getApplicationContext(), JobHistoryActivity.class));
overridePendingTransition(0, 0);
return true;
case R.id.home:
startActivity(new Intent(getApplicationContext(), ScrollApplicationActivity.class));
overridePendingTransition(0, 0);
return true;
case R.id.create:
startActivity(new Intent(getApplicationContext(), EditJobActivity.class));
overridePendingTransition(0, 0);
return true;
case R.id.profile:
return true;
}
return false;
}
});
} else {
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(com.example.nftscmers.employeractivities.ProfileActivity.this, ScrollJobActivity.class);
startActivity(intent);
}
});
Utils.disableButton(bottomNavigationView);
}
}
Aggregations