Search in sources :

Example 1 with SkillsFragment

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

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

the class ViewJobActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_job);
    backButton = findViewById(R.id.job_back);
    edit = findViewById(R.id.job_edit);
    employer = findViewById(R.id.job_employer);
    employerPic = findViewById(R.id.job_picture);
    position = findViewById(R.id.job_position);
    description = findViewById(R.id.job_description);
    deadline = findViewById(R.id.job_deadline);
    location = findViewById(R.id.job_location);
    // Loading of previous job data, pass UUID into the intent
    new JobDb(ViewJobActivity.this, new JobDb.OnJobModel() {

        @Override
        public void onResult(JobModel jobModel) {
            Log.d(TAG, "onResult: " + jobModel);
            job = jobModel;
            Utils.loadImage(employerPic, job.getEmployerPic());
            Utils.setValid(employer, job.getEmployerName());
            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.job_skills_list, skillsFragment).commit();
            // Remove edit button if user viewing is not the employer
            if (!LoggedInUser.getInstance().getUserDocRef().equals(job.getEmployer())) {
                Utils.disableButton(edit);
            }
        }
    }).getJobModel(getIntent().getStringExtra(ViewJobActivity.TAG));
    backButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            finish();
        }
    });
}
Also used : SkillsFragment(com.example.nftscmers.fragments.SkillsFragment) JobModel(com.example.nftscmers.objectmodels.JobModel) JobDb(com.example.nftscmers.db.JobDb) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with SkillsFragment

use of com.example.nftscmers.fragments.SkillsFragment 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 4 with SkillsFragment

use of com.example.nftscmers.fragments.SkillsFragment 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 5 with SkillsFragment

use of com.example.nftscmers.fragments.SkillsFragment 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);
    }
}
Also used : LoginActivity(com.example.nftscmers.commonactivities.LoginActivity) ApplicantModel(com.example.nftscmers.objectmodels.ApplicantModel) SkillsFragment(com.example.nftscmers.fragments.SkillsFragment) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ApplicantDb(com.example.nftscmers.db.ApplicantDb) ImageView(android.widget.ImageView) View(android.view.View) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) ListView(android.widget.ListView) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) YesNoDialogFragment(com.example.nftscmers.fragments.YesNoDialogFragment) ScrollApplicationActivity(com.example.nftscmers.employeractivities.ScrollApplicationActivity)

Aggregations

View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 SkillsFragment (com.example.nftscmers.fragments.SkillsFragment)5 Intent (android.content.Intent)3 SkillsDialogFragment (com.example.nftscmers.fragments.SkillsDialogFragment)3 DocumentReference (com.google.firebase.firestore.DocumentReference)3 ListView (android.widget.ListView)2 ApplicantDb (com.example.nftscmers.db.ApplicantDb)2 JobDb (com.example.nftscmers.db.JobDb)2 ApplicantModel (com.example.nftscmers.objectmodels.ApplicantModel)2 JobModel (com.example.nftscmers.objectmodels.JobModel)2 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)2 Uri (android.net.Uri)1 MenuItem (android.view.MenuItem)1 LoginActivity (com.example.nftscmers.commonactivities.LoginActivity)1 ApplicationDb (com.example.nftscmers.db.ApplicationDb)1 ScrollApplicationActivity (com.example.nftscmers.employeractivities.ScrollApplicationActivity)1 CropDialogFragment (com.example.nftscmers.fragments.CropDialogFragment)1 DatePickerDialogFragment (com.example.nftscmers.fragments.DatePickerDialogFragment)1