"Blood Donation Android Application": A Mini Project Report On

Download as pdf or txt
Download as pdf or txt
You are on page 1of 77

A Mini Project Report On

“Blood Donation Android Application”


Submitted in partial fulfillment of the requirements
For the award of the Degree of

BACHELOR OF TECHNOLOGY
In
COMPUTER SCIENCE AND ENGINEERING
By

YAHYA (18H11A0541)
ADHITHYA (18U61A0514)
AQUIB AHMED (18U61A0501)
ABDUL DANISH (18U61A0502)

Under the Guidance of


Mrs. G. Pavani
Assistant Professor

Department of Computer Science and Engineering


GLOBAL INSTITUTE OF ENGINEERING & TECHNOLOGY
(Affilated to JNTU, Hyderabad. Approved by NAAC & AICTE, New Delhi)
Recognized under section 2(f) of UGC Act 1956
Chilkur (village), Moinabad (mandal), R.R.Dist-501504
2018-2022
An NAAC Accredited Institution
(Approved by AICTE & Affiliated to JNTUH)
(Recognized Under Section 2(f) Of UGC Act 1956) Survey No. 179,
Chilkur (V), Moinabad (M), Ranga Reddy Dist. T.S. Phone:
9985096961, 8790101015
E-Mail: principal.giet.u6@gmail.com/gietcsedepartment@gmail.com
JNTUH Code (U6) ECE – EEE –CSM- CSE - CIVIL – ME – MBA - M. Tech EAMCET Code - (GLOB)

Department of Computer Science and Engineering

Date: 05-01-2022

CERTIFICATE
This is to certify that the project work entitled “Blood Donation Android Application”,
is a bonafide work of ADHITHYA (18U61A0514), AQUIB AHMED (18U61A0501), ABDUL
DANISH (18U61A0502) & YAHYA (18H11A0541) submitted in partial fulfillment of the
requirement for the award of Bachelor of Technology in Computer Science and Engineering during
the Academic year 2021-22. This is further certified that the work done under my guidance, and
the results of this work have not been submitted elsewhere for the award of any other degree or
diploma.

INTERNAL GUIDE HEAD OF DEPARTMENT


Mrs. G. Pavani Mr. Syed Mazharuddin

Assistant Professor Associate Professor

EXTERNAL EXAMINER

_______________________
ACKNOWLEDGEMENT

We are thankful to our guide Mrs. G. Pavani, Assistant Professor of CSE Department for
her valuable guidance for successful completion of this project.
We express our sincere thanks to Mr. Syed Mazharuddin, Project Coordinator for giving
us an opportunity to undertake the project “Blood Donation Android Application” and for
enlightening us on various aspects of our project work and assistance in the evaluation of
material and facts. He not only encouraged us to take up this topic but also given valuable
guidance in assessing facts and arriving at conclusions.
We are also most obliged and grateful to Mr. Syed Mazharuddin, Associate Professor and
Head, Department of CSE for giving us guidance in completing this project successfully. We
express our heart-felt gratitude to our Vice-Principal Mr. G Ahmed Zeeshan, Co-Ordinator
Internal Quality Assurance Cell (IQAC) for his constant guidance, cooperation, motivation and
support which have always kept us going ahead.
We owe a lot of gratitude to him for always being there for us. We are also most obliged
and grateful to our Principal Prof. Dr. K. Sivalingam for giving us guidance in completing this
project successfully.
We also thank our parents for their constant encourage and support without which the
project would have not come to an end. Last but not the least, we would also like to thank all our
class mates who have extended their cooperation during our project work.

ADHITHYA (18U61A0514)
AQUIB AHMED (18U61A0501)
ABDUL DANISH (18U61A0502)
YAHYA (18H11A0541)
DECLARATION

We hereby declare that the project work entitled BLOOD DONATION ANDROID
APPLICATION, submitted to Department of Computer Science and Engineering, Global
Institute of Engineering & Technology, Moinabad, affiliated to JNTUH, Hyderabad in partial
fulfillment of the requirement for the award of the degree of BACHELOR OF TECHNOLOGY
in Computer Science and Engineering is the work done by us and has not been submitted elsewhere
for the award of any degree or diploma.

ADHITHYA (18U61A0514)
AQUIB AHMED (18U61A0501)
ABDUL DANISH (18U61A0502)
YAHYA (18H11A0541)
VISION:
The vision of the department is to produce professional computer science engineers
who can meet the expectations of the globe and contribute to the advancement of
engineering and technology which involves creativity and innovations by providing
an excellent learning environment with thebest quality facilities.

MISSION:

1. To provide the students with a practical and qualitative education in a modern


technical environment that will help to improve their abilities and skills in solving
programming problems effectively with different ideas and knowledge.
2. To infuse the scientific temper in the students towards the research and development
in Computer Science and Engineering trends.
3. To mould the graduates to assume leadership roles by possessing good
communication skills, an appreciation for their social and ethical responsibility in a
global setting, and the ability to work effectively as team members.

PROGRAMME EDUCATIONAL OBJECTIVES:

 PEO1: To provide graduates with a good foundation in mathematics, sciences


and engineering fundamentals required to solve engineering problems that will
facilitate them to find employment inMNC’s and / or to pursue post graduate
studies with an appreciation for lifelong learning.
 PEO2: To provide graduates with analytical and problem-solving skills to
design algorithms, other hardware / software systems, and inculcate
professional ethics, inter- personal skills to work in a multi-cultural team.
 PEO3: To facilitate graduates to get familiarized with the art software /
hardware tools, imbibing creativity and innovation that would enable them to
develop cutting edge technologies of multi- disciplinary nature for societal
development.

PROGRAMME OUTCOMES:

 PO 1: Engineering knowledge: Apply the knowledge of mathematics, science,


engineering fundamentals and an engineering specialization to the solution of
complex engineering problems.
 PO 2: Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural science and engineering sciences
 PO 3: Design/development of solutions: design solutions for complex engineering
problems and design system components or processes that meet the specified needs
with appropriate consideration for the public health and safety, and the cultural,
societal and environmental considerations.
 PO 4: Conduct investigations of complex problems: use research-based
knowledge and research methods including design of experiments, analysis and
interpretation of data, and synthesis of the Information to provide valid conclusions.
 PO 5: Modern tool usage: create, select and apply appropriate techniques,
resources and modern engineering and IT tools including prediction and
modeling to complex engineering activities with an understanding of the limitations.
 PO 6: The engineer and society: apply reasoning informed by the contextual
knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.
 PO 7: Environment sustainability: understand the impact of the professional
engineering solutions in the societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
 PO 8: Ethics: apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
 PO 9: Individual and team work: function effectively as an individual and as
a member or leader in diverse teams, and in multidisciplinary settings.
 PO 10: Communication: communicate effectively on complex engineering
activities with the engineering community and with society at large, such as, being
able to comprehend and write effective reports and design documentation,
make effective presentations, and give and receive clear instructions.

 PO 11: Project management and finance: demonstrate knowledge and


understanding of the engineering and management principles and apply these to one’s
own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.

 PO 12: Lifelong learning: recognize the need for, and have the preparation and
ability to engage in independent and lifelong learning in the broader context of
technological change.

PROGRAMME SPECIFIC OUTCOMES:

 PSO1: An Ability to Apply the fundamentals of mathematics, Computer


Science and Engineering Knowledge to analyze and develop computer programs
in the areas related to Algorithms, System Software, Web Designing,
Networking and Data mining for efficient Design of computer-based system to
deal with Real Time Problems.
 PSO2: Ability to implement the Professional Engineering solutions for the
betterment of Society, and able to communicate with professional Ethics
effectively.
Blood Donation Android Application

ABSTRACT:

“Blood Point” is a mobile-based project developed in android platform. This Java android project
provides an easy and fast way to search for blood donors. This app enables users to find blood in
emergency situations. Here Users can easily find the details of donors and receivers through their
mobiles. Users need to register with the application to view all the information which is available
on the app. The user can search the details and find the details of the blood donors. Users can get
brief details about the donor’s contact details including their location. The user can make a call or
message directly by using this application.

1
Department of CSE
Blood Donation Android Application

TABLE OF CONTENTS:

List of figures 03
1. Introduction 04
1.1 Objective 05
1.2 Purpose 06
1.3 Existing Model 07
1.4 Proposed Model 07
2. Literature survey 08
2.1 E-Donation Application 09
2.2 Mobile donor Tracker 10
3. System analysis 11
3.1 Class Diagram 12
3.2 Use Case Diagram 13
3.3 Sequence Diagram 14
4. System Requirement Specification 15
4.1 Software Requirements 16
4.2 Hardware Requirements 16
5. System Implementation 17
5.1 Introduction 18
5.2 Android Studio 18
5.3 Understanding IDEs & SDK 19
5.4 Firebase 21
5.5 Project Hierarchy 22
5.5.1 Logical Implementation (Java) 23
5.5.2 Design Implementation (XML) 59
6. Result 64
7. Conclusion 69
8. Reference 70

2
Department of CSE
Blood Donation Android Application

List of Figures

Figure Number Figure Name Page Number


3.1 Class diagram 12
3.2 Use case diagram 13
3.3 Sequence Diagram 14
5.5 Project Hierarchy 22
5.5.1.1 Java Program Folder 23
5.5.1.2 Activity Files 23
5.5.1.3 Adapter Files 36
5.5.1.4 Fragment Files 40
5.5.1.5 View Model Files 52
5.5.2.1 Design Hierarchy 59
5.5.2.2 Starting Page of application 60
5.5.2.3 Layout XML Files 61
5.5.2.4 login 61
5.5.2.5 Registration 61
5.5.2.6 Dashboard 61
5.5.2.7 Home View 62
5.5.2.8 Search Blood Donor 62
5.5.2.9 Find nearby Hospitals 62
5.5.2.10 Menu 62
5.5.2.11 Values 63
6.1 Authentication Database 65
6.2 Real time databases 66
6.3 Donor Database 67
6.4 Post database 67
6.5 User database 68

3
Department of CSE
Blood Donation Android Application

Chapter 1
Introduction

4
Department of CSE
Blood Donation Android Application

Overview:
Over the past few years, India has been focused on improving health indicators across rural
and urban areas. However, ensuring safe and adequate blood, which is fundamental to our
healthcare system, still remains a huge challenge and a gap area. Despite all its efforts, India fell
short of 1.9 million units of blood in 2016-17 – equivalent to 60 tankers. If you account for the
challenges specific to a country like India – poor health-seeking behavior, higher disease burden,
limited access to healthcare facilities – having a robust blood system is the critical need of the
hour.

Even today, India is heavily dependent on replacement blood donation, wherein family or
friends are asked to donate blood in lieu of the units given to a patient. However, this form of blood
donation does not necessarily replace the blood group or quantity administered and leads to
increased risk of transfusion-transmissible infections.
A blood donation is a process whereby a person voluntarily has blood drawn to be used for
future transfusions when in need at hospitals for treatment procedures that require them. Donation
may be of whole blood (blood drawn directly from the body) or of specific components of the
blood; such as red blood cells, white blood cells, plasma, and platelets. Blood banks often
participate in the process of collecting blood and other procedures such as managing stocks,
approving blood requests and updating donation information.

“Blood Point” is an android application to collect or donate blood easily. Users who have
an android phone & active internet connection can contact and start searching for a donor easily
through this application. The purpose of this application is to help people belonging to rural areas.
The Blood Bank Android Project is one of the great technical life saver applications. The
main aim of this application is to reduce the time spent in searching of blood donors in case of
emergency. This system will keep track of all the latest updates relevant to the people who donate
blood and who had donated blood in case of emergency.

This Blood Bank Android Project system will specify all the details related to the donor
such as their name, their address, their mobile number, their blood group and so on. The one who
need blood, just have to login into the system which will hardly take few seconds and then the one
who needs the blood get access to all the available group of bloods in nearby blood banks as well
as details of those who can donate blood in urgent.

5
Department of CSE
Blood Donation Android Application

1.1 Objective:

The main aim of developing this system is to provide blood to the people who are in
need of blood. The number of persons who are in need of blood are increasing in large number
day by day. Using this system user can search blood group available in the city and he can also
get contact number of the donor who has the same blood group he needs. In order to help people
who are in need of blood, this Online Blood Bank management system can be used effectively
for getting the details of available blood groups and user can also get contact number of the
blood donors having the same blood group and within the same city. So if the blood group is not
available in the blood bank user can request the donor to donate the blood to him and save
someone life. Using this bank management system people can register himself or herself who
want to donate blood. To register in the system they have to enter their contact information like
address, mobile number, Blood group, etc.

This blood bank management system is easily available to everyone. When a person
want to donate blood he can by looking at the list of people who want blood (have to register to
the system). Donor registration is very easy, to get register to the system he have to fill up
registration form. After submitting the registration form he can create username and password.
Donor have to give information like blood group, contact details etc. donor can also change his
account information when he wants using his username and password.

Using this blood bank system people can search blood group available which they are
needed. They check it online using our blood bank app. If in case blood group is not available
in blood bank they can also get contact numbers of the persons who has the same blood group
he is need. And he can request the person to donate the blood for saving someone life. Our
system also allow user to search online the person who have the same blood group he needs and
if he find a donor in his city then we give him all details of the donor, if he doesn’t find any
donor then he is given the contact numbers and addresses of the Life Saving Contact Persons.

1.2 Purpose:
 To bridge the gap between blood banks, hospitals, volunteer donors and needy
people, through this system.
 To facilitate the search process for needy people and make it easier than before.
 To reduce the data entry process.

6
Department of CSE
Blood Donation Android Application

 To use GPS service for locating the hospitals, blood banks & volunteer donors to
know if the seeker is near to or not.
 Some blood types are rare so the system can find the required donors with the
required blood type easily from the huge database by using search feature in the
android app.

Scope of the project:

The application was designed to maximize the blood donation potential of millions of
healthy smartphone owners which is currently underwhelming given that the degree of
voluntarism is low, with different blood collecting organizations resorting to schools among
other institutions of learning in order to organize the blood donation drives. By maximizing the
blood donation potential of the healthy smartphone users, there will be a lot more blood units in
stock for when patients require it while also going along way in enabling Uganda improve its
compliance in ensuring the number of blood units in stock corresponds to the 1% of the total
population as per World Bank Regulations.

1.3 Existing Model:


Blood Donation System was a labour Work as people search for blood with respective
group types by going through formalities manually such as going to a hospital or blood bank
center.
Searching for blood types on ground cost time and efforts in case of emergency.

1.4 Proposed Model:


Blood Point application is made to bridge gap between donors and recipient where anyone can
seek the blood of any group type.

It is a mobile application so the cost of time and labor work will be less compare to existing
model
One can contact the seeker or donor and complete their transaction formalities via on phone

7
Department of CSE
Blood Donation Android Application

Chapter 2
Literature Survey

8
Department of CSE
Blood Donation Android Application

2.1 E-Blood Donation System:

According to Deeptha. H the E-Blood Donation System Using Location Tracking is a


system that bridges the gap between blood donors and the people in need for blood. It synchronizes
blood donors and users with the help of Internet and through it, registered users can view the
availability of donors and can send Request for blood to the donor matching with blood
requirement and can be ordered online when required. The Android application can be accessed
only by the donors to receive the blood donation notifications and the requesting users and
hospitals to search the nearest donors and notify them. The functionality of the E-Blood Donation
System resembles that of A FRAMEWORK FOR A SMART SOCIAL BLOOD DONATION
SYSTEM BASED ON MOBILE CLOUD COMPUTING proposed by Almetwally, M. C. Figure
2.1: Shows the architecture of E-Blood Donation system After installation of the application a user
is provided with two options: Login and sign in. If the person has already registered, then he/she
has to login. If not, he/she has to create an account
providing basic details like name, address, contact, date of birth, blood group, email id etc. Once
the user registration is complete, he/she can check various blood banks that are located. The user
gets various options on screen:
1. Search Donors
2. Request for blood
3. View contact for donors
The user can select any of the option and according to the selected option he/she will get
the information. The user can also get the exact path from his/her location to blood bank or hospital
by using Global Positioning System (GPS). The details of the blood banks, hospitals etc. are saved
in database and only the administrator has access to the database.
This application has the following results: The system provides very less paper work and
turns the present manual system in to computerized system. This provides a means to connect
people who are in need of blood and willing donors. With the application, blood donation becomes
more effective. The system also helps to reduce the time required to deliver required blood to the
needy in cases of emergency. The Android application can also be used by the people interested
in donating their blood by locating their nearest blood bank. The web application provides a way
of communication between the hospitals and the blood banks.

2.2 Mobile Blood Donor Tracker:

The Mobile Blood Donor Tracker proposed by Samy. S, [6] is a mobile application that
connects users with Blood Centers to facilitate the blood collection from donors during
emergencies, facilitate the communication of blood donors with each other and facilitate the
communication of blood donors with the Hospital blood center. It is an application developed by
making use of the following technologies: MySQL database-used by the application to manage
the low-level work of data by sending it commands, Service based location-a software application

9
Department of CSE
Blood Donation Android Application

for IP capable mobile devices, Android-the Linux based open source platform backed by Google,
and the Android System Architecture, among others. The documentation on this application makes
a case for leveraging the increasing number of smart phone users to enhance the effectiveness of
blood donation.

The number of smart phone users globally will exceed 2 billion in 2016, according to new
statistics from e Marketer-after almost getting there in 2015. Next year, there will be more than
1.91 billion smart phone users nationwide, a figure that will boost an extra 12.6% close to 2.16
billion in 2016., their paper quotes before going on to propose a mobile blood donor tracking
system application that works on Android smart phones.

10
Department of CSE
Blood Donation Android Application

Chapter 3
System Analysis

11
Department of CSE
Blood Donation Android Application

System analysis:
System Analysis in software engineering is, therefore, the activities that comprise software
engineering as a process in the production of software. It is the software process. Our project
mainly works on web application side. In this project, we emphasized system analysis with
different list of Diagrams which are constructed using UML concepts.

3.1 Class Diagram:


The class diagram is the main building block of object-oriented modelling. It is used both
for general conceptual modelling of the systematics of the application, and for detailed modelling
translating the models into programming code. Class diagrams can also be used for data
modeling. The classes in a class diagram represent both the main elements, interactions in the
application, and the classes to be programmed.

Fig 3.1: Class diagram

12
Department of CSE
Blood Donation Android Application

3.2 Use case Diagram:


To model a system the most important aspect is to capture the dynamic behavior. To
clarify a bit in details, dynamic behavior means the behavior of the system when it is running
/operating.

So only static behavior is not sufficient to model a system rather dynamic behavior is more
important than static behavior. In UML there are five diagrams available to model dynamic
nature and use case diagram is one of them. Now as we have to discuss that the use case diagram
is dynamic in nature there should be some internal or external factors for making the interaction.

Fig 3.2: Use Case Diagram

13
Department of CSE
Blood Donation Android Application

3.3 Sequence Diagram:


A Sequence diagram is an interaction diagram that shows how processes operate
with one another and in what order. It is a construct of a Message Sequence Chart. A sequence
diagram shows object interactions arranged in time sequence. It depicts the objects and classes
involved in the scenario and the sequence of messages exchanged between the objects needed to
carry out the functionality of the scenario. Sequence diagrams are typically associated with use
case realizations in the Logical View of the system under development. Sequence diagrams are
sometimes called event diagrams or event scenari

Fig: 3.3: Sequence Diagram

14
Department of CSE
Blood Donation Android Application

Chapter 4
System Specification Requirements

15
Department of CSE
Blood Donation Android Application

4.1 System Specification Requirement:


A system requirement specification (SRS) is an engineering document that explicitly
and. concisely describes a set of requirements. As such, the SRS is of fundamental
importance to technical. planning, system development, quality assurance, and
overall project management.

A basic SRS comprise of 2 categories

 Software Requirements
 Hardware Requirements
4.1.1 Software Requirements:

 Android OS (Android KitKat or Above)


 Google Maps Service
Tools Used:

 Android Studio
 Firebase
 Gradle
Languages Used:

 Java
 XML
4.1.2 Hardware Requirements:

 RAM 3 GB
 Storage 16 GB
 Snapdragon 460 or above

16
Department of CSE
Blood Donation Android Application

Chapter 5
System Implementation

17
Department of CSE
Blood Donation Android Application

5.1 Introduction:
Blood Point is an Android Application build using Java Language. Before moving onto the
Implementation part let us first understand the Tools used for building this application. Following
are the tools used in developing this project.

5.2 Android Studio:


Android Studio is the official, integrated development
environment (IDE) for Google's Android operating system,
built on JetBrains' IntelliJ IDEA software and designed
specifically for Android development. It is available for
download on Windows, macOS and Linux based operating
systems or as a subscription-based service in 2020. It is a
replacement for the Eclipse Android Development Tools (E-
ADT) as the primary IDE for native Android application
development.

Android Studio was announced on May 16, 2013 at the


Google I/O conference. It was in early access preview stage
starting from version 0.1 in May 2013, then entered beta stage starting from version 0.8 which was
released in June 2014. The first stable build was released in December 2014, starting from version
1.0.

On May 7, 2019, Kotlin replaced Java as Google's preferred language for Android app
development. Java is still supported, as is C++.

A specific feature of the Android Studio is an absence of the possibility to switch autosave feature
off.
The following features are provided in the current stable version:

 Gradle-based build support


 Android-specific refactoring and quick fixes
 Lint tools to catch performance, usability, version compatibility and other problems
 ProGuard integration and app-signing capabilities
 Template-based wizards to create common Android designs and components
 A rich layout editor that allows users to drag-and-drop UI components, option to preview
layouts on multiple screen configurations
 Support for building Android Wear apps
 Built-in support for Google Cloud Platform, enabling integration with Firebase Cloud
Messaging (Earlier 'Google Cloud Messaging') and Google App Engine

18
Department of CSE
Blood Donation Android Application

 Android Virtual Device (Emulator) to run and debug apps in the Android studio.
Android Studio supports all the same programming languages of IntelliJ (and CLion) e.g., Java,
C++, and more with extensions, such as Go; and Android Studio 3.0 or later supports Kotlin and
"all Java 7 language features and a subset of Java 8 language features that vary by platform
version." External projects backport some Java 9 features. While IntelliJ states that Android Studio
supports all released Java versions, and Java 12, it's not clear to what level Android Studio supports
Java versions up to Java 12 (the documentation mentions partial Java 8 support). At least some
new language features up to Java 12 are usable in Android.
Once an app has been compiled with Android Studio, it can be published on the Google Play Store.
The application has to be in line with the Google Play Store developer content policy.

SDK:
The Android SDK (software development kit) is a set of development tools used to develop
applications for the Android platform that has become Apple’s biggest rival in the smartphone
space. The Android SDK includes the following:

 Required libraries
 Debugger.
 An emulator.
 Relevant documentation for the Android application program interfaces (APIs).
 Sample source code.
 Tutorials for the Android OS.

Every time Google releases a new version of Android, a corresponding SDK is also released. To
be able to write programs with the latest features, developers must download and install each
version’s SDK for the particular phone. The SDK essentially represents Android’s delivered
toolkit for a specific version and technology of its operating systems.
The development platforms that are compatible with SDK include operating systems like Windows
(XP or later), Linux (any recent Linux distribution) and Mac OS X (10.4.9 or later). The
components of Android SDK can be downloaded separately. Third-party add-ons are also available
for download.
Although the SDK can be used to write Android programs in the command prompt, the most
common method is by using an integrated development environment (IDE). The recommended
IDE is Eclipse with the Android Development Tools (ADT) plug-in. However, other IDEs, such
as NetBeans or IntelliJ, will also work.
Most of these IDEs provide a graphical interface enabling developers to perform development
tasks faster. Since Android applications are written in Java code, a user should have the Java
Development Kit (JDK) installed.

19
Department of CSE
Blood Donation Android Application

In addition, experts sometimes talk about optimizing the use of SDKs for Android, for instance,
using targeted versioning to eliminate the need for additional wrapped API calls, or may refer to
SDK targeting as “value-added to an Android manifest” that can help with OS implementations,
many recommending setting a target version and a minimum version in the manifest.
Other related resources include tips for optimized installation and the use of the Android SDK
Manager.

5.3 IDEs and Android SDK:


Another way to understand the utility of the IDE and why it may be favored over simple SDK use
is to think about the ways that IDs abstract and facilitate the process of development.

One thing that the IDEs do, as implied above, is consolidate various tools into one single
environment. For example, if an IDE provides functionality for a text editor, compiler and
debugger altogether, (where each of those things would be treated separately in dealing with an
SDK,) that offers evident benefits for the developer.

Experts also explain how IDEs, for example, Netbeans, create graphical user interface or more
user-friendly versions of development environments that would be considered more manually or
basically implemented in SDKs.

A good analogy might be the use of HTML to code webpages contrasted with the emergence of
many platforms, (early ones including Dreamweaver, for example,) that provided GUIs over the
HTML environment for implementation.

By abstracting the underlying tasks in this way, the GUIs make the tasks more accessible to a
wider set of users, and can help to save time and effort. The IDE does this for the Android
developer, although some argue that too many shortcuts compromises the core knowledge that the
developer needs to be confident in a variety of environments.

An Android Virtual Device (AVD) is a configuration that defines the characteristics of an Android
phone, tablet, Wear OS, Android TV, or Automotive OS device that you want to simulate in the
Android Emulator. The AVD Manager is an interface you can launch from Android Studio that
helps you create and manage AVDs.

20
Department of CSE
Blood Donation Android Application

5.4 Firebase:
Firebase is a platform developed by Google for creating
mobile and web applications. It was originally an
independent company founded in 2011. In 2014,
Google acquired the platform and it is now their
flagship offering for app development.
Firebase offers a number of services, including:

 Analytics – Google Analytics for Firebase


offers free, unlimited reporting on as many as
500 separate events. Analytics presents data
about user behavior in iOS and Android apps, enabling better decision-making about
improving performance and app marketing.
 Authentication – Firebase Authentication makes it easy for developers to build secure
authentication systems and enhances the sign-in and onboarding experience for users. This
feature offers a complete identity solution, supporting email and password accounts, phone
auth, as well as Google, Facebook, GitHub, Twitter login and more.
 Cloud messaging – Firebase Cloud Messaging (FCM) is a cross-platform messaging tool
that lets companies reliably receive and deliver messages on iOS, Android and the web at
no cost.
 Realtime database – the Firebase Realtime Database is a cloud-hosted NoSQL database
that enables data to be stored and synced between users in real time. The data is synced
across all clients in real time and is still available when an app goes offline.
 Crashlytics – Firebase Crashlytics is a real-time crash reporter that helps developers track,
prioritize and fix stability issues that reduce the quality of their apps. With crashlytics,
developers spend less time organizing and troubleshooting crashes and more time building
features for their apps.
 Performance – Firebase Performance Monitoring service gives developers insight into the
performance characteristics of their iOS and Android apps to help them determine where
and when the performance of their apps can be improved.
 Test lab – Firebase Test Lab is a cloud-based app-testing infrastructure. With one
operation, developers can test their iOS or Android apps across a variety of devices and
device configurations. They can see the results, including videos, screenshots and logs, in
the Firebase console.

Understanding Project Hierarchy:


Our Android Application is divided into two parts as follows:
1. Logical Implementation (Java folder)
2. Design Implementation (res folder)

21
Department of CSE
Blood Donation Android Application

Android Project is created using 2 different languages, java and xml mainly. The logical
Implementation deals with the working of the android app, java language is used as a logical view.
The design implementation deals with the design structure of our android app, the android studio
generates xml files as we add buttons, create form for our android application. Based on xml
structure the java code is created for every action event such as buttons, forms, drawers etc.

5.5 Project Directory Hierarchy:

Fig 5.5: Project Hierarchy


The Blood Point Folder Consist of following folders. We will discuss about every logical file
present in these folders.

22
Department of CSE
Blood Donation Android Application

5.5.1 Logical Implementation (JAVA)

Fig 5.5.1.1: Java Program Folders

Activities:
Activities folder deals with the activity of a user on an blood point application. Below are the
java files used in activity folder.

Fig 5.5.1.2: Activity Files

Log inactivity:
This java file creates a logical Activity for sign in form of blood point application.
LoginActivity.java

23
Department of CSE
Blood Donation Android Application

package com.android.iunoob.Blood_point.activities;

import android.app.ProgressDialog;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.android.iunoob.Blood_point.R;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;

public class LoginActivity extends AppCompatActivity {

private Button signin, signup, resetpass;


private EditText inputemail, inputpassword;
private FirebaseAuth mAuth;
private ProgressDialog pd;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

pd = new ProgressDialog(this);
pd.setMessage("Loading...");
pd.setCancelable(true);
pd.setCanceledOnTouchOutside(false);

mAuth = FirebaseAuth.getInstance();

if(mAuth.getCurrentUser() != null)
{
Intent intent = new Intent(getApplicationContext(), Dashboard.class);
startActivity(intent);
finish();
}

inputemail = findViewById(R.id.input_username);
inputpassword = findViewById(R.id.input_password);

signin = findViewById(R.id.button_login);

24
Department of CSE
Blood Donation Android Application

signup = findViewById(R.id.button_register);
resetpass = findViewById(R.id.button_forgot_password);

signin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

final String email = inputemail.getText().toString()+"";


final String password = inputpassword.getText().toString()+"";

try {
if(password.length()>0 && email.length()>0) {
pd.show();
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(LoginActivity.this, new
OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Toast.makeText(getApplicationContext(),
"Authentication Failed",
Toast.LENGTH_LONG).show();
Log.v("error", task.getException().getMessage());
} else {
Intent intent = new Intent(getApplicationContext(), Dashboard.class);
startActivity(intent);
finish();
}
pd.dismiss();
}
});
}
else
{
Toast.makeText(getApplicationContext(), "Please fill all the field.",
Toast.LENGTH_LONG).show();
}

} catch (Exception e)
{
e.printStackTrace();
}
}
});

signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ProfileActivity.class);
startActivity(intent);
}

25
Department of CSE
Blood Donation Android Application

});

resetpass.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), RestorePassword.class);
startActivity(intent);
}
});

PostActivity:
The post activity comprises of logical view for posting the request of blood group on a home view list
PostActivity.java
package com.android.iunoob.Blood_point.activities;

import android.app.ProgressDialog;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import com.android.iunoob.Blood_point.R;
import com.android.iunoob.Blood_point.viewmodels.UserData;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
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.Query;
import com.google.firebase.database.ValueEventListener;

import java.util.Calendar;

public class PostActivity extends AppCompatActivity {

ProgressDialog pd;

26
Department of CSE
Blood Donation Android Application

EditText text1, text2;


Spinner spinner1, spinner2;
Button btnpost;

FirebaseDatabase fdb;
DatabaseReference db_ref;
FirebaseAuth mAuth;

Calendar cal;
String uid;
String Time, Date;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_post);

pd = new ProgressDialog(this);
pd.setMessage("Loading...");
pd.setCancelable(true);
pd.setCanceledOnTouchOutside(false);

getSupportActionBar().setTitle("Post Blood Request");


getSupportActionBar().setDisplayHomeAsUpEnabled(true);

text1 = findViewById(R.id.getMobile);
text2 = findViewById(R.id.getLocation);

spinner1 = findViewById(R.id.SpinnerBlood);
spinner2 = findViewById(R.id.SpinnerDivision);

btnpost = findViewById(R.id.postbtn);

cal = Calendar.getInstance();

int day = cal.get(Calendar.DAY_OF_MONTH);


int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int hour = cal.get(Calendar.HOUR);
int min = cal.get(Calendar.MINUTE);
month+=1;
Time = "";
Date = "";
String ampm="AM";

if(cal.get(Calendar.AM_PM) ==1)
{
ampm = "PM";
}

27
Department of CSE
Blood Donation Android Application

if(hour<10)
{
Time += "0";
}
Time += hour;
Time +=":";

if(min<10) {
Time += "0";
}

Time +=min;
Time +=(" "+ampm);

Date = day+"/"+month+"/"+year;

FirebaseUser cur_user = mAuth.getInstance().getCurrentUser();

if(cur_user == null)
{
startActivity(new Intent(PostActivity.this, LoginActivity.class));
} else {
uid = cur_user.getUid();
}

mAuth = FirebaseAuth.getInstance();
fdb = FirebaseDatabase.getInstance();
db_ref = fdb.getReference("posts");

try {
btnpost.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pd.show();
final Query findname = fdb.getReference("users").child(uid);

if(text1.getText().length() == 0)
{
Toast.makeText(getApplicationContext(), "Enter your contact number!",
Toast.LENGTH_LONG).show();
}
else if(text2.getText().length() == 0)
{
Toast.makeText(getApplicationContext(), "Enter your location!",
Toast.LENGTH_LONG).show();
}
else {
findname.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {

28
Department of CSE
Blood Donation Android Application

if (dataSnapshot.exists()) {

db_ref.child(uid).child("Name").setValue(dataSnapshot.getValue(UserData.class).getName());
db_ref.child(uid).child("Contact").setValue(text1.getText().toString());
db_ref.child(uid).child("Address").setValue(text2.getText().toString());

db_ref.child(uid).child("Division").setValue(spinner2.getSelectedItem().toString());

db_ref.child(uid).child("BloodGroup").setValue(spinner1.getSelectedItem().toString());
db_ref.child(uid).child("Time").setValue(Time);
db_ref.child(uid).child("Date").setValue(Date);
Toast.makeText(PostActivity.this, "Your post has been created successfully",
Toast.LENGTH_LONG).show();
startActivity(new Intent(PostActivity.this, Dashboard.class));

} else {
Toast.makeText(getApplicationContext(), "Database error occured.",
Toast.LENGTH_LONG).show();
}

@Override
public void onCancelled(DatabaseError databaseError) {
Log.d("User", databaseError.getMessage());

}
});
}
}
});
}
catch (Exception e)
{
e.printStackTrace();
}
pd.dismiss();

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}

return super.onOptionsItemSelected(item);
}
}

29
Department of CSE
Blood Donation Android Application

ProfileActivity:
The profile activity deals with the profile updating activity where a user can change its name, blood group
and other details
ProfileActivity.java
package com.android.iunoob.Blood_point.activities;

import android.app.ProgressDialog;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

import com.android.iunoob.Blood_point.R;
import com.android.iunoob.Blood_point.viewmodels.UserData;
import com.google.firebase.auth.FirebaseAuth;
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.Query;
import com.google.firebase.database.ValueEventListener;

public class ProfileActivity extends AppCompatActivity {

private EditText inputemail, inputpassword, retypePassword, fullName, address, contact;


private FirebaseAuth mAuth;
private Button btnSignup;
private ProgressDialog pd;
private Spinner gender, bloodgroup, division;

private boolean isUpdate = false;

private DatabaseReference db_ref, donor_ref;


private FirebaseDatabase db_User;
private CheckBox isDonor;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
pd = new ProgressDialog(this);
pd.setMessage("Loading...");

30
Department of CSE
Blood Donation Android Application

pd.setCancelable(true);
pd.setCanceledOnTouchOutside(false);
pd.show();
setContentView(R.layout.activity_profile);

db_User = FirebaseDatabase.getInstance();
db_ref = db_User.getReference("users");
donor_ref = db_User.getReference("donors");
mAuth = FirebaseAuth.getInstance();

inputemail = findViewById(R.id.input_userEmail);
inputpassword = findViewById(R.id.input_password);
retypePassword = findViewById(R.id.input_password_confirm);
fullName = findViewById(R.id.input_fullName);
gender = findViewById(R.id.gender);
address = findViewById(R.id.inputAddress);
division = findViewById(R.id.inputDivision);
bloodgroup = findViewById(R.id.inputBloodGroup);
contact = findViewById(R.id.inputMobile);
isDonor = findViewById(R.id.checkbox);

btnSignup = findViewById(R.id.button_register);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

if (mAuth.getCurrentUser() != null) {

inputemail.setVisibility(View.GONE);
inputpassword.setVisibility(View.GONE);
retypePassword.setVisibility(View.GONE);
btnSignup.setText("Update Profile");
pd.dismiss();
/// getActionBar().setTitle("Profile");
getSupportActionBar().setTitle("Profile");
findViewById(R.id.image_logo).setVisibility(View.GONE);
isUpdate = true;

Query Profile = db_ref.child(mAuth.getCurrentUser().getUid());


Profile.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

UserData userData = dataSnapshot.getValue(UserData.class);

if (userData != null) {
pd.show();
fullName.setText(userData.getName());
gender.setSelection(userData.getGender());
address.setText(userData.getAddress());
contact.setText(userData.getContact());
bloodgroup.setSelection(userData.getBloodGroup());

31
Department of CSE
Blood Donation Android Application

division.setSelection(userData.getDivision());
Query donor = donor_ref.child(division.getSelectedItem().toString())
.child(bloodgroup.getSelectedItem().toString())
.child(mAuth.getCurrentUser().getUid());

donor.addListenerForSingleValueEvent(new ValueEventListener() {

@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

if(dataSnapshot.exists())
{
isDonor.setChecked(true);
isDonor.setText("Unmark this to leave from donors");
}
else
{
Toast.makeText(ProfileActivity.this, "Your are not a donor! Be a donor and save
life by donating blood.",
Toast.LENGTH_LONG).show();
}
pd.dismiss();

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d("User", databaseError.getMessage());
}

});
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d("User", databaseError.getMessage());
}
});

} else pd.dismiss();
btnSignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String email = inputemail.getText().toString();
final String password = inputpassword.getText().toString();
final String ConfirmPassword = retypePassword.getText().toString();
final String Name = fullName.getText().toString();
final int Gender = gender.getSelectedItemPosition();

32
Department of CSE
Blood Donation Android Application

final String Contact = contact.getText().toString();


final int BloodGroup = bloodgroup.getSelectedItemPosition();
final String Address = address.getText().toString();
final int Division = division.getSelectedItemPosition();
final String blood = bloodgroup.getSelectedItem().toString();
final String div = division.getSelectedItem().toString();

try {

if (Name.length() <= 2) {
ShowError("Name");
fullName.requestFocusFromTouch();
} else if (Contact.length() <= 11) {
ShowError("Contact Number");
contact.requestFocusFromTouch();
} else if (Address.length() <= 2) {
ShowError("Address");
address.requestFocusFromTouch();
} else {
if (!isUpdate) {
if (email.length() == 0) {
ShowError("Email ID");
inputemail.requestFocusFromTouch();
} else if (password.length() <= 5) {
ShowError("Password");
inputpassword.requestFocusFromTouch();
} else if (password.compareTo(ConfirmPassword) != 0) {
Toast.makeText(ProfileActivity.this, "Password did not match!",
Toast.LENGTH_LONG)
.show();
retypePassword.requestFocusFromTouch();
} else {
pd.show();
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(ProfileActivity.this, task -> {

if (!task.isSuccessful()) {
Toast.makeText(ProfileActivity.this, "Registration failed! try agian.",
Toast.LENGTH_LONG)
.show();
Log.v("error", task.getException().getMessage());
} else {
String id = mAuth.getCurrentUser().getUid();
db_ref.child(id).child("Name").setValue(Name);
db_ref.child(id).child("Gender").setValue(Gender);
db_ref.child(id).child("Contact").setValue(Contact);
db_ref.child(id).child("BloodGroup").setValue(BloodGroup);
db_ref.child(id).child("Address").setValue(Address);
db_ref.child(id).child("Division").setValue(Division);

if(isDonor.isChecked())

33
Department of CSE
Blood Donation Android Application

donor_ref.child(div).child(blood).child(id).child("UID").setValue(id).toString();

donor_ref.child(div).child(blood).child(id).child("LastDonate").setValue("Don't donate yet!");

donor_ref.child(div).child(blood).child(id).child("TotalDonate").setValue(0);

donor_ref.child(div).child(blood).child(id).child("Name").setValue(Name);

donor_ref.child(div).child(blood).child(id).child("Contact").setValue(Contact);

donor_ref.child(div).child(blood).child(id).child("Address").setValue(Address);

Toast.makeText(getApplicationContext(), "Welcome, your account has


been created!", Toast.LENGTH_LONG)
.show();
Intent intent = new Intent(ProfileActivity.this, Dashboard.class);
startActivity(intent);

finish();
}
pd.dismiss();

});
}

} else {

String id = mAuth.getCurrentUser().getUid();
db_ref.child(id).child("Name").setValue(Name);
db_ref.child(id).child("Gender").setValue(Gender);
db_ref.child(id).child("Contact").setValue(Contact);
db_ref.child(id).child("BloodGroup").setValue(BloodGroup);
db_ref.child(id).child("Address").setValue(Address);
db_ref.child(id).child("Division").setValue(Division);

if(isDonor.isChecked())
{
donor_ref.child(div).child(blood).child(id).child("UID").setValue(id).toString();
donor_ref.child(div).child(blood).child(id).child("LastDonate").setValue("Don't
donate yet!");
donor_ref.child(div).child(blood).child(id).child("TotalDonate").setValue(0);
donor_ref.child(div).child(blood).child(id).child("Name").setValue(Name);
donor_ref.child(div).child(blood).child(id).child("Contact").setValue(Contact);
donor_ref.child(div).child(blood).child(id).child("Address").setValue(Address);

}
else

34
Department of CSE
Blood Donation Android Application

donor_ref.child(div).child(blood).child(id).removeValue();

}
Toast.makeText(getApplicationContext(), "Your account has been updated!",
Toast.LENGTH_LONG)
.show();
Intent intent = new Intent(ProfileActivity.this, Dashboard.class);
startActivity(intent);
finish();
}
pd.dismiss();

}
} catch (Exception e) {
e.printStackTrace();
}

}
});
}

private void ShowError(String error) {

Toast.makeText(ProfileActivity.this, "Please, Enter a valid "+error,


Toast.LENGTH_LONG).show();
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
}

return super.onOptionsItemSelected(item);
}
}

35
Department of CSE
Blood Donation Android Application

Adapters:

Fig 5.5.1.3:P Adapter Files

BloodRequestAdapter:
This adapter deals with the request of blood group, the reciepents check the homeview where donors
posts their requirements.
BloodRequestAdapter.java
package com.android.iunoob.Blood_point.adapters;

import android.graphics.Color;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.iunoob.Blood_point.R;
import com.android.iunoob.Blood_point.viewmodels.CustomUserData;

import java.util.List;

public class BloodRequestAdapter extends RecyclerView.Adapter<BloodRequestAdapter.PostHolder> {

private List<CustomUserData> postLists;

public class PostHolder extends RecyclerView.ViewHolder


{
TextView Name, bloodgroup, Address, contact, posted;

public PostHolder(@NonNull View itemView) {


super(itemView);

Name = itemView.findViewById(R.id.reqstUser);
contact = itemView.findViewById(R.id.targetCN);
bloodgroup = itemView.findViewById(R.id.targetBG);
Address = itemView.findViewById(R.id.reqstLocation);
posted = itemView.findViewById(R.id.posted);

36
Department of CSE
Blood Donation Android Application

}
}

public BloodRequestAdapter(List<CustomUserData> postLists)


{
this.postLists = postLists;
}

@Override
public PostHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

View listitem = LayoutInflater.from(viewGroup.getContext())


.inflate(R.layout.request_list_item, viewGroup, false);

return new PostHolder(listitem);


}

@Override
public void onBindViewHolder(PostHolder postHolder, int i) {

if(i%2==0)
{
postHolder.itemView.setBackgroundColor(Color.parseColor("#C13F31"));
}
else
{
postHolder.itemView.setBackgroundColor(Color.parseColor("#FFFFFF"));
}

CustomUserData customUserData = postLists.get(i);


postHolder.Name.setText("Posted by: "+customUserData.getName());
postHolder.Address.setText("From: "+customUserData.getAddress()+",
"+customUserData.getDivision());
postHolder.bloodgroup.setText("Needs "+customUserData.getBloodGroup());
postHolder.posted.setText("Posted on:"+customUserData.getTime()+",
"+customUserData.getDate());
postHolder.contact.setText(customUserData.getContact());

@Override
public int getItemCount() {
return postLists.size();
}
}

37
Department of CSE
Blood Donation Android Application

SearchDonorAdapter:
The list of donors is numerous; thus this adapter is used to find donors with respective to their location.
SearchDonorAdapter.java
package com.android.iunoob.Blood_point.adapters;

import android.graphics.Color;
import androidx.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.android.iunoob.Blood_point.R;
import com.android.iunoob.Blood_point.viewmodels.DonorData;

import java.util.List;

public class SearchDonorAdapter extends RecyclerView.Adapter<SearchDonorAdapter.PostHolder> {

private List<DonorData> postLists;

public class PostHolder extends RecyclerView.ViewHolder


{
TextView Name, Address, contact, posted, totaldonate;

public PostHolder(@NonNull View itemView) {


super(itemView);

Name = itemView.findViewById(R.id.donorName);
contact = itemView.findViewById(R.id.donorContact);
totaldonate = itemView.findViewById(R.id.totaldonate);
Address = itemView.findViewById(R.id.donorAddress);
posted = itemView.findViewById(R.id.lastdonate);

}}
public SearchDonorAdapter(List<DonorData> postLists)
{
this.postLists = postLists;
}

@Override
public PostHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

View listitem = LayoutInflater.from(viewGroup.getContext())


.inflate(R.layout.search_donor_item, viewGroup, false);

38
Department of CSE
Blood Donation Android Application

return new PostHolder(listitem);


}

@Override
public void onBindViewHolder(PostHolder postHolder, int i) {

if(i%2==0)
{
postHolder.itemView.setBackgroundColor(Color.parseColor("#C13F31"));
}
else
{
postHolder.itemView.setBackgroundColor(Color.parseColor("#FFFFFF"));
}
DonorData donorData = postLists.get(i);
postHolder.Name.setText("Name: "+donorData.getName());
postHolder.contact.setText(donorData.getContact());
postHolder.Address.setText("Address: "+donorData.getAddress());
postHolder.totaldonate.setText("Total Donation: "+donorData.getTotalDonate()+" times");
postHolder.posted.setText("Last Donation: "+donorData.getLastDonate());

@Override
public int getItemCount() {
return postLists.size();
}
}

39
Department of CSE
Blood Donation Android Application

Fragments:
Below are the fragments files that are used in our android project

Fig 5.5.1.4: Fragment Files

AboutUs:
The AboutUS java file is an static view where it displays project credits and developers details
AboutUs.java
package com.android.iunoob.Blood_point.fragments;

import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.app.Fragment;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.iunoob.Blood_point.R;

public class AboutUs extends Fragment {


private TextView textView;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.aboutus, container, false);
getActivity().setTitle("About us");

textView = view.findViewById(R.id.txtv);
Linkify.addLinks(textView, Linkify.ALL);
return view;

40
Department of CSE
Blood Donation Android Application

}
}

HomeView:
This java file is used to show blood reciepents information in the home page
HomeView.java
package com.android.iunoob.Blood_point.fragments;

import android.app.ProgressDialog;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.app.Fragment;

import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.android.iunoob.Blood_point.R;
import com.android.iunoob.Blood_point.adapters.BloodRequestAdapter;
import com.android.iunoob.Blood_point.viewmodels.CustomUserData;
import com.google.firebase.auth.FirebaseAuth;
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.Query;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;
import java.util.List;

public class HomeView extends Fragment {

private View view;

41
Department of CSE
Blood Donation Android Application

private RecyclerView recentPosts;

private DatabaseReference donor_ref;


FirebaseAuth mAuth;
private BloodRequestAdapter restAdapter;
private List<CustomUserData> postLists;
private ProgressDialog pd;

public HomeView() {

@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {

view = inflater.inflate(R.layout.home_view_fragment, container, false);


recentPosts = (RecyclerView) view.findViewById(R.id.recyleposts);

recentPosts.setLayoutManager(new LinearLayoutManager(getContext()));

donor_ref = FirebaseDatabase.getInstance().getReference();
postLists = new ArrayList<>();

pd = new ProgressDialog(getActivity());
pd.setMessage("Loading...");
pd.setCancelable(true);
pd.setCanceledOnTouchOutside(false);

mAuth = FirebaseAuth.getInstance();
getActivity().setTitle("Blood Point");

restAdapter = new BloodRequestAdapter(postLists);


RecyclerView.LayoutManager pmLayout = new LinearLayoutManager(getContext());
recentPosts.setLayoutManager(pmLayout);
recentPosts.setItemAnimator(new DefaultItemAnimator());
recentPosts.addItemDecoration(new DividerItemDecoration(getActivity(),
LinearLayoutManager.VERTICAL));
recentPosts.setAdapter(restAdapter);

AddPosts();
return view;

}
private void AddPosts()
{
Query allposts = donor_ref.child("posts");
pd.show();
allposts.addListenerForSingleValueEvent(new ValueEventListener() {
@Override

42
Department of CSE
Blood Donation Android Application

public void onDataChange(@NonNull DataSnapshot dataSnapshot) {

if(dataSnapshot.exists()) {

for (DataSnapshot singlepost : dataSnapshot.getChildren()) {


CustomUserData customUserData = singlepost.getValue(CustomUserData.class);
postLists.add(customUserData);
restAdapter.notifyDataSetChanged();
}
pd.dismiss();
}
else
{
Toast.makeText(getActivity(), "Database is empty now!",
Toast.LENGTH_LONG).show();
}
}

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

Log.d("User", databaseError.getMessage());

}
});

@Override
public void onResume() {
super.onResume();
}

@Override
public void onStop() {
super.onStop();
}

@Override
public void onPause() {
super.onPause();
}

@Override
public void onDestroy() {
super.onDestroy();
}
}

43
Department of CSE
Blood Donation Android Application

NearByHospitalActivity:
This java file deals with the logical Implementation of the search system which make use of Maps api
i.e., google services.
NearByHospitalActivity.java
package com.android.iunoob.Blood_point.fragments;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;

import com.android.iunoob.Blood_point.R;
import com.android.iunoob.Blood_point.viewmodels.GetNearbyPlacesData;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.SettingsClient;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.tasks.OnSuccessListener;

import org.jetbrains.annotations.Nullable;

public class NearByHospitalActivity extends Fragment implements


OnMapReadyCallback, GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener, LocationListener {

44
Department of CSE
Blood Donation Android Application

private GoogleMap mMap;


View view;
private GoogleApiClient client;
private LocationRequest locationRequest;
Location lastlocation;
private Marker currentLocationmMarker = null;
private static final int Permission_Request = 99;
int PROXIMITY_RADIUS = 10000;
private FusedLocationProviderClient fusedLocationProviderClient;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {

view = inflater.inflate(R.layout.near_by_hospitals, container, false);


getActivity().setTitle("Nearest hospitals");

return view;
}

@Override
public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(getActivity());

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {


checkLocationPermission();
}

SupportMapFragment mapFragment = (SupportMapFragment)


getChildFragmentManager().findFragmentById(R.id.gMap);
if (mapFragment != null) {
mapFragment.getMapAsync(this);
}
else
{
Toast.makeText(getActivity(), "MapFragment is null, why?", Toast.LENGTH_LONG).show();
}

@SuppressLint("MissingPermission")
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull
int[] grantResults) {
switch (requestCode) {
case Permission_Request:

45
Department of CSE
Blood Donation Android Application

if (grantResults.length > 0 && grantResults[0] ==


PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (client == null) {
buildGoogleApiClient();
}
mMap.setMyLocationEnabled(true);
mMap.setTrafficEnabled(true);
}
} else {
Toast.makeText(getActivity(), "Permission Denied", Toast.LENGTH_LONG).show();
}
}
}

@Override
public void onMapReady(@NonNull GoogleMap googleMap) {

mMap = googleMap;

if (ContextCompat.checkSelfPermission(requireActivity(),
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
mMap.setTrafficEnabled(true);

protected synchronized void buildGoogleApiClient() {


client = new
GoogleApiClient.Builder(requireActivity().getApplicationContext()).addConnectionCallbacks(this).addO
nConnectionFailedListener(this).addApi(LocationServices.API).build();
client.connect();

}
@Override
public void onConnected(@Nullable Bundle bundle) {
locationRequest = new LocationRequest();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();


builder.addLocationRequest(locationRequest);
LocationSettingsRequest locationSettingsRequest = builder.build();

SettingsClient settingsClient = LocationServices.getSettingsClient(getActivity());


settingsClient.checkLocationSettings(locationSettingsRequest);

46
Department of CSE
Blood Donation Android Application

if (ActivityCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(getActivity(),
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getActivity(), "You need to enable permissions to display location !",
Toast.LENGTH_SHORT).show();
}

fusedLocationProviderClient.getLastLocation().addOnSuccessListener(getActivity(), new
OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
ShowHospitals(location.getLatitude(), location.getLongitude());
}
});

private String getUrl(double latitude, double longitude, String nearbyPlace) {

StringBuilder googlePlaceUrl = new


StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
googlePlaceUrl.append("location=").append(latitude).append(",").append(longitude);
googlePlaceUrl.append("&radius=").append(PROXIMITY_RADIUS);
googlePlaceUrl.append("&type=").append(nearbyPlace);
googlePlaceUrl.append("&sensor=true");
googlePlaceUrl.append("&key=" + "AIzaSyAmeQ8IwQWBcmFLRpKARu7LM1TlShQKmfg");

Log.d("NearbyHospitalActivity", "url = " + googlePlaceUrl.toString());

return googlePlaceUrl.toString();
}

public void checkLocationPermission() {


if (ContextCompat.checkSelfPermission(requireActivity(),
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
Manifest.permission.ACCESS_FINE_LOCATION)) {
ActivityCompat.requestPermissions(getActivity(), new
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, Permission_Request);
} else {
ActivityCompat.requestPermissions(getActivity(), new
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, Permission_Request);
}

}
}

47
Department of CSE
Blood Donation Android Application

@Override
public void onConnectionSuspended(int i) {

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {

@Override
public void onLocationChanged(Location location) {
lastlocation = location;
LatLng latLng = new LatLng(location.getLatitude() , location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Location");

markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
currentLocationmMarker = mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomBy(0));

@Override
public void onStart() {
super.onStart();

if(client!=null)
{
client.connect();
}
}

public void ShowHospitals(double latitude, double longitude)


{
mMap.clear();
Object dataTransfer[] = new Object[2];
GetNearbyPlacesData getNearbyPlacesData = new GetNearbyPlacesData();
String url = getUrl(latitude, longitude, "hospital");
dataTransfer[0] = mMap;
dataTransfer[1] = url;

getNearbyPlacesData.execute(dataTransfer);
Toast.makeText(getContext(), "Showing Nearby Hospitals", Toast.LENGTH_SHORT).show();
}
}

48
Department of CSE
Blood Donation Android Application

SeachDonorFragment:
This java file creates a logical Implementation to find blood donors nearby.
SeachDonorFragment.java
package com.android.iunoob.Blood_point.fragments;

import android.app.ProgressDialog;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.app.Fragment;

import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;

import com.android.iunoob.Blood_point.R;
import com.android.iunoob.Blood_point.adapters.SearchDonorAdapter;
import com.android.iunoob.Blood_point.viewmodels.DonorData;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
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.Query;
import com.google.firebase.database.ValueEventListener;

import java.util.ArrayList;
import java.util.List;

public class SearchDonorFragment extends Fragment {

private View view;

FirebaseAuth mAuth;
FirebaseUser fuser;
FirebaseDatabase fdb;
DatabaseReference db_ref, user_ref;

49
Department of CSE
Blood Donation Android Application

Spinner bloodgroup, division;


Button btnsearch;
ProgressDialog pd;
List<DonorData> donorItem;
private RecyclerView recyclerView;

private SearchDonorAdapter sdadapter;

public SearchDonorFragment() {

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {

view = inflater.inflate(R.layout.search_donor_fragment, container, false);

pd = new ProgressDialog(getActivity());
pd.setMessage("Loading...");
pd.setCancelable(true);
pd.setCanceledOnTouchOutside(false);

mAuth = FirebaseAuth.getInstance();
fuser = mAuth.getCurrentUser();
fdb = FirebaseDatabase.getInstance();
db_ref = fdb.getReference("donors");

bloodgroup = view.findViewById(R.id.btngetBloodGroup);
division = view.findViewById(R.id.btngetDivison);
btnsearch = view.findViewById(R.id.btnSearch);

getActivity().setTitle("Find Blood Donor");

btnsearch.setOnClickListener(new View.OnClickListener() {
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onClick(View v) {
pd.show();
donorItem = new ArrayList<>();
donorItem.clear();
sdadapter = new SearchDonorAdapter(donorItem);
recyclerView = (RecyclerView) view.findViewById(R.id.showDonorList);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
RecyclerView.LayoutManager searchdonor = new LinearLayoutManager(getContext());
recyclerView.setLayoutManager(searchdonor);

50
Department of CSE
Blood Donation Android Application

recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(),
LinearLayoutManager.VERTICAL));
recyclerView.setAdapter(sdadapter);
Query qpath = db_ref.child(division.getSelectedItem().toString())
.child(bloodgroup.getSelectedItem().toString());
qpath.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if(dataSnapshot.exists())
{
for(DataSnapshot singleitem : dataSnapshot.getChildren())
{
DonorData donorData = singleitem.getValue(DonorData.class);
donorItem.add(donorData);
sdadapter.notifyDataSetChanged();
}
}
else
{

Toast.makeText(getActivity(), "Database is empty now!",


Toast.LENGTH_LONG).show();

}
}

@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d("User", databaseError.getMessage());

}
});
pd.dismiss();
}
});
return view;
}

51
Department of CSE
Blood Donation Android Application

Viewmodels:
The view model consists of logical files that are used to fetch and store the details of user which can be
donor or recipient. Below is the list of files used in view model.

Fig 5.5.1.5: ViewModel Files


CustomerUserData:
CustomerUserData.java
package com.android.iunoob.Blood_point.viewmodels;

import java.io.Serializable;

public class CustomUserData implements Serializable {


private String Address, Division, Contact;
private String Name, BloodGroup;
private String Time, Date;

public CustomUserData() {

public CustomUserData(String address, String division, String contact, String name, String
bloodGroup, String time, String date) {
Address = address;
Division = division;
Contact = contact;
Name = name;
BloodGroup = bloodGroup;
Time = time;
Date = date;
}

public String getAddress() {


return Address;
}

public void setAddress(String address) {


this.Address = address;

52
Department of CSE
Blood Donation Android Application

public String getDivision() {


return Division;
}

public void setDivision(String division) {


this.Division = division;
}

public String getContact() {


return Contact;
}

public void setContact(String contact) {


this.Contact = contact;
}

public String getName() {


return Name;
}

public void setName(String name) {


this.Name = name;
}

public String getBloodGroup() {


return BloodGroup;
}

public void setBloodGroup(String bloodGroup) {


this.BloodGroup = bloodGroup;
}

public String getTime() {


return Time;
}

public void setTime(String time) {


this.Time = time;
}

public String getDate() {


return Date;
}

public void setDate(String date) {


this.Date = date;
}
}
}

53
Department of CSE
Blood Donation Android Application

DonorData:
DonorData.java
package com.android.iunoob.Blood_point.viewmodels;

public class DonorData {

private int TotalDonate;


private String LastDonate, Name, Contact, UID, Address;

public DonorData() {

public DonorData(int totalDonate, String lastDonate, String Name, String Contact, String Address,
String UID) {
this.TotalDonate = totalDonate;
this.LastDonate = lastDonate;
this.Name = Name;
this.Contact = Contact;
this.UID = UID;
this.Address = Address;
}

public int getTotalDonate() {


return TotalDonate;
}

public void setTotalDonate(int totalDonate) {


this.TotalDonate = totalDonate;
}

public String getLastDonate() {


return LastDonate;
}

public void setLastDonate(String lastDonate) {


this.LastDonate = lastDonate;
}

public String getUID() {


return UID;
}

public void setUID(String UID) {


this.UID = UID;

54
Department of CSE
Blood Donation Android Application

public String getName() {


return Name;
}

public void setDonorName(String donorName) {


this.Name = Name;
}

public String getContact() {


return Contact;
}

public void setContact(String donorContact) {


this.Contact = Contact;
}

public String getAddress() {


return Address;
}

public void setAddress(String address) {


Address = address;
}
}

GetNearbyPlacesData:
GetNearbyPlacesData.java
package com.android.iunoob.Blood_point.viewmodels;

import android.os.AsyncTask;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

public class GetNearbyPlacesData extends AsyncTask<Object, String, String> {

String googlePlacesData;
GoogleMap mMap;

55
Department of CSE
Blood Donation Android Application

String url;

@Override
protected String doInBackground(Object... objects) {
mMap = (GoogleMap) objects[0];
url = (String) objects[1];

DownloadUrl downloadUrl = new DownloadUrl();


try {
googlePlacesData = downloadUrl.readUrl(url);
} catch (IOException e) {
e.printStackTrace();
}

return googlePlacesData;
}

@Override
protected void onPostExecute(String s) {

List<HashMap<String, String>> nearbyPlaceList;


DataParser parser = new DataParser();
nearbyPlaceList = parser.parse(s);

showNearbyPlaces(nearbyPlaceList);
}

private void showNearbyPlaces(List<HashMap<String, String>> nearbyplaces)


{
for(int i=0; i<nearbyplaces.size(); i++)
{
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String, String> googlePlace = nearbyplaces.get(i);

String PlaceName = googlePlace.get("place_name");


String vicinity = googlePlace.get("vicinity");
double lat = Double.parseDouble(googlePlace.get("lat"));
double lng = Double.parseDouble(googlePlace.get("lng"));

LatLng latLng = new LatLng(lat, lng);


markerOptions.position(latLng);
markerOptions.title(PlaceName+" "+vicinity);

markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));

mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomBy(10));
}

56
Department of CSE
Blood Donation Android Application

}
}

Userdata:
Userdata.java
package com.android.iunoob.Blood_point.viewmodels;

public class UserData {

private String Name, Email, Contact, Address;


private int Gender, BloodGroup, Division;

public UserData() {

public String getContact() {


return Contact;
}

public void setContact(String contact) {


Contact = contact;
}

public String getAddress() {


return Address;
}

public void setAddress(String address) {


this.Address = address;
}

public int getDivision() {


return Division;
}

public void setDivision(int division) {


this.Division = division;
}

public String getName() {


return Name;
}

public int getBloodGroup() {


return BloodGroup;
}

public void setBloodGroup(int bloodGroup) {

57
Department of CSE
Blood Donation Android Application

this.BloodGroup = bloodGroup;
}

public String getEmail() {


return Email;
}

public int getGender() {


return Gender;
}

public void setName(String name) { this.Name = name; }

public void setEmail(String email) {


this.Email = email;
}

public void setGender(int gender) {


this.Gender = gender;
}

58
Department of CSE
Blood Donation Android Application

5.5.2 Design Implementation (XML)

Fig 5.5.2.1: Design Hierarchy


The Design Hierarchy gives structure detail about android component development using xml
scripting language
It builds components within android application
The Above Structure Consist of 4 main components

1. Drawable
2. Layout
3. Menu
4. Values

59
Department of CSE
Blood Donation Android Application

Drawable:
This folder keeps the files of intro application. Intro logo of our android application is displayed
in figure below.

Fig 5.5.2.2: Starting Page of application

Layout:
Layout folder consist of xml files that requires heavy components such as login form,
registration form, dashboard, posting card view etc.,

This Layout manager deals with the internal operation of the application and highly works using
java logical part.
Following are the xml files used in layout manager

60
Department of CSE
Blood Donation Android Application

Fig 5.5.2.3: Layout XML files


Below are Snapshots of different components resides in our application which is build using
above xml files.

Fig 5.5.2.4: login Fig 5.5.2.5: Registration Fig 5.5.2.6: sDashboard

61
Department of CSE
Blood Donation Android Application

Fig 5.5.2.7: homeView Fig 5.5.2.8: Search Adapter Fig 5.5.2.9: Find Near
by Hospital

Menu:
This folder keeps files of menu view that are of 2 types, hamburger menu view and triple dot menu
view. Each menu consists of layouts that displays child layouts.

Here Activity_dashboard_drawer.xml file shows the dashboard view whereas the dashboard.xml
file shows the view of blood information and developers details.

Fig 5.5.2.10: Menu XML Files

Values:
Values folder keeps the values files that are beneficial for entire project, values such as strings
keeps the record of cities and android application, the dimens and colors file keep the values of

62
Department of CSE
Blood Donation Android Application

colors used and dimens of each layout. Google maps api keeps the values used for google maps
navigation.

Fig 5.5.2.11: Values XML Files

63
Department of CSE
Blood Donation Android Application

Chapter 6
Results

64
Department of CSE
Blood Donation Android Application

Storing Information on database:


Database:
Google Firebase is implemented to store data in real time database. Firebase mainly works at
Google-backed application development software that enables developers to develop iOS, Android
and Web apps. Firebase provides tools for tracking analytics, reporting and fixing app crashes,
creating marketing and product experiment.
Two types of information is retrieved from clients
i. Authentication data
ii. Registration & Blood Posting data

Authentication:
Authentication is the process of recognizing a user's identity. ... Different systems may require
different types of credentials to ascertain a user's identity. The credential often takes the form of a
password, which is a secret and known only to the individual and the system.

In firebase we can manage & manipulate user authentication data by adding, disabling, removing
or reseting the password of the user.

Fig 6.1: Authentication Database

65
Department of CSE
Blood Donation Android Application

Registration & Blood Posting Data:


A real-time database is a database system which uses real-time processing to handle workloads
whose state is constantly changing. Real-time databases are useful for accounting, banking, law,
medical records, multi-media, process control, reservation systems, and scientific data analysis.
Here Blood recipients as well as donors data is collected and showed in RTDB.
Three types of data is retrieved as shown in figures below
1. Donor data: Donor data is collected.
2. User data: User (Recipient) data is collected.
3. Posting data: the data which is posted on the blood point app is stored in RTDB.

Fig 6.2: Real Time Database

66
Department of CSE
Blood Donation Android Application

Fig 6.3: Donor database

Fig 6.4: Posts database

67
Department of CSE
Blood Donation Android Application

Fig 6.5: User database

68
Department of CSE
Blood Donation Android Application

7. Conclusion:
A majority of the donors were willing to be regular donors. The donors showed positive effects
like a sense of satisfaction after the donation. Creating an opportunity for blood donation by
conducting many blood donation camps may increase the voluntary blood donations.

Our Application is a beneficial Software, by building a life saving application which helps in
donation of blood as well as finding blood hospitals nearby, bridges the gap of donating blood
online in case of emergency.

"The best way to save someone's life is by DONATING BLOOD".

69
Department of CSE
Blood Donation Android Application

8. Reference:
 https://developer.android.com/guide
 https://en.wikipedia.org/wiki/Android_Studio
 https://firebase.google.com/docs/build
 Telusko: https://www.youtube.com/channel/UC59K-uG2A5ogwIrHw4bmlEg
 https://en.wikipedia.org/wiki/Blood_donation_in_India
 https://science.thewire.in/health/india-must-change-its-approach-to-blood-donation/

70
Department of CSE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy