Search in sources :

Example 1 with ApplicationHistoryAdapter

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

Intent (android.content.Intent)1 MenuItem (android.view.MenuItem)1 ArrayAdapter (android.widget.ArrayAdapter)1 ApplicationHistoryAdapter (com.example.nftscmers.adapters.ApplicationHistoryAdapter)1 FeedbackActivity (com.example.nftscmers.commonactivities.FeedbackActivity)1 ApplicantDb (com.example.nftscmers.db.ApplicantDb)1 ApplicationDb (com.example.nftscmers.db.ApplicationDb)1 JobDb (com.example.nftscmers.db.JobDb)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 DocumentReference (com.google.firebase.firestore.DocumentReference)1 HashMap (java.util.HashMap)1