use of com.example.nftscmers.fragments.CropDialogFragment in project HackFest2022-Pretzel by chuanshaof.
the class EditProfileActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_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);
skills = findViewById(R.id.applicant_skills);
confirm = findViewById(R.id.applicant_edit_confirm);
Utils.uneditableField(name);
Utils.uneditableField(email);
// Loading of previous applicant data
new ApplicantDb(EditProfileActivity.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_list, skillsFragment).commit();
}
}).getApplicantModel(LoggedInUser.getInstance().getEmail());
// When user clicks on skills
skills.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new SkillsDialogFragment(applicant.getSkills(), new SkillsDialogFragment.onConfirmListener() {
@Override
public void onResult(ArrayList<DocumentReference> skillsList) {
Log.d(TAG, "onResult: " + skillsList);
applicant.setSkills(skillsList);
SkillsFragment skillsFragment = new SkillsFragment(applicant.getSkills());
getSupportFragmentManager().beginTransaction().replace(R.id.applicant_skills_list, skillsFragment).commit();
}
}).show(getSupportFragmentManager(), TAG);
}
});
profilePic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "onClick: test");
new CropDialogFragment(new CropDialogFragment.OnCropListener() {
@Override
public void onResult(Uri uri) {
new ApplicantDb(EditProfileActivity.this, new ApplicantDb.OnApplicantUploadSuccess() {
@Override
protected void onResult(String string) {
Utils.loadImage(profilePic, string);
applicant.setImage(string);
}
}).updateProfilePicture(uri, applicant.getEmail());
}
}).show(getSupportFragmentManager(), TAG);
}
});
confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (Utils.invalidData(name, about)) {
return;
}
applicant.setName(name.getText().toString());
applicant.setAbout(about.getText().toString());
applicant.setLinkedIn(linkedIn.getText().toString());
new ApplicantDb(EditProfileActivity.this, new ApplicantDb.OnApplicantUploadSuccess() {
@Override
protected void onResult() {
Intent intent = new Intent(EditProfileActivity.this, ProfileActivity.class);
intent.putExtra(ProfileActivity.TAG, LoggedInUser.getInstance().getEmail());
startActivity(intent);
}
}, new ApplicantDb.OnApplicantUploadFailure() {
@Override
public void onResult() {
Utils.fireStoreError(EditProfileActivity.this, TAG);
}
}).updateProfile(applicant);
}
});
}
use of com.example.nftscmers.fragments.CropDialogFragment in project HackFest2022-Pretzel by chuanshaof.
the class EditProfileActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_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);
website = findViewById(R.id.employer_website);
confirm = findViewById(R.id.employer_edit_confirm);
Utils.uneditableField(name);
Utils.uneditableField(email);
// Loading of previous employer data
new EmployerDb(EditProfileActivity.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(website, employer.getWebsite());
Utils.setValid(email, employer.getEmail());
}
}).getEmployerModel(LoggedInUser.getInstance().getEmail());
profilePic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "onClick: test");
new CropDialogFragment(new CropDialogFragment.OnCropListener() {
@Override
public void onResult(Uri uri) {
new EmployerDb(EditProfileActivity.this, new EmployerDb.OnEmployerUploadSuccess() {
@Override
protected void onResult(String string) {
Utils.loadImage(profilePic, string);
employer.setImage(string);
}
}).updateProfilePicture(uri, employer.getEmail());
}
}).show(getSupportFragmentManager(), TAG);
}
});
confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (Utils.invalidData(name, about) || employer.getImage() == null) {
return;
}
employer.setName(name.getText().toString());
employer.setAbout(about.getText().toString());
employer.setWebsite(website.getText().toString());
new EmployerDb(EditProfileActivity.this, new EmployerDb.OnEmployerUploadSuccess() {
@Override
protected void onResult() {
Intent intent = new Intent(EditProfileActivity.this, ProfileActivity.class);
intent.putExtra(ProfileActivity.TAG, LoggedInUser.getInstance().getEmail());
startActivity(intent);
}
}, new EmployerDb.OnEmployerUploadFailure() {
@Override
public void onResult() {
Utils.fireStoreError(EditProfileActivity.this, TAG);
}
}).updateProfile(employer);
}
});
}
Aggregations