0% found this document useful (0 votes)
2 views27 pages

Code

Uploaded by

AbhijeetMaluche
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views27 pages

Code

Uploaded by

AbhijeetMaluche
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

AddProjectActivity.

java

package [Link];

import [Link];

public class AddProjectActivity extends AppCompatActivity {

// creating variables for our button, edit text,

// firebase database, database reference, progress bar.

private Button addProjectBtn;

private TextInputEditText ProjectNameEdt, ProjectDescEdt, ProjectPriceEdt, bestSuitedEdt,


ProjectImgEdt, ProjectLinkEdt;

FirebaseDatabase firebaseDatabase;

DatabaseReference databaseReference;

private ProgressBar loadingPB;

private String ProjectID;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_add_Project);

// initializing all our variables.

addProjectBtn = findViewById([Link]);

ProjectNameEdt = findViewById([Link]);

ProjectDescEdt = findViewById([Link]);

ProjectPriceEdt = findViewById([Link]);

bestSuitedEdt = findViewById([Link]);

ProjectImgEdt = findViewById([Link]);

ProjectLinkEdt = findViewById([Link]);

loadingPB = findViewById([Link]);

firebaseDatabase = [Link]();

// on below line creating our database reference.

databaseReference = [Link]("Projects");

// adding click listener for our add Project button.


[Link](new [Link]() {

@Override

public void onClick(View v) {

[Link]([Link]);

// getting data from our edit text.

String ProjectName = [Link]().toString();

String ProjectDesc = [Link]().toString();

String ProjectPrice = [Link]().toString();

String bestSuited = [Link]().toString();

String ProjectImg = [Link]().toString();

String ProjectLink = [Link]().toString();

ProjectID = ProjectName;

// on below line we are passing all data to our modal class.

ProjectRVModal ProjectRVModal = new ProjectRVModal(ProjectID, ProjectName,


ProjectDesc, ProjectPrice, bestSuited, ProjectImg, ProjectLink);

// on below line we are calling a add value event

// to pass data to firebase database.

[Link](new ValueEventListener() {

@Override

public void onDataChange(@NonNull DataSnapshot snapshot) {

// on below line we are setting data in our firebase database.

[Link](ProjectID).setValue(ProjectRVModal);

// displaying a toast message.

[Link]([Link], "Project Added..",


Toast.LENGTH_SHORT).show();

// starting a main activity.

startActivity(new Intent([Link], [Link]));

@Override

public void onCancelled(@NonNull DatabaseError error) {

// displaying a failure message on below line.


[Link]([Link], "Fail to add Project..",
Toast.LENGTH_SHORT).show();

});

});

[Link]

package [Link];

import [Link];

import [Link];

public class ProjectRVAdapter extends [Link]<[Link]> {

// creating variables for our list, context, interface and position.

private final ArrayList<ProjectRVModal> ProjectRVModalArrayList;

private final Context context;

private final ProjectClickInterface ProjectClickInterface;

int lastPos = -1;

// creating a constructor.

public ProjectRVAdapter(ArrayList<ProjectRVModal> ProjectRVModalArrayList, Context context,


ProjectClickInterface ProjectClickInterface) {

[Link] = ProjectRVModalArrayList;

[Link] = context;

[Link] = ProjectClickInterface;

@NonNull

@Override
public [Link] onCreateViewHolder(@NonNull ViewGroup parent, int
viewType) {

// inflating our layout file on below line.

View view = [Link](context).inflate([Link].Project_rv_item, parent, false);

return new ViewHolder(view);

@Override

public void onBindViewHolder(@NonNull [Link] holder, int position) {

// setting data to our recycler view item on below line.

ProjectRVModal ProjectRVModal = [Link](position);

[Link]([Link]());

[Link]("Rs. " + [Link]());

[Link]().load([Link]()).into([Link]);

// adding animation to recycler view item on below line.

setAnimation([Link], position);

[Link](new [Link]() {

@Override

public void onClick(View v) {

[Link](position);

});

private void setAnimation(View itemView, int position) {

if (position > lastPos) {

// on below line we are setting animation.

Animation animation = [Link](context,


[Link].slide_in_left);

[Link](animation);

lastPos = position;

}
}

@Override

public int getItemCount() {

return [Link]();

public static class ViewHolder extends [Link] {

// creating variable for our image view and text view on below line.

private final ImageView ProjectIV;

private final TextView ProjectTV;

private final TextView ProjectPriceTV;

public ViewHolder(@NonNull View itemView) {

super(itemView);

// initializing all our variables on below line.

ProjectIV = [Link]([Link]);

ProjectTV = [Link]([Link]);

ProjectPriceTV = [Link]([Link]);

// creating a interface for on click

public interface ProjectClickInterface {

void onProjectClick(int position);

[Link]

package [Link];

import [Link];
import [Link];

public class ProjectRVModal implements Parcelable {

// creating variables for our different fields.

private String ProjectName;

private String ProjectDescription;

private String ProjectPrice;

private String bestSuitedFor;

private String ProjectImg;

private String ProjectLink;

private String ProjectId;

public String getProjectId() {

return ProjectId;

public void setProjectId(String ProjectId) {

[Link] = ProjectId;

// creating an empty constructor.

public ProjectRVModal() {

protected ProjectRVModal(Parcel in) {

ProjectName = [Link]();

ProjectId = [Link]();

ProjectDescription = [Link]();
ProjectPrice = [Link]();

bestSuitedFor = [Link]();

ProjectImg = [Link]();

ProjectLink = [Link]();

public static final Creator<ProjectRVModal> CREATOR = new Creator<ProjectRVModal>() {

@Override

public ProjectRVModal createFromParcel(Parcel in) {

return new ProjectRVModal(in);

@Override

public ProjectRVModal[] newArray(int size) {

return new ProjectRVModal[size];

};

// creating getter and setter methods.

public String getProjectName() {

return ProjectName;

public void setProjectName(String ProjectName) {

[Link] = ProjectName;

public String getProjectDescription() {

return ProjectDescription;

}
public void setProjectDescription(String ProjectDescription) {

[Link] = ProjectDescription;

public String getProjectPrice() {

return ProjectPrice;

public void setProjectPrice(String ProjectPrice) {

[Link] = ProjectPrice;

public String getBestSuitedFor() {

return bestSuitedFor;

public void setBestSuitedFor(String bestSuitedFor) {

[Link] = bestSuitedFor;

public String getProjectImg() {

return ProjectImg;

public void setProjectImg(String ProjectImg) {

[Link] = ProjectImg;

public String getProjectLink() {

return ProjectLink;

}
public void setProjectLink(String ProjectLink) {

[Link] = ProjectLink;

public ProjectRVModal(String ProjectId, String ProjectName, String ProjectDescription, String


ProjectPrice, String bestSuitedFor, String ProjectImg, String ProjectLink) {

[Link] = ProjectName;

[Link] = ProjectId;

[Link] = ProjectDescription;

[Link] = ProjectPrice;

[Link] = bestSuitedFor;

[Link] = ProjectImg;

[Link] = ProjectLink;

@Override

public int describeContents() {

return 0;

@Override

public void writeToParcel(Parcel dest, int flags) {

[Link](ProjectName);

[Link](ProjectId);

[Link](ProjectDescription);

[Link](ProjectPrice);

[Link](bestSuitedFor);

[Link](ProjectImg);

[Link](ProjectLink);
}

[Link]

package [Link];

import [Link];

import [Link];

public class EditProjectActivity extends AppCompatActivity {

// creating variables for our edit text, firebase database,

// database reference, Project rv modal,progress bar.

private TextInputEditText ProjectNameEdt, ProjectDescEdt, ProjectPriceEdt, bestSuitedEdt,


ProjectImgEdt, ProjectLinkEdt;

FirebaseDatabase firebaseDatabase;

DatabaseReference databaseReference;

ProjectRVModal ProjectRVModal;

private ProgressBar loadingPB;

// creating a string for our Project id.

private String ProjectID;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_edit_Project);

// initializing all our variables on below line.

Button updateProjectBtn = findViewById([Link]);

Button deleteProjectBtn = findViewById([Link]);

ProjectNameEdt = findViewById([Link]);

ProjectDescEdt = findViewById([Link]);

ProjectPriceEdt = findViewById([Link]);

bestSuitedEdt = findViewById([Link]);
ProjectImgEdt = findViewById([Link]);

ProjectLinkEdt = findViewById([Link]);

loadingPB = findViewById([Link]);

firebaseDatabase = [Link]();

// on below line we are getting our modal class on which we have passed.

ProjectRVModal = getIntent().getParcelableExtra("Project");

if (ProjectRVModal != null) {

// on below line we are setting data to our edit text from our modal class.

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

ProjectID = [Link]();

// on below line we are initializing our database reference and we are adding a child as our
Project id.

databaseReference = [Link]("Projects").child(ProjectID);

// on below line we are adding click listener for our add Project button.

[Link](new [Link]() {

@Override

public void onClick(View v) {

// on below line we are making our progress bar as visible.

[Link]([Link]);

// on below line we are getting data from our edit text.

String ProjectName = [Link]().toString();

String ProjectDesc = [Link]().toString();

String ProjectPrice = [Link]().toString();


String bestSuited = [Link]().toString();

String ProjectImg = [Link]().toString();

String ProjectLink = [Link]().toString();

// on below line we are creating a map for

// passing a data using key and value pair.

Map<String, Object> map = new HashMap<>();

[Link]("ProjectName", ProjectName);

[Link]("ProjectDescription", ProjectDesc);

[Link]("ProjectPrice", ProjectPrice);

[Link]("bestSuitedFor", bestSuited);

[Link]("ProjectImg", ProjectImg);

[Link]("ProjectLink", ProjectLink);

[Link]("ProjectId", ProjectID);

// on below line we are calling a database reference on

// add value event listener and on data change method

[Link](new ValueEventListener() {

@Override

public void onDataChange(@NonNull DataSnapshot snapshot) {

// making progress bar visibility as gone.

[Link]([Link]);

// adding a map to our database.

[Link](map);

// on below line we are displaying a toast message.

[Link]([Link], "Project Updated..",


Toast.LENGTH_SHORT).show();

// opening a new activity after updating our coarse.

startActivity(new Intent([Link], [Link]));

@Override
public void onCancelled(@NonNull DatabaseError error) {

// displaying a failure message on toast.

[Link]([Link], "Fail to update Project..",


Toast.LENGTH_SHORT).show();

});

});

// adding a click listener for our delete Project button.

[Link](new [Link]() {

@Override

public void onClick(View v) {

// calling a method to delete a Project.

deleteProject();

});

private void deleteProject() {

// on below line calling a method to delete the Project.

[Link]();

// displaying a toast message on below line.

[Link](this, "Project Deleted..", Toast.LENGTH_SHORT).show();

// opening a main activity on below line.

startActivity(new Intent([Link], [Link]));

[Link]

package [Link];
import [Link];

public class MainActivity extends AppCompatActivity implements


[Link] {

// creating variables for fab, firebase database,

// progress bar, list, adapter,firebase auth,

// recycler view and relative layout.

private FloatingActionButton addProjectFAB;

FirebaseDatabase firebaseDatabase;

DatabaseReference databaseReference;

private RecyclerView ProjectRV;

private FirebaseAuth mAuth;

private ProgressBar loadingPB;

private ArrayList<ProjectRVModal> ProjectRVModalArrayList;

private ProjectRVAdapter ProjectRVAdapter;

private RelativeLayout homeRL;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_main);

// initializing all our variables.

ProjectRV = findViewById([Link]);

homeRL = findViewById([Link]);

loadingPB = findViewById([Link]);

addProjectFAB = findViewById([Link]);
firebaseDatabase = [Link]();

mAuth = [Link]();

ProjectRVModalArrayList = new ArrayList<>();

// on below line we are getting database reference.

databaseReference = [Link]("Projects");

// on below line adding a click listener for our floating action button.

[Link](new [Link]() {

@Override

public void onClick(View v) {

// opening a new activity for adding a Project.

Intent i = new Intent([Link], [Link]);

startActivity(i);

});

// on below line initializing our adapter class.

ProjectRVAdapter = new ProjectRVAdapter(ProjectRVModalArrayList, this,


this::onProjectClick);

// setting layout malinger to recycler view on below line.

[Link](new LinearLayoutManager(this));

// setting adapter to recycler view on below line.

[Link](ProjectRVAdapter);

// on below line calling a method to fetch Projects from database.

getProjects();

private void getProjects() {

// on below line clearing our list.

[Link]();

// on below line we are calling add child event listener method to read the data.

[Link](new ChildEventListener() {

@Override
public void onChildAdded(@NonNull DataSnapshot snapshot, @Nullable String
previousChildName) {

// on below line we are hiding our progress bar.

[Link]([Link]);

// adding snapshot to our array list on below line.

[Link]([Link]([Link]));

// notifying our adapter that data has changed.

[Link]();

@Override

public void onChildChanged(@NonNull DataSnapshot snapshot, @Nullable String


previousChildName) {

// this method is called when new child is added

// we are notifying our adapter and making progress bar

// visibility as gone.

[Link]([Link]);

[Link]();

@Override

public void onChildRemoved(@NonNull DataSnapshot snapshot) {

// notifying our adapter when child is removed.

[Link]();

[Link]([Link]);

@Override

public void onChildMoved(@NonNull DataSnapshot snapshot, @Nullable String


previousChildName) {

// notifying our adapter when child is moved.


[Link]();

[Link]([Link]);

@Override

public void onCancelled(@NonNull DatabaseError error) {

});

@Override

public void onProjectClick(int position) {

// calling a method to display a bottom sheet on below line.

displayBottomSheet([Link](position));

@Override

public boolean onOptionsItemSelected(@NonNull MenuItem item) {

// adding a click listener for option selected on below line.

int id = [Link]();

switch (id) {

case [Link]:

// displaying a toast message on user logged out inside on click.

[Link](getApplicationContext(), "User Logged Out",


Toast.LENGTH_LONG).show();

// on below line we are signing out our user.

[Link]();

// on below line we are opening our login activity.

Intent i = new Intent([Link], [Link]);

startActivity(i);
[Link]();

return true;

default:

return [Link](item);

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// on below line we are inflating our menu

// file for displaying our menu options.

getMenuInflater().inflate([Link].menu_main, menu);

return true;

private void displayBottomSheet(ProjectRVModal modal) {

// on below line we are creating our bottom sheet dialog.

final BottomSheetDialog bottomSheetTeachersDialog = new BottomSheetDialog(this,


[Link]);

// on below line we are inflating our layout file for our bottom sheet.

View layout = [Link](this).inflate([Link].bottom_sheet_dialog, homeRL);

// setting content view for bottom sheet on below line.

[Link](layout);

// on below line we are setting a cancelable

[Link](false);

[Link](true);

// calling a method to display our bottom sheet.

[Link]();

// on below line we are creating variables for

// our text view and image view inside bottom sheet

// and initializing them with their ids.


TextView ProjectNameTV = [Link]([Link]);

TextView ProjectDescTV = [Link]([Link]);

TextView suitedForTV = [Link]([Link]);

TextView priceTV = [Link]([Link]);

ImageView ProjectIV = [Link]([Link]);

// on below line we are setting data to different views on below line.

[Link]([Link]());

[Link]([Link]());

[Link]("Suited for " + [Link]());

[Link]("Rs." + [Link]());

[Link]().load([Link]()).into(ProjectIV);

Button viewBtn = [Link]([Link]);

Button editBtn = [Link]([Link]);

// adding on click listener for our edit button.

[Link](new [Link]() {

@Override

public void onClick(View v) {

// on below line we are opening our EditProjectActivity on below line.

Intent i = new Intent([Link], [Link]);

// on below line we are passing our Project modal

[Link]("Project", modal);

startActivity(i);

});

// adding click listener for our view button on below line.

[Link](new [Link]() {

@Override

public void onClick(View v) {

// on below line we are navigating to browser

// for displaying Project details from its url


Intent i = new Intent(Intent.ACTION_VIEW);

[Link]([Link]([Link]()));

startActivity(i);

});

[Link]

package [Link];

import [Link];

import [Link];

import [Link];

public class RegistrationActivity extends AppCompatActivity {

// creating variables for edit text and textview,

// firebase auth, button and progress bar.

private TextInputEditText userNameEdt, passwordEdt, confirmPwdEdt;

private TextView loginTV;

private Button registerBtn;

private FirebaseAuth mAuth;

private ProgressBar loadingPB;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_registration);
// initializing all our variables.

userNameEdt = findViewById([Link]);

passwordEdt = findViewById([Link]);

loadingPB = findViewById([Link]);

confirmPwdEdt = findViewById([Link]);

loginTV = findViewById([Link]);

registerBtn = findViewById([Link]);

mAuth = [Link]();

// adding on click for login tv.

[Link](new [Link]() {

@Override

public void onClick(View v) {

// opening a login activity on clicking login text.

Intent i = new Intent([Link], [Link]);

startActivity(i);

});

// adding click listener for register button.

[Link](new [Link]() {

@Override

public void onClick(View v) {

// hiding our progress bar.

[Link]([Link]);

// getting data from our edit text.

String userName = [Link]().toString();

String pwd = [Link]().toString();

String cnfPwd = [Link]().toString();


// checking if the password and confirm password is equal or not.

if (![Link](cnfPwd)) {

[Link]([Link], "Please check both having same password..",


Toast.LENGTH_SHORT).show();

} else if ([Link](userName) && [Link](pwd) &&


[Link](cnfPwd)) {

// checking if the text fields are empty or not.

[Link]([Link], "Please enter your credentials..",


Toast.LENGTH_SHORT).show();

} else {

// on below line we are creating a new user by passing email and password.

[Link](userName,
pwd).addOnCompleteListener(new OnCompleteListener<AuthResult>() {

@Override

public void onComplete(@NonNull Task<AuthResult> task) {

// on below line we are checking if the task is success or not.

if ([Link]()) {

// in on success method we are hiding our progress bar and opening a login
activity.

[Link]([Link]);

[Link]([Link], "User Registered..",


Toast.LENGTH_SHORT).show();

Intent i = new Intent([Link], [Link]);

startActivity(i);

finish();

} else {

// in else condition we are displaying a failure toast message.

[Link]([Link]);
[Link]([Link], "Fail to register user..",
Toast.LENGTH_SHORT).show();

});

});

[Link]

package [Link];

import [Link];

public class SplashActivity extends AppCompatActivity {

TextView wel,voma;

private static int splash_timeout=5000;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_splash);

wel=findViewById([Link]);

voma=findViewById([Link]);

new Handler().postDelayed(new Runnable() {

@Override

public void run() {

Intent splashintent=new Intent([Link],[Link]);

startActivity(splashintent);
finish();

},splash_timeout);

Animation myanim= [Link]([Link],[Link].animation2);

[Link](myanim);

Animation myanima=
[Link]([Link],[Link].splash_screen_animation);

[Link](myanima);

[Link]

package [Link];

import [Link];

import [Link];

public class UserActivityMain extends AppCompatActivity {

Button admin,user;

TextView wel;

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

setContentView([Link].activity_user_main);

wel = findViewById([Link]);

admin=findViewById([Link]);

user=findViewById([Link]);
Animation myanim = [Link]([Link], [Link].animation2);

[Link](myanim);

[Link](new [Link]() {

@Override

public void onClick(View view) {

Intent intent=new Intent([Link],[Link]);

startActivity(intent);

finish();

});

[Link](new [Link]() {

@Override

public void onClick(View view) {

Intent intent=new Intent([Link],[Link]);

startActivity(intent);

finish();

});

[Link]

package [Link];

import [Link];

import [Link];

import [Link];

public class EmployeeDBHandler extends SQLiteOpenHelper {


private static final String DATABASE_NAME = "[Link]";

private static final int DATABASE_VERSION = 1;

public static final String TABLE_EMPLOYEES = "employees";

public static final String COLUMN_ID = "empID";

public static final String COLUMN_FIRST_NAME = "firstname";

public static final String COLUMN_LAST_NAME = "lastname";

public static final String COLUMN_GENDER = "gender";

public static final String COLUMN_HIRE_DATE = "hiredata";

public static final String COLUMN_DEPT = "dept";

private static final String TABLE_CREATE = "CREATE TABLE " + TABLE_EMPLOYEES + " (" +
COLUMN_ID

+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + COLUMN_FIRST_NAME + " TEXT, " +
COLUMN_LAST_NAME

+ " TEXT, " + COLUMN_GENDER + " TEXT, " + COLUMN_HIRE_DATE + " NUMERIC, " +
COLUMN_DEPT + " TEXT " + ")";

public EmployeeDBHandler(Context context) {

super(context, DATABASE_NAME, null, DATABASE_VERSION);

@Override

public void onCreate(SQLiteDatabase sqLiteDatabase) {

[Link](TABLE_CREATE);

@Override

public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {


[Link]("DROP TABLE IF EXISTS " + TABLE_EMPLOYEES);

[Link](TABLE_CREATE);

You might also like