-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from JapneetRajput/firebase
Projects and leave
- Loading branch information
Showing
118 changed files
with
3,044 additions
and
761 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/example/workflow/AdapterEmployee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.example.workflow; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class AdapterEmployee extends RecyclerView.Adapter<AdapterEmployee.MyViewHolder> { | ||
|
||
ArrayList<EmployeeListModel> mList; | ||
Context context; | ||
|
||
public AdapterEmployee(Context context , ArrayList<EmployeeListModel> mList){ | ||
|
||
this.mList = mList; | ||
this.context = context; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View v = LayoutInflater.from(context).inflate(R.layout.employee_card , parent ,false); | ||
return new MyViewHolder(v); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { | ||
EmployeeListModel model = mList.get(position); | ||
holder.name.setText("Name: "+ model.getFirstName()+ " " + model.getLastName()); | ||
holder.position.setText("Position: "+model.getPosition()); | ||
holder.department.setText("Department: "+model.getDepartment()); | ||
holder.email.setText("Email: "+model.getEmail()); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return mList.size(); | ||
} | ||
|
||
public static class MyViewHolder extends RecyclerView.ViewHolder{ | ||
|
||
TextView name , position,department, email; | ||
|
||
public MyViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
|
||
name = itemView.findViewById(R.id.employeeName); | ||
department = itemView.findViewById(R.id.employeeDepartment); | ||
position = itemView.findViewById(R.id.employeePosition); | ||
email = itemView.findViewById(R.id.employeeEmail); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
app/src/main/java/com/example/workflow/AdapterProjects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.example.workflow; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class AdapterProjects extends RecyclerView.Adapter<AdapterProjects.MyViewHolder> { | ||
|
||
Context context; | ||
ArrayList<ProjectList> list; | ||
private static RecyclerViewClickListener listener; | ||
|
||
public AdapterProjects(Context context, ArrayList<ProjectList> list, RecyclerViewClickListener listener) { | ||
this.context = context; | ||
this.list = list; | ||
AdapterProjects.listener =listener; | ||
} | ||
public AdapterProjects(Context context, ArrayList<ProjectList> list) { | ||
this.context = context; | ||
this.list = list; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
View v = LayoutInflater.from(context).inflate(R.layout.notices_card,parent,false); | ||
return new MyViewHolder(v); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { | ||
ProjectList ProjectList = list.get(position); | ||
holder.title.setText(ProjectList.getTitle()); | ||
holder.description.setText(ProjectList.getDescription()); | ||
holder.department.setText(ProjectList.getDepartment()); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return list.size(); | ||
} | ||
|
||
public static class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ | ||
|
||
TextView description, title,department; | ||
public MyViewHolder(@NonNull View itemView) { | ||
super(itemView); | ||
title=itemView.findViewById(R.id.NoticeTitle); | ||
description=itemView.findViewById(R.id.NoticeDesc); | ||
department=itemView.findViewById(R.id.NoticeDepartment); | ||
itemView.setOnClickListener(this); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
listener.onClick(itemView, getAdapterPosition()); | ||
} | ||
} | ||
|
||
public interface RecyclerViewClickListener{ | ||
void onClick(View v, int position); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.example.workflow; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
|
||
import com.google.firebase.database.DataSnapshot; | ||
import com.google.firebase.database.DatabaseError; | ||
import com.google.firebase.database.DatabaseReference; | ||
import com.google.firebase.database.FirebaseDatabase; | ||
import com.google.firebase.database.ValueEventListener; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class EmployeeList extends AppCompatActivity { | ||
|
||
DatabaseReference root = FirebaseDatabase.getInstance().getReference().child("Users"); | ||
private AdapterEmployee adapter; | ||
private ArrayList<EmployeeListModel> list; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_employee_list); | ||
getSupportActionBar().hide(); | ||
|
||
RecyclerView recyclerView = findViewById(R.id.EmployeeRecyclerView); | ||
recyclerView.setHasFixedSize(true); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
|
||
list = new ArrayList<>(); | ||
adapter = new AdapterEmployee(this ,list ); | ||
|
||
recyclerView.setAdapter(adapter); | ||
|
||
root.addValueEventListener(new ValueEventListener() { | ||
@Override | ||
public void onDataChange(@NonNull DataSnapshot snapshot) { | ||
|
||
for (DataSnapshot dataSnapshot : snapshot.getChildren()){ | ||
EmployeeListModel model = dataSnapshot.getValue(EmployeeListModel.class); | ||
list.add(model); | ||
} | ||
adapter.notifyDataSetChanged(); | ||
} | ||
|
||
@Override | ||
public void onCancelled(@NonNull DatabaseError error) { | ||
|
||
} | ||
}); | ||
} | ||
@Override | ||
public void onBackPressed() { | ||
startActivity(new Intent(EmployeeList.this,HomeActivity.class)); | ||
finish(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
app/src/main/java/com/example/workflow/EmployeeListModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.example.workflow; | ||
|
||
public class EmployeeListModel { | ||
|
||
String firstName,lastName,email,position,department; | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public String getPosition() { | ||
return position; | ||
} | ||
|
||
public String getDepartment() { | ||
return department; | ||
} | ||
} |
Oops, something went wrong.