Search in sources :

Example 1 with JobDb

use of com.example.nftscmers.db.JobDb 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 JobDb

use of com.example.nftscmers.db.JobDb in project HackFest2022-Pretzel by chuanshaof.

the class JobHistoryActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_job_history);
    jobListView = findViewById(R.id.job_history_list);
    ArrayAdapter arrayAdapter = new JobHistoryAdapter(JobHistoryActivity.this, R.layout.item_job_history, jobDetailsList, new JobHistoryAdapter.OnItemClickListener() {

        @Override
        public void onResult(int position) {
            Intent intent = new Intent(JobHistoryActivity.this, ViewJobActivity.class);
            intent.putExtra(ViewJobActivity.TAG, jobsList.get(position).getId());
            startActivityForResult(intent, 0);
        }
    });
    jobListView.setAdapter(arrayAdapter);
    new EmployerDb(JobHistoryActivity.this, new EmployerDb.OnEmployerModel() {

        @Override
        public void onResult(EmployerModel employerModel) {
            jobsList = employerModel.getJobs();
            for (DocumentReference job : jobsList) {
                Log.d(TAG, "onResult: " + job.getId());
                new JobDb(JobHistoryActivity.this, new JobDb.OnJobModel() {

                    @Override
                    public void onResult(JobModel jobModel) {
                        HashMap<String, String> jobDetails = new HashMap<>();
                        jobDetails.put(JobModel.POSITION, jobModel.getPosition());
                        jobDetails.put(JobModel.DEADLINE, Globals.DATEFORMAT.format(jobModel.getDeadline()));
                        jobDetailsList.add(jobDetails);
                        arrayAdapter.notifyDataSetChanged();
                    }
                }).getJobModel(job);
            }
        }
    }).getEmployerModel(LoggedInUser.getInstance().getEmail());
    // Initialize and assign variable
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
    // Set Home selected
    bottomNavigationView.setSelectedItemId(R.id.history);
    // Perform item selected listener
    bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch(item.getItemId()) {
                case R.id.history:
                    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:
                    Intent intent = new Intent(JobHistoryActivity.this, ProfileActivity.class);
                    intent.putExtra(ProfileActivity.TAG, LoggedInUser.getInstance().getEmail());
                    startActivity(intent);
                    overridePendingTransition(0, 0);
                    return true;
            }
            return false;
        }
    });
}
Also used : HashMap(java.util.HashMap) EmployerModel(com.example.nftscmers.objectmodels.EmployerModel) Intent(android.content.Intent) MenuItem(android.view.MenuItem) EmployerDb(com.example.nftscmers.db.EmployerDb) JobHistoryAdapter(com.example.nftscmers.adapters.JobHistoryAdapter) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) ViewJobActivity(com.example.nftscmers.commonactivities.ViewJobActivity) JobModel(com.example.nftscmers.objectmodels.JobModel) JobDb(com.example.nftscmers.db.JobDb) ArrayAdapter(android.widget.ArrayAdapter) DocumentReference(com.google.firebase.firestore.DocumentReference)

Example 3 with JobDb

use of com.example.nftscmers.db.JobDb in project HackFest2022-Pretzel by chuanshaof.

the class ScrollApplicationActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_scroll_application);
    FirebaseFirestore db = FirebaseFirestore.getInstance();
    flingAdapterView = findViewById(R.id.swipe);
    ArrayList<ApplicantModel> item = new ArrayList<>();
    jobTracker = new HashMap<>();
    ApplicantAdapter arrayAdapter = new ApplicantAdapter(ScrollApplicationActivity.this, R.layout.item_in_cardview, item);
    flingAdapterView.setAdapter(arrayAdapter);
    new EmployerDb(ScrollApplicationActivity.this, new EmployerDb.OnEmployerModel() {

        @Override
        public void onResult(EmployerModel employerModel) {
            for (DocumentReference job : employerModel.getJobs()) {
                Toast.makeText(getApplicationContext(), job.toString(), Toast.LENGTH_LONG).show();
                new JobDb(ScrollApplicationActivity.this, new JobDb.OnJobModel() {

                    @Override
                    public void onResult(JobModel jobModel) {
                        if (jobModel.getPending() == null) {
                            return;
                        }
                        for (DocumentReference pending : jobModel.getPending()) {
                            Log.d(TAG, "onResult: " + pending.getId());
                            new ApplicationDb(ScrollApplicationActivity.this, new ApplicationDb.OnApplicationModel() {

                                @Override
                                public void onResult(ApplicationModel applicationModel) {
                                    new ApplicantDb(ScrollApplicationActivity.this, new ApplicantDb.OnApplicantModel() {

                                        @Override
                                        public void onResult(ApplicantModel applicantModel) {
                                            Log.d(TAG, "onResult: " + applicantModel);
                                            item.add(applicantModel);
                                            ArrayList<DocumentReference> tracker = new ArrayList<>();
                                            tracker.add(pending);
                                            tracker.add(job);
                                            jobTracker.put(applicantModel, tracker);
                                            arrayAdapter.notifyDataSetChanged();
                                        }
                                    }).getApplicantModel(applicationModel.getApplicant());
                                }
                            }).getApplicationModel(pending);
                        }
                    }
                }).getJobModel(job);
            }
        }
    }).getEmployerModel(LoggedInUser.getInstance().getEmail());
    flingAdapterView.setFlingListener(new SwipeFlingAdapterView.onFlingListener() {

        @Override
        public void removeFirstObjectInAdapter() {
            item.remove(0);
            arrayAdapter.notifyDataSetChanged();
        }

        @Override
        public void onLeftCardExit(Object o) {
            new JobDb(ScrollApplicationActivity.this, new JobDb.OnJobUploadSuccess() {

                @Override
                public void onResult() {
                    new ApplicationDb(ScrollApplicationActivity.this, new ApplicationDb.OnApplicationUploadSuccess() {

                        @Override
                        public void onResult() {
                            Toast.makeText(ScrollApplicationActivity.this, "Rejected", Toast.LENGTH_SHORT).show();
                            Intent intent = new Intent(ScrollApplicationActivity.this, FeedbackActivity.class);
                            intent.putExtra(FeedbackActivity.TAG, jobTracker.get(o).get(0).getId());
                            startActivityForResult(intent, 0);
                        }
                    }).updateApplicationStatus(ApplicationModel.REJECTED, jobTracker.get(o).get(0));
                }
            }).deletePending(jobTracker.get(o).get(0), jobTracker.get(o).get(1));
        }

        @Override
        public void onRightCardExit(Object o) {
            Log.d(TAG, "onRightCardExit: " + o);
            new JobDb(ScrollApplicationActivity.this, new JobDb.OnJobUploadSuccess() {

                @Override
                public void onResult() {
                    new ApplicationDb(ScrollApplicationActivity.this, new ApplicationDb.OnApplicationUploadSuccess() {

                        @Override
                        public void onResult() {
                            Toast.makeText(ScrollApplicationActivity.this, "Accepted", Toast.LENGTH_SHORT).show();
                            Intent intent = new Intent(ScrollApplicationActivity.this, FeedbackActivity.class);
                            intent.putExtra(FeedbackActivity.TAG, jobTracker.get(o).get(0).getId());
                            startActivityForResult(intent, 0);
                        }
                    }).updateApplicationStatus(ApplicationModel.ACCEPTED, jobTracker.get(o).get(0));
                }
            }).deletePending(jobTracker.get(o).get(0), jobTracker.get(o).get(1));
        }

        @Override
        public void onAdapterAboutToEmpty(int i) {
        }

        @Override
        public void onScroll(float v) {
        }
    });
    flingAdapterView.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() {

        @Override
        public void onItemClicked(int i, Object o) {
            Intent intent = new Intent(ScrollApplicationActivity.this, com.example.nftscmers.applicantactivities.ProfileActivity.class);
            intent.putExtra(com.example.nftscmers.applicantactivities.ProfileActivity.TAG, item.get(i).getDocumentId());
            startActivity(intent);
        }
    });
    Button like, dislike;
    like = findViewById(R.id.like);
    dislike = findViewById(R.id.dislike);
    like.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            flingAdapterView.getTopCardListener().selectRight();
        }
    });
    dislike.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            flingAdapterView.getTopCardListener().selectLeft();
        }
    });
    // Initialize and assign variable
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
    // Set Home selected
    bottomNavigationView.setSelectedItemId(R.id.home);
    // Perform item selected listener
    bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            Intent intent;
            switch(item.getItemId()) {
                case R.id.history:
                    intent = new Intent(ScrollApplicationActivity.this, JobHistoryActivity.class);
                    startActivity(intent);
                    overridePendingTransition(0, 0);
                    return true;
                case R.id.home:
                    return true;
                case R.id.create:
                    startActivity(new Intent(getApplicationContext(), EditJobActivity.class));
                    overridePendingTransition(0, 0);
                    return true;
                case R.id.profile:
                    intent = new Intent(ScrollApplicationActivity.this, ProfileActivity.class);
                    intent.putExtra(ProfileActivity.TAG, LoggedInUser.getInstance().getEmail());
                    startActivity(intent);
                    overridePendingTransition(0, 0);
                    return true;
            }
            return false;
        }
    });
}
Also used : ApplicantAdapter(com.example.nftscmers.adapters.ApplicantAdapter) ArrayList(java.util.ArrayList) ApplicationModel(com.example.nftscmers.objectmodels.ApplicationModel) ApplicantDb(com.example.nftscmers.db.ApplicantDb) Button(android.widget.Button) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) ApplicationDb(com.example.nftscmers.db.ApplicationDb) JobModel(com.example.nftscmers.objectmodels.JobModel) DocumentReference(com.google.firebase.firestore.DocumentReference) SwipeFlingAdapterView(com.lorentzos.flingswipe.SwipeFlingAdapterView) FirebaseFirestore(com.google.firebase.firestore.FirebaseFirestore) FeedbackActivity(com.example.nftscmers.commonactivities.FeedbackActivity) ApplicantModel(com.example.nftscmers.objectmodels.ApplicantModel) EmployerModel(com.example.nftscmers.objectmodels.EmployerModel) Intent(android.content.Intent) MenuItem(android.view.MenuItem) View(android.view.View) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) SwipeFlingAdapterView(com.lorentzos.flingswipe.SwipeFlingAdapterView) EmployerDb(com.example.nftscmers.db.EmployerDb) JobDb(com.example.nftscmers.db.JobDb)

Example 4 with JobDb

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

use of com.example.nftscmers.db.JobDb in project HackFest2022-Pretzel by chuanshaof.

the class ApplicationHistoryActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_application_history);
    applicationListView = findViewById(R.id.application_history_list);
    ArrayAdapter arrayAdapter = new ApplicationHistoryAdapter(ApplicationHistoryActivity.this, R.layout.item_application_history, applicationDetailsList, new ApplicationHistoryAdapter.OnItemClickListener() {

        @Override
        public void onResult(int position) {
            Intent intent = new Intent(ApplicationHistoryActivity.this, FeedbackActivity.class);
            intent.putExtra(FeedbackActivity.TAG, applicationsList.get(position).getId());
            startActivityForResult(intent, 0);
        }
    });
    applicationListView.setAdapter(arrayAdapter);
    new ApplicantDb(ApplicationHistoryActivity.this, new ApplicantDb.OnApplicantModel() {

        @Override
        public void onResult(ApplicantModel applicantModel) {
            applicationsList = applicantModel.getApplications();
            for (DocumentReference application : applicationsList) {
                Log.d(TAG, "onResult: " + application.getId());
                new ApplicationDb(ApplicationHistoryActivity.this, new ApplicationDb.OnApplicationModel() {

                    @Override
                    public void onResult(ApplicationModel applicationModel) {
                        HashMap<String, String> applicationDetails = new HashMap<>();
                        applicationDetails.put(ApplicationModel.STATUS, applicationModel.getStatus());
                        new JobDb(ApplicationHistoryActivity.this, new JobDb.OnJobModel() {

                            @Override
                            public void onResult(JobModel jobModel) {
                                applicationDetails.put(ApplicationModel.COMPANY, jobModel.getEmployerName());
                                applicationDetails.put(ApplicationModel.POSITION, jobModel.getPosition());
                                applicationDetailsList.add(applicationDetails);
                                arrayAdapter.notifyDataSetChanged();
                            }
                        }).getJobModel(applicationModel.getJob());
                    }
                }).getApplicationModel(application);
            }
        }
    }).getApplicantModel(LoggedInUser.getInstance().getEmail());
    // Initialize and assign variable
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
    // Set Home selected
    bottomNavigationView.setSelectedItemId(R.id.history);
    // Perform item selected listener
    bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            Intent intent;
            switch(item.getItemId()) {
                case R.id.history:
                    return true;
                case R.id.home:
                    intent = new Intent(ApplicationHistoryActivity.this, ScrollJobActivity.class);
                    startActivity(intent);
                    overridePendingTransition(0, 0);
                    return true;
                case R.id.profile:
                    intent = new Intent(ApplicationHistoryActivity.this, ProfileActivity.class);
                    intent.putExtra(ProfileActivity.TAG, LoggedInUser.getInstance().getEmail());
                    startActivity(intent);
                    overridePendingTransition(0, 0);
                    return true;
            }
            return false;
        }
    });
}
Also used : HashMap(java.util.HashMap) FeedbackActivity(com.example.nftscmers.commonactivities.FeedbackActivity) ApplicantModel(com.example.nftscmers.objectmodels.ApplicantModel) ApplicationModel(com.example.nftscmers.objectmodels.ApplicationModel) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ApplicantDb(com.example.nftscmers.db.ApplicantDb) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) ApplicationDb(com.example.nftscmers.db.ApplicationDb) JobModel(com.example.nftscmers.objectmodels.JobModel) ApplicationHistoryAdapter(com.example.nftscmers.adapters.ApplicationHistoryAdapter) JobDb(com.example.nftscmers.db.JobDb) ArrayAdapter(android.widget.ArrayAdapter) DocumentReference(com.google.firebase.firestore.DocumentReference)

Aggregations

JobDb (com.example.nftscmers.db.JobDb)6 JobModel (com.example.nftscmers.objectmodels.JobModel)6 Intent (android.content.Intent)5 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)5 DocumentReference (com.google.firebase.firestore.DocumentReference)5 MenuItem (android.view.MenuItem)4 View (android.view.View)4 ApplicantDb (com.example.nftscmers.db.ApplicantDb)3 ApplicationDb (com.example.nftscmers.db.ApplicationDb)3 ApplicantModel (com.example.nftscmers.objectmodels.ApplicantModel)3 ArrayAdapter (android.widget.ArrayAdapter)2 Button (android.widget.Button)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 FeedbackActivity (com.example.nftscmers.commonactivities.FeedbackActivity)2 ViewJobActivity (com.example.nftscmers.commonactivities.ViewJobActivity)2 EmployerDb (com.example.nftscmers.db.EmployerDb)2 SkillsFragment (com.example.nftscmers.fragments.SkillsFragment)2 ApplicationModel (com.example.nftscmers.objectmodels.ApplicationModel)2 EmployerModel (com.example.nftscmers.objectmodels.EmployerModel)2