Search in sources :

Example 1 with CropDialogFragment

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);
        }
    });
}
Also used : SkillsDialogFragment(com.example.nftscmers.fragments.SkillsDialogFragment) ApplicantModel(com.example.nftscmers.objectmodels.ApplicantModel) SkillsFragment(com.example.nftscmers.fragments.SkillsFragment) CropDialogFragment(com.example.nftscmers.fragments.CropDialogFragment) Intent(android.content.Intent) ApplicantDb(com.example.nftscmers.db.ApplicantDb) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView) Uri(android.net.Uri) DocumentReference(com.google.firebase.firestore.DocumentReference)

Example 2 with CropDialogFragment

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);
        }
    });
}
Also used : EmployerModel(com.example.nftscmers.objectmodels.EmployerModel) CropDialogFragment(com.example.nftscmers.fragments.CropDialogFragment) Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Uri(android.net.Uri) EmployerDb(com.example.nftscmers.db.EmployerDb)

Aggregations

Intent (android.content.Intent)2 Uri (android.net.Uri)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 CropDialogFragment (com.example.nftscmers.fragments.CropDialogFragment)2 ListView (android.widget.ListView)1 ApplicantDb (com.example.nftscmers.db.ApplicantDb)1 EmployerDb (com.example.nftscmers.db.EmployerDb)1 SkillsDialogFragment (com.example.nftscmers.fragments.SkillsDialogFragment)1 SkillsFragment (com.example.nftscmers.fragments.SkillsFragment)1 ApplicantModel (com.example.nftscmers.objectmodels.ApplicantModel)1 EmployerModel (com.example.nftscmers.objectmodels.EmployerModel)1 DocumentReference (com.google.firebase.firestore.DocumentReference)1