Search in sources :

Example 1 with EmployeeObject

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();
            }
        });
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) SharedPreferences(android.content.SharedPreferences) DatabaseReference(com.google.firebase.database.DatabaseReference) EmployeeObject(aunguyen.quanlycongviec.Object.EmployeeObject) ValueEventListener(com.google.firebase.database.ValueEventListener) ProgressDialog(android.app.ProgressDialog) DataSnapshot(com.google.firebase.database.DataSnapshot)

Example 2 with EmployeeObject

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();
}
Also used : ArrayList(java.util.ArrayList) EmployeeObject(aunguyen.quanlycongviec.Object.EmployeeObject) Intent(android.content.Intent)

Example 3 with EmployeeObject

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();
        }
    });
}
Also used : EmployeeObject(aunguyen.quanlycongviec.Object.EmployeeObject) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 4 with EmployeeObject

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();
    }
}
Also used : FirebaseDatabase(com.google.firebase.database.FirebaseDatabase) DatabaseReference(com.google.firebase.database.DatabaseReference) SharedPreferences(android.content.SharedPreferences) ArrayList(java.util.ArrayList) EmployeeObject(aunguyen.quanlycongviec.Object.EmployeeObject) ProgressDialog(android.app.ProgressDialog) Date(java.util.Date) JobObject(aunguyen.quanlycongviec.Object.JobObject) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with EmployeeObject

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());
            }
        });
    }
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) SharedPreferences(android.content.SharedPreferences) DatabaseReference(com.google.firebase.database.DatabaseReference) EmployeeObject(aunguyen.quanlycongviec.Object.EmployeeObject) ValueEventListener(com.google.firebase.database.ValueEventListener) DataSnapshot(com.google.firebase.database.DataSnapshot)

Aggregations

EmployeeObject (aunguyen.quanlycongviec.Object.EmployeeObject)11 SharedPreferences (android.content.SharedPreferences)6 DatabaseReference (com.google.firebase.database.DatabaseReference)6 DataSnapshot (com.google.firebase.database.DataSnapshot)4 DatabaseError (com.google.firebase.database.DatabaseError)4 ValueEventListener (com.google.firebase.database.ValueEventListener)4 ArrayList (java.util.ArrayList)4 ProgressDialog (android.app.ProgressDialog)3 Intent (android.content.Intent)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 AuthResult (com.google.firebase.auth.AuthResult)2 FirebaseUser (com.google.firebase.auth.FirebaseUser)2 CardView (android.support.v7.widget.CardView)1 JobObject (aunguyen.quanlycongviec.Object.JobObject)1 FirebaseDatabase (com.google.firebase.database.FirebaseDatabase)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1