Search in sources :

Example 1 with EmployerDb

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

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

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

the class SignUpActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up);
    title = findViewById(R.id.sign_up_title);
    email = findViewById(R.id.sign_up_email);
    password = findViewById(R.id.sign_up_password);
    confirmPassword = findViewById(R.id.sign_up_confirm_password);
    signUp = findViewById(R.id.sign_up_button);
    signIn = findViewById(R.id.sign_in);
    // Setting up of initial sign up type
    signUpType = getIntent().getStringExtra(LoginActivity.TAG);
    Log.i(TAG, "onCreate: " + signUpType);
    if (signUpType == null) {
        signUpType = Globals.APPLICANT;
        title.setText(getString(R.string.applicant_sign_up));
    } else if (signUpType.equals(Globals.APPLICANT)) {
        title.setText(getString(R.string.applicant_sign_up));
    } else if (signUpType.equals(Globals.EMPLOYER)) {
        title.setText(getString(R.string.employer_sign_up));
    } else {
        signUpType = Globals.APPLICANT;
        title.setText(getString(R.string.applicant_sign_up));
    }
    // Sign Up Button
    signUp.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String enteredEmail = email.getText().toString();
            String enteredPassword = password.getText().toString();
            String confirmPasswordEntry = confirmPassword.getText().toString();
            // Ensure that entered data are all valid
            if (!Utils.isNetworkAvailable(SignUpActivity.this) | Utils.invalidData(email, password, confirmPassword) | Utils.invalidEmail(email)) {
                Log.i(TAG, "onSignUp failed");
                return;
            }
            if (!enteredPassword.equals(confirmPasswordEntry)) {
                confirmPassword.requestFocus();
                confirmPassword.setError(getString(R.string.sign_up_confirm_fail));
                Log.i(TAG, getString(R.string.sign_up_confirm_fail));
                return;
            }
            // Disable button for Firestore processing
            signUp.setEnabled(false);
            signUp.setText(getString(R.string.signing_up));
            // Ensuring that email has not already been registered
            DocumentReference accountDocument = FirebaseFirestore.getInstance().collection(AccountModel.getCollectionId()).document(email.getText().toString());
            accountDocument.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {

                @Override
                public void onComplete(@NonNull Task<DocumentSnapshot> task) {
                    if (task.isSuccessful()) {
                        DocumentSnapshot document = task.getResult();
                        if (document.exists()) {
                            email.requestFocus();
                            email.setError(getString(R.string.duplicate_email));
                            signUp.setEnabled(true);
                            signUp.setText(getString(R.string.sign_up));
                            Log.i(TAG, getString(R.string.duplicate_email));
                            return;
                        } else {
                            // Creating new profile in applicant
                            if (signUpType.equals(Globals.APPLICANT)) {
                                new ApplicantDb(SignUpActivity.this, new ApplicantDb.OnApplicantUploadSuccess() {

                                    @Override
                                    public void onResult() {
                                        Map<String, Object> account = new HashMap<>();
                                        account.put(AccountModel.EMAIL, enteredEmail);
                                        account.put(AccountModel.PASSWORD, password.getText().toString());
                                        account.put(AccountModel.ACCOUNTTYPE, signUpType);
                                        account.put(AccountModel.PROFILE, new ApplicantDb().getDocument(email.getText().toString()));
                                        accountDocument.set(account).addOnSuccessListener(new OnSuccessListener<Void>() {

                                            @Override
                                            public void onSuccess(Void aVoid) {
                                                LoggedInUser.getInstance().setUser(FirebaseFirestore.getInstance().collection(ApplicantModel.getCollectionId()).document(enteredEmail), enteredEmail, signUpType);
                                                Utils.toastLog(SignUpActivity.this, TAG, getString(R.string.sign_up_success));
                                                Intent intent = new Intent(SignUpActivity.this, com.example.nftscmers.applicantactivities.EditProfileActivity.class);
                                                startActivity(intent);
                                            }
                                        }).addOnFailureListener(new OnFailureListener() {

                                            @Override
                                            public void onFailure(@NonNull Exception e) {
                                                Log.w(TAG, getString(R.string.firestore_error), e);
                                                signUp.setEnabled(true);
                                                signUp.setText(getString(R.string.sign_up));
                                            }
                                        });
                                    }
                                }).newProfile(email);
                            } else if (signUpType.equals(Globals.EMPLOYER)) {
                                new EmployerDb(SignUpActivity.this, new EmployerDb.OnEmployerUploadSuccess() {

                                    @Override
                                    public void onResult() {
                                        Map<String, Object> account = new HashMap<>();
                                        account.put(AccountModel.EMAIL, enteredEmail);
                                        account.put(AccountModel.PASSWORD, password.getText().toString());
                                        account.put(AccountModel.ACCOUNTTYPE, Globals.EMPLOYER);
                                        account.put(AccountModel.PROFILE, new EmployerDb().getDocument(email.getText().toString()));
                                        accountDocument.set(account).addOnSuccessListener(new OnSuccessListener<Void>() {

                                            @Override
                                            public void onSuccess(Void aVoid) {
                                                LoggedInUser.getInstance().setUser(FirebaseFirestore.getInstance().collection(EmployerModel.getCollectionId()).document(enteredEmail), enteredEmail, signUpType);
                                                Utils.toastLog(SignUpActivity.this, TAG, getString(R.string.sign_up_success));
                                                Intent intent = new Intent(SignUpActivity.this, com.example.nftscmers.employeractivities.EditProfileActivity.class);
                                                startActivity(intent);
                                            }
                                        }).addOnFailureListener(new OnFailureListener() {

                                            @Override
                                            public void onFailure(@NonNull Exception e) {
                                                Utils.fireStoreError(SignUpActivity.this, TAG);
                                                signUp.setEnabled(true);
                                                signUp.setText(getString(R.string.sign_in));
                                            }
                                        });
                                    }
                                }).newProfile(email);
                            } else {
                                Utils.unexpectedError(SignUpActivity.this, TAG);
                                signUp.setEnabled(true);
                                signUp.setText(getString(R.string.sign_up));
                            }
                        }
                    } else {
                        Utils.fireStoreError(SignUpActivity.this, TAG);
                        signUp.setEnabled(true);
                        signUp.setText(getString(R.string.sign_up));
                    }
                }
            });
        }
    });
    // Sign In Button
    signIn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(SignUpActivity.this, LoginActivity.class);
            intent.putExtra(LoginActivity.TAG, signUpType);
            startActivity(intent);
        }
    });
}
Also used : Task(com.google.android.gms.tasks.Task) HashMap(java.util.HashMap) ApplicantDb(com.example.nftscmers.db.ApplicantDb) DocumentSnapshot(com.google.firebase.firestore.DocumentSnapshot) NonNull(androidx.annotation.NonNull) OnSuccessListener(com.google.android.gms.tasks.OnSuccessListener) DocumentReference(com.google.firebase.firestore.DocumentReference) Intent(android.content.Intent) View(android.view.View) TextView(android.widget.TextView) EmployerDb(com.example.nftscmers.db.EmployerDb) OnCompleteListener(com.google.android.gms.tasks.OnCompleteListener) HashMap(java.util.HashMap) Map(java.util.Map) OnFailureListener(com.google.android.gms.tasks.OnFailureListener)

Example 4 with EmployerDb

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

Example 5 with EmployerDb

use of com.example.nftscmers.db.EmployerDb 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_employer_profile);
    back = findViewById(R.id.employer_back_arrow);
    editProfile = findViewById(R.id.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);
    linkedIn = findViewById(R.id.employer_linkedIn);
    logout = findViewById(R.id.button_logout);
    // Loading of previous employer data
    new EmployerDb(ProfileActivity.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(linkedIn, employer.getWebsite());
            Utils.setValid(email, employer.getEmail());
        }
    }).getEmployerModel(getIntent().getStringExtra(TAG));
    if (!getIntent().getStringExtra(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.EMPLOYER) {
        back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(com.example.nftscmers.employeractivities.ProfileActivity.this, ScrollApplicationActivity.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(), JobHistoryActivity.class));
                        overridePendingTransition(0, 0);
                        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:
                        return true;
                }
                return false;
            }
        });
    } else {
        back.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                Intent intent = new Intent(com.example.nftscmers.employeractivities.ProfileActivity.this, ScrollJobActivity.class);
                startActivity(intent);
            }
        });
        Utils.disableButton(bottomNavigationView);
    }
}
Also used : LoginActivity(com.example.nftscmers.commonactivities.LoginActivity) EmployerModel(com.example.nftscmers.objectmodels.EmployerModel) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) ListView(android.widget.ListView) EmployerDb(com.example.nftscmers.db.EmployerDb) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) YesNoDialogFragment(com.example.nftscmers.fragments.YesNoDialogFragment) ScrollJobActivity(com.example.nftscmers.applicantactivities.ScrollJobActivity)

Aggregations

Intent (android.content.Intent)5 EmployerDb (com.example.nftscmers.db.EmployerDb)5 View (android.view.View)4 EmployerModel (com.example.nftscmers.objectmodels.EmployerModel)4 MenuItem (android.view.MenuItem)3 TextView (android.widget.TextView)3 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)3 DocumentReference (com.google.firebase.firestore.DocumentReference)3 ImageView (android.widget.ImageView)2 ApplicantDb (com.example.nftscmers.db.ApplicantDb)2 JobDb (com.example.nftscmers.db.JobDb)2 JobModel (com.example.nftscmers.objectmodels.JobModel)2 HashMap (java.util.HashMap)2 Uri (android.net.Uri)1 ArrayAdapter (android.widget.ArrayAdapter)1 Button (android.widget.Button)1 ListView (android.widget.ListView)1 NonNull (androidx.annotation.NonNull)1 ApplicantAdapter (com.example.nftscmers.adapters.ApplicantAdapter)1 JobHistoryAdapter (com.example.nftscmers.adapters.JobHistoryAdapter)1