use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class SelectEmployeeToJobActivity method getData.
private void getData() {
Intent intent = getIntent();
if (intent != null) {
List<EmployeeObject> listEmployeeAdded = (List<EmployeeObject>) intent.getSerializableExtra("LIST_EMPLOYEE_ADDED");
temp.addAll(listEmployees);
// Loại bỏ bị trùng
for (int i = 0; i < listEmployeeAdded.size(); i++) {
EmployeeObject added = listEmployeeAdded.get(i);
for (int j = 0; j < temp.size(); j++) {
EmployeeObject employee = temp.get(j);
if (added.getIdEmployee().equals(employee.getIdEmployee())) {
int posi = j - i;
listEmployees.remove(posi);
listCheck.remove(posi);
employeeAdapter.notifyDataSetChanged();
break;
}
}
}
progressDialog.dismiss();
}
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class SelectEmployeeToJobActivity method loadDataFromFireBase.
private void loadDataFromFireBase() {
progressDialog = new ProgressDialog(this);
progressDialog.show();
SharedPreferences preferences = this.getSharedPreferences(Constant.PREFERENCE_NAME, MODE_PRIVATE);
final String id = preferences.getString(Constant.PREFERENCE_KEY_ID, null);
if (id != null) {
DatabaseReference myRef = FirebaseDatabase.getInstance().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())) {
listEmployees.add(employeeObject);
listCheck.add(false);
employeeAdapter.notifyDataSetChanged();
}
}
getData();
}
@Override
public void onCancelled(DatabaseError error) {
Log.i("ABC", "Failed to read value.", error.toException());
}
});
} else {
progressDialog.dismiss();
Log.i("ANTN", "ID Manage is null!");
}
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class SignUpActivity method signUp.
private void signUp() {
final boolean[] isFirst = { true };
final List<String> listDomain = new ArrayList<>();
final String username = edtUsername.getText().toString();
final String password = edtPassword.getText().toString();
final String domain = edtDomain.getText().toString();
final String fullName = edtFullName.getText().toString();
final String phone = edtPhone.getText().toString();
final String address = edtAddress.getText().toString();
final DatabaseReference referenceDomain, referenceEmployee;
referenceDomain = database.getReference(Constant.NODE_DOMAIN);
referenceEmployee = database.getReference(Constant.NODE_NHAN_VIEN);
// Check domain exist
referenceDomain.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
String domain = snapshot.getValue(String.class);
listDomain.add(domain);
}
if (listDomain.contains(domain) && isFirst[0]) {
Toast.makeText(SignUpActivity.this, "Domain cua ban da ton tai!!!", Toast.LENGTH_SHORT).show();
isFirst[0] = false;
} else if (isFirst[0]) {
if (!username.equals("") && !password.equals("") && !domain.equals("") && !fullName.equals("")) {
mAuth.createUserWithEmailAndPassword(username + domain, password).addOnCompleteListener(SignUpActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseUser user = mAuth.getCurrentUser();
EmployeeObject employeeObject = new EmployeeObject();
employeeObject.setAccountType("0");
employeeObject.setIdEmployee(user.getUid());
employeeObject.setIdManage("");
employeeObject.setUsernameEmployee(username + domain);
if (!phone.equals("")) {
employeeObject.setPhoneEmployee(phone);
} else {
employeeObject.setPhoneEmployee("");
}
if (!address.equals("")) {
employeeObject.setAddressEmployee(address);
} else {
employeeObject.setAddressEmployee("");
}
employeeObject.setNameEmployee(fullName);
if (rdbMale.isChecked()) {
employeeObject.setGenderEmployee("Nam");
employeeObject.setUrlAvatar(Constant.URL_MALE);
} else {
employeeObject.setGenderEmployee("Nu");
employeeObject.setUrlAvatar(Constant.URL_FEMALE);
}
employeeObject.setBirthdayEmployee("01/01/1990");
referenceEmployee.child(user.getUid()).setValue(employeeObject);
referenceDomain.push().setValue(domain);
Toast.makeText(SignUpActivity.this, "Dang ky thanh cong!!!", Toast.LENGTH_SHORT).show();
isFirst[0] = false;
SharedPreferences preferences = SignUpActivity.this.getSharedPreferences(Constant.PREFERENCE_NAME, MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putString(Constant.PREFERENCE_DOMAIN, domain);
editor.apply();
startActivity(new Intent(SignUpActivity.this, SignInActivity.class));
}
}
});
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class AddEmployeeAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull EmployeeViewHolder holder, final int position) {
EmployeeObject employeeObject = employeeObjectList.get(position);
holder.tvNameEmployee.setText(employeeObject.getNameEmployee());
Glide.with(context).load(employeeObject.getUrlAvatar()).into(holder.imgAvatar);
}
use of aunguyen.quanlycongviec.Object.EmployeeObject in project NienLuanChuyenNganh-Android by AuNguyenTrungNguyen.
the class AddEmployeeActivity method signUp.
private void signUp() {
SharedPreferences preferences = AddEmployeeActivity.this.getSharedPreferences(Constant.PREFERENCE_NAME, MODE_PRIVATE);
final String id = preferences.getString(Constant.PREFERENCE_KEY_ID, null);
final String domain = preferences.getString(Constant.PREFERENCE_DOMAIN, null);
final String username = edtUsername.getText().toString();
final String password = edtPassword.getText().toString();
final String fullName = edtFullName.getText().toString();
final String phone = edtPhone.getText().toString();
final String address = edtAddress.getText().toString();
final DatabaseReference referenceEmployee;
referenceEmployee = databaseEmployee.getReference(Constant.NODE_NHAN_VIEN);
if (!username.equals("") && !password.equals("") && !fullName.equals("")) {
mAuth.createUserWithEmailAndPassword(username + domain, password).addOnCompleteListener(AddEmployeeActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseUser user = mAuth.getCurrentUser();
EmployeeObject employeeObject = new EmployeeObject();
if (rdbAdmin.isChecked()) {
employeeObject.setAccountType("0");
} else {
employeeObject.setAccountType("1");
}
employeeObject.setIdEmployee(user.getUid());
employeeObject.setIdManage(id);
employeeObject.setUsernameEmployee(username + domain);
if (!phone.equals("")) {
employeeObject.setPhoneEmployee(phone);
} else {
employeeObject.setPhoneEmployee("");
}
if (!address.equals("")) {
employeeObject.setAddressEmployee(address);
} else {
employeeObject.setAddressEmployee("");
}
employeeObject.setNameEmployee(fullName);
if (rdbMale.isChecked()) {
employeeObject.setGenderEmployee("Nam");
employeeObject.setUrlAvatar(Constant.URL_MALE);
} else {
employeeObject.setGenderEmployee("Nu");
employeeObject.setUrlAvatar(Constant.URL_FEMALE);
}
employeeObject.setBirthdayEmployee("01/01/1990");
referenceEmployee.child(user.getUid()).setValue(employeeObject);
Toast.makeText(AddEmployeeActivity.this, "Dang ky thanh cong!!!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
Aggregations