use of com.example.nftscmers.objectmodels.ApplicationModel 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;
}
});
}
use of com.example.nftscmers.objectmodels.ApplicationModel in project HackFest2022-Pretzel by chuanshaof.
the class ApplicationDb method newApplication.
/**
* Create new account for applications using only email with no details yet
* @param applicant a DocumentReference object containing the applicant
* @param job a DocumentReference object containing the job that is being applied to
*/
public void newApplication(DocumentReference applicant, DocumentReference job) {
DocumentReference application = getDocument(UUID.randomUUID().toString());
new ApplicantDb(context, new ApplicantDb.OnApplicantUploadSuccess() {
@Override
protected void onResult() {
new JobDb(context, new JobDb.OnJobUploadSuccess() {
@Override
public void onResult() {
ApplicationModel applicationModel = new ApplicationModel(applicant, job, null, null, ApplicationModel.PENDING);
application.set(applicationModel).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
onApplicationUploadSuccess.onResult();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
onApplicationUploadFailure.onResult();
}
});
}
}).addPending(application, job);
}
}).updateApplications(application, applicant);
}
use of com.example.nftscmers.objectmodels.ApplicationModel 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;
}
});
}
use of com.example.nftscmers.objectmodels.ApplicationModel 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));
}
}
});
}
use of com.example.nftscmers.objectmodels.ApplicationModel in project HackFest2022-Pretzel by chuanshaof.
the class ApplicationDb method getApplicationModel.
/**
* Get ApplicationModel from an email address
* @param application a DocumentReference indicating an email address
*/
public void getApplicationModel(DocumentReference application) {
if (!Utils.isNetworkAvailable(context)) {
onApplicationModel.onResult(null);
return;
}
application.get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() {
@Override
public void onSuccess(DocumentSnapshot documentSnapshot) {
ApplicationModel applicationModel = documentSnapshot.toObject(ApplicationModel.class);
Log.d(TAG, "onSuccess " + applicationModel.getDocumentId());
onApplicationModel.onResult(applicationModel);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "onFailure");
}
});
}
Aggregations