use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class ManageMyEmployeesActivity method loadData.
private void loadData() {
progressDialog = new ProgressDialog(this);
progressDialog.setTitle(getResources().getString(R.string.dialog));
progressDialog.show();
SharedPreferences preferences = this.getSharedPreferences(Constant.PREFERENCE_NAME, MODE_PRIVATE);
final String id = preferences.getString(Constant.PREFERENCE_KEY_ID, null);
Log.i("ANTN", "ID: " + id);
if (id != null) {
DatabaseReference myRef = database.getReference(Constant.NODE_NHAN_VIEN);
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
EmployeeObject employeeObject = snapshot.getValue(EmployeeObject.class);
if (id.equals(employeeObject.getIdManage())) {
listEmployee.add(employeeObject);
employeeAdapter.notifyDataSetChanged();
}
}
progressDialog.dismiss();
}
@Override
public void onCancelled(DatabaseError error) {
progressDialog.dismiss();
}
});
}
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class SelectEmployeeToJobActivity method addEmployees.
private void addEmployees() {
ArrayList<EmployeeObject> list = new ArrayList<>();
for (int i = 0; i < listCheck.size(); i++) {
if (listCheck.get(i)) {
list.add(listEmployees.get(i));
}
}
Intent intent = new Intent();
intent.putExtra("LIST_EMPLOYEE", list);
intent.putExtra("MAX", temp.size());
setResult(Constant.RESULT_CODE, intent);
finish();
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class EmployeeSelectedAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull final EmployeeSelectedViewHolder holder, final int position) {
EmployeeObject employeeObject = employeeObjectList.get(position);
Glide.with(context).load(employeeObject.getUrlAvatar()).into(holder.imgAvatar);
holder.tvNameEmployee.setText(employeeObject.getNameEmployee());
holder.btnRemove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
employeeObjectList.remove(position);
notifyDataSetChanged();
}
});
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class AddJobActivity method addJob.
private void addJob() {
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setTitle(getResources().getString(R.string.dialog));
String title = edtTitle.getText().toString();
String description = edtDescription.getText().toString();
String timeStart = tvStart.getText().toString();
String timeEnd = tvEnd.getText().toString();
if (!title.equals("") && !description.equals("") && !timeStart.equals(getResources().getString(R.string.job_start)) && !timeEnd.equals(getResources().getString(R.string.job_end)) && listEmployees.size() > 0) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
Date date = new Date();
String now = dateFormat.format(date);
if (compareDate(now, timeStart) && compareDate(timeStart, timeEnd)) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference reference = database.getReference().child(Constant.NODE_CONG_VIEC);
String idJob = reference.push().getKey();
SharedPreferences preferences = getSharedPreferences(Constant.PREFERENCE_NAME, MODE_PRIVATE);
String idManage = preferences.getString(Constant.PREFERENCE_KEY_ID, "");
List<String> listIdMember = new ArrayList();
for (EmployeeObject object : listEmployees) {
listIdMember.add(object.getIdEmployee());
}
JobObject jobObject = new JobObject();
jobObject.setIdJob(idJob);
jobObject.setIdManageJob(idManage);
jobObject.setTitleJob(title);
jobObject.setDescriptionJob(description);
jobObject.setStartDateJob(timeStart);
jobObject.setEndDateJob(timeEnd);
jobObject.setStatusJob(Constant.NOT_RECEIVED);
jobObject.setListIdMember(listIdMember);
dialog.show();
reference.child(idJob).setValue(jobObject).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
dialog.dismiss();
Toast.makeText(AddJobActivity.this, "Success!", Toast.LENGTH_SHORT).show();
}
});
} else {
Toast.makeText(this, "Date is fail!", Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(this, "Data is empty!", Toast.LENGTH_SHORT).show();
}
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class ManageMyAccountActivity method loadData.
private void loadData() {
SharedPreferences preferences = this.getSharedPreferences(Constant.PREFERENCE_NAME, MODE_PRIVATE);
String id = preferences.getString(Constant.PREFERENCE_KEY_ID, null);
if (id != null) {
DatabaseReference myRef = database.getReference(Constant.NODE_NHAN_VIEN).child(id);
myRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
EmployeeObject employeeObject = dataSnapshot.getValue(EmployeeObject.class);
if (employeeObject != null) {
Glide.with(getApplicationContext()).load(employeeObject.getUrlAvatar()).into(imgAvartar);
edtFullName.setText(employeeObject.getNameEmployee());
if ((employeeObject.getAccountType()).equals("0")) {
tvAccountType.setText(getString(R.string.message_admin));
} else if ((employeeObject.getAccountType()).equals("1")) {
tvAccountType.setText(getString(R.string.message_employee));
}
tvOffice.setText("Office " + employeeObject.getOfficeEmployee());
tvBirthday.setText(employeeObject.getBirthdayEmployee());
edtPhone.setText(employeeObject.getPhoneEmployee());
edtAddress.setText(employeeObject.getAddressEmployee());
}
}
@Override
public void onCancelled(DatabaseError error) {
// Failed to read value
Log.i("ABC", "Failed to read value.", error.toException());
}
});
}
}
Aggregations