Search in sources :

Example 1 with JobHistoryAdapter

use of com.example.nftscmers.adapters.JobHistoryAdapter 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)

Aggregations

Intent (android.content.Intent)1 MenuItem (android.view.MenuItem)1 ArrayAdapter (android.widget.ArrayAdapter)1 JobHistoryAdapter (com.example.nftscmers.adapters.JobHistoryAdapter)1 ViewJobActivity (com.example.nftscmers.commonactivities.ViewJobActivity)1 EmployerDb (com.example.nftscmers.db.EmployerDb)1 JobDb (com.example.nftscmers.db.JobDb)1 EmployerModel (com.example.nftscmers.objectmodels.EmployerModel)1 JobModel (com.example.nftscmers.objectmodels.JobModel)1 BottomNavigationView (com.google.android.material.bottomnavigation.BottomNavigationView)1 DocumentReference (com.google.firebase.firestore.DocumentReference)1 HashMap (java.util.HashMap)1