Search in sources :

Example 1 with SkillsDialogFragment

use of com.example.nftscmers.fragments.SkillsDialogFragment in project HackFest2022-Pretzel by chuanshaof.

the class EditJobActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_employer_edit_job);
    backButton = findViewById(R.id.back_button);
    position = findViewById(R.id.edit_job_position);
    description = findViewById(R.id.edit_job_description);
    deadline = findViewById(R.id.edit_job_deadline);
    location = findViewById(R.id.edit_job_location);
    skills = findViewById(R.id.edit_job_skills);
    confirm = findViewById(R.id.edit_job_confirm);
    if (getIntent().getStringExtra(ViewJobActivity.TAG) != null) {
        // Loading of previous job data
        new JobDb(EditJobActivity.this, new JobDb.OnJobModel() {

            @Override
            public void onResult(JobModel jobModel) {
                Log.d(TAG, "onResult: " + jobModel);
                job = jobModel;
                Utils.setValid(position, job.getPosition());
                Utils.setValid(description, job.getDescription());
                Utils.setValid(deadline, Globals.DATEFORMAT.format(job.getDeadline()));
                Utils.setValid(location, job.getLocation());
                position.setEnabled(false);
                Utils.uneditableField(position);
                SkillsFragment skillsFragment = new SkillsFragment(job.getSkills());
                getSupportFragmentManager().beginTransaction().replace(R.id.applicant_skills_list, skillsFragment).commit();
            }
        }).getJobModel(getIntent().getStringExtra(ViewJobActivity.TAG));
    } else {
        job = new JobModel(LoggedInUser.getInstance().getUserDocRef());
    }
    backButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(EditJobActivity.this, ScrollApplicationActivity.class);
            startActivity(intent);
        }
    });
    deadline.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new DatePickerDialogFragment(new DatePickerDialogFragment.OnDateSetListener() {

                @Override
                public void onResult(Calendar calendar) {
                    deadlineCalendar = calendar;
                    Utils.setValid(deadline, Globals.DATEFORMAT.format(calendar.getTime()));
                }
            }).setMinDate(Calendar.getInstance()).show(getSupportFragmentManager(), TAG);
        }
    });
    skills.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new SkillsDialogFragment(job.getSkills(), new SkillsDialogFragment.onConfirmListener() {

                @Override
                public void onResult(ArrayList<DocumentReference> skillsList) {
                    Log.d(TAG, "onResult: " + skillsList);
                    job.setSkills(skillsList);
                    SkillsFragment skillsFragment = new SkillsFragment(job.getSkills());
                    getSupportFragmentManager().beginTransaction().replace(R.id.edit_job_skills_list, skillsFragment).commit();
                }
            }).show(getSupportFragmentManager(), TAG);
        }
    });
    confirm.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (Utils.invalidData(position, deadline, description)) {
                return;
            }
            job.setDeadline(deadlineCalendar.getTime());
            job.setLocation(location.getText().toString());
            job.setDescription(description.getText().toString());
            job.setPosition(position.getText().toString());
            JobDb jobDb = new JobDb(EditJobActivity.this, new JobDb.OnJobUploadSuccess() {

                @Override
                public void onResult() {
                    Intent intent = new Intent(EditJobActivity.this, ScrollApplicationActivity.class);
                    startActivity(intent);
                }
            });
            // Handling if it is an existing job or new job
            if (job.getDocumentId() == null) {
                jobDb.createJob(job, LoggedInUser.getInstance().getEmail());
            } else {
                jobDb.updateJob(job);
            }
        }
    });
}
Also used : DatePickerDialogFragment(com.example.nftscmers.fragments.DatePickerDialogFragment) SkillsDialogFragment(com.example.nftscmers.fragments.SkillsDialogFragment) Calendar(java.util.Calendar) SkillsFragment(com.example.nftscmers.fragments.SkillsFragment) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) JobModel(com.example.nftscmers.objectmodels.JobModel) JobDb(com.example.nftscmers.db.JobDb) DocumentReference(com.google.firebase.firestore.DocumentReference)

Example 2 with SkillsDialogFragment

use of com.example.nftscmers.fragments.SkillsDialogFragment in project HackFest2022-Pretzel by chuanshaof.

the class FeedbackActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_feedback);
    backButton = findViewById(R.id.back_button);
    feedbackTitle = findViewById(R.id.feedback_title);
    feedback = findViewById(R.id.feedback);
    skills = findViewById(R.id.feedback_skills);
    submit = findViewById(R.id.feedback_submit);
    new ApplicationDb(FeedbackActivity.this, new ApplicationDb.OnApplicationModel() {

        @Override
        public void onResult(ApplicationModel applicationModel) {
            application = applicationModel;
            feedback.setText(applicationModel.getFeedback());
            SkillsFragment skillsFragment = new SkillsFragment(applicationModel.getFeedbackSkills());
            getSupportFragmentManager().beginTransaction().replace(R.id.feedback_skills_list, skillsFragment).commit();
        }
    }).getApplicationModel(getIntent().getStringExtra(TAG));
    if (LoggedInUser.getInstance().getAccountType() == Globals.EMPLOYER) {
        Utils.disableButton(backButton);
        feedbackTitle.setText(getString(R.string.feedback_set));
        // When user clicks on skills
        skills.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                new SkillsDialogFragment(application.getFeedbackSkills(), new SkillsDialogFragment.onConfirmListener() {

                    @Override
                    public void onResult(ArrayList<DocumentReference> skillsList) {
                        Log.d(TAG, "onResult: " + skillsList);
                        application.setFeedbackSkills(skillsList);
                        SkillsFragment skillsFragment = new SkillsFragment(application.getFeedbackSkills());
                        getSupportFragmentManager().beginTransaction().replace(R.id.feedback_skills_list, skillsFragment).commit();
                    }
                }).show(getSupportFragmentManager(), TAG);
            }
        });
    } else {
        Utils.disableButton(submit);
        feedback.setKeyListener(null);
        feedbackTitle.setText(getString(R.string.feedback_view));
    }
    backButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            finish();
        }
    });
    submit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (Utils.invalidData(feedback)) {
                return;
            } else {
                application.setFeedback(feedback.getText().toString());
                new ApplicationDb(FeedbackActivity.this, new ApplicationDb.OnApplicationUploadSuccess() {

                    @Override
                    public void onResult() {
                        finish();
                    }
                }).updateApplication(application, getIntent().getStringExtra(TAG));
            }
        }
    });
}
Also used : SkillsDialogFragment(com.example.nftscmers.fragments.SkillsDialogFragment) ApplicationDb(com.example.nftscmers.db.ApplicationDb) ApplicationModel(com.example.nftscmers.objectmodels.ApplicationModel) SkillsFragment(com.example.nftscmers.fragments.SkillsFragment) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) DocumentReference(com.google.firebase.firestore.DocumentReference)

Example 3 with SkillsDialogFragment

use of com.example.nftscmers.fragments.SkillsDialogFragment 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)

Aggregations

View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 SkillsDialogFragment (com.example.nftscmers.fragments.SkillsDialogFragment)3 SkillsFragment (com.example.nftscmers.fragments.SkillsFragment)3 DocumentReference (com.google.firebase.firestore.DocumentReference)3 Intent (android.content.Intent)2 Uri (android.net.Uri)1 ListView (android.widget.ListView)1 ApplicantDb (com.example.nftscmers.db.ApplicantDb)1 ApplicationDb (com.example.nftscmers.db.ApplicationDb)1 JobDb (com.example.nftscmers.db.JobDb)1 CropDialogFragment (com.example.nftscmers.fragments.CropDialogFragment)1 DatePickerDialogFragment (com.example.nftscmers.fragments.DatePickerDialogFragment)1 ApplicantModel (com.example.nftscmers.objectmodels.ApplicantModel)1 ApplicationModel (com.example.nftscmers.objectmodels.ApplicationModel)1 JobModel (com.example.nftscmers.objectmodels.JobModel)1 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)1 Calendar (java.util.Calendar)1