0% found this document useful (0 votes)
49 views34 pages

Sweet Delivery App Development

The document describes the Sweethouse mobile application, an Android-based project for delivering sweet and dessert products to customers. It includes features for customer and admin interfaces, allowing users to purchase products, manage orders, and handle payments through various methods. The document also provides details on the app's structure, including user registration, product management, and the use of Firebase for data storage.

Uploaded by

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

Sweet Delivery App Development

The document describes the Sweethouse mobile application, an Android-based project for delivering sweet and dessert products to customers. It includes features for customer and admin interfaces, allowing users to purchase products, manage orders, and handle payments through various methods. The document also provides details on the app's structure, including user registration, product management, and the use of Firebase for data storage.

Uploaded by

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

Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

Project Introduction :-
Sweethouse is the my project name. Sweethouse is an Android java based project to sale
sweet/dessert product delivery at the customer home in decided time period. From cakes and
ice creams to candies and chocolates, the app is designed to cater to dessert lovers.

Keywords:
1. Android app
2. Firebase database
3. Product management
4. Add product by admin only

There are two side of this application first is for customer (Sweethouse). And second is for
admin and staff uses (Sweethouse admin). In Sweethouse app user or customer can purchase or
buy product which are available in app. Customer app product in cart and order more then one
or more then one product in one order. In check out process two way to pay total amount. First
cash on delivery and second option is pay online. In pay online there are two way first UPI
payment and second is card payment with card number, card holder name, card expiry date.
User can see they old or resent order in order history. User can easly access this app by sign in
with mobile number with OTP. If user not register there number. So user can register there
number with sign up page with giving details like name, mobile number, email address and
create password.
In main page there are four fragment home fragment, category fragment, cart fragment, profile
fragment. In main page all category is display. In category fragment all category display with
img. In cart fragment which product which are add by user in cart is [Link] profile fragment
user details like user pic, user name, user email. User can change there details. User can logout
or delete there account from this app.
Some more category are added soon in this app. And we add some more product in all category.
In admin side admin can accept or reject the order status. this status is also in by user in order
history. Admin can add new category and product in app. By sign with admin number and
password in Sweethous admin app.
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

Source code :-
1. Sign up page :-
package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];

import [Link];
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

public class sign_up extends AppCompatActivity {

String patten = "[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]+";


ProgressDialog pd;
TextView sign_in;
EditText name, number, email, pass, cpass;
Button button;
SQLiteDatabase db;
SharedPreferences sp;
ImageView seen,seen2, hide, hide2;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
[Link](this);
setContentView([Link].activity_sign_up);
[Link](findViewById([Link]), (v, insets) -
>{
Insets systemBars = [Link]([Link]());
[Link]([Link], [Link], [Link],
[Link]);
return insets;
});

// connent sp
sp = getSharedPreferences([Link], MODE_PRIVATE);

// connect database
db = openOrCreateDatabase("[Link]", MODE_PRIVATE, null);

name = findViewById([Link].sign_up_name);
number = findViewById([Link].sign_up_number);
email = findViewById([Link].sign_up_email);
pass = findViewById([Link].sign_up_password);
cpass = findViewById([Link].sign_up_cpassword);
button = findViewById([Link].sign_up_button);

// seen password

seen = findViewById([Link]);
hide = findViewById([Link]);
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]([Link]);
[Link]([Link]);
[Link](null);
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]([Link]);
[Link]([Link]);
[Link](new PasswordTransformationMethod());
}
});

seen2 = findViewById([Link].seen2);
hide2 = findViewById([Link].hide2);

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]([Link]);
[Link]([Link]);
[Link](null);
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]([Link]);
[Link]([Link]);
[Link](new PasswordTransformationMethod());
}
});

// input condition
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

[Link](new [Link]() {
@Override
public void onClick(View view) {
if ([Link]().toString().trim().equals("")){
[Link]("name required");
}
else if ([Link]().toString().trim().equals("")){
[Link]("number required");
}
else if (!([Link]().toString().trim().length() == 10)){
[Link]("invalid number");
}
else if ([Link]().toString().trim().equals("")){
[Link]("Email required");
}
else if (![Link]().toString().trim().matches(patten)){
[Link]("invalid email");
}
else if ([Link]().toString().trim().equals("")){
[Link]("Password required");
}
else if ([Link]().toString().trim().length() < 6){
[Link]("Password have minimum 6 char");
}
else if ([Link]().toString().trim().equals("")){
[Link]("Password required");
}
else if (![Link]().toString().trim().equals([Link]().toString().trim())){
[Link]("Password don't match");
}
else {
if (new ConnectionDetector(sign_up.this).networkConnected()){
// new CommonMethod(sign_up.this, "connect");
// new doSignup().execute();
pd = new ProgressDialog(sign_up.this);
[Link]("Please Wait...");
[Link](false);
[Link]();
firesign();
}
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

else {
new ConnectionDetector(sign_up.this).networkDisconnected();
}
}
}
});

// for login
sign_in = findViewById([Link].sign_up_in);

sign_in.setOnClickListener(new [Link]() {
@Override
public void onClick(View view) {
Intent intent = new Intent(sign_up.this,
[Link].sign_in.class);
startActivity(intent);
}
});
}

@Override
public void onBackPressed() {
[Link]();
finishAffinity();
}

public void firesign () {


FirebaseDatabase database = [Link]();
DatabaseReference myRef = [Link]("details");
Query check = [Link]("number").equalTo([Link]().toString());

[Link](new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {

if ([Link]()){
[Link]();
new CommonMethod(sign_up.this, "Number is already in use");
}
else {
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

HashMap<String, String> values = new HashMap<>();


[Link]("name", [Link]().toString());
[Link]("number", [Link]().toString());
[Link]("email", [Link]().toString());
[Link]("password", [Link]().toString());

[Link]([Link]("number")).setValue(values).addOnCompleteListener(new
OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
[Link]();
new CommonMethod(sign_up.this, "Sign in successfully");
}
});
}
}

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

}
});
}
}
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

xml file :-

<?xml version="1.0" encoding="utf-8"?>


<ScrollView xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".sign_up"
android:background="@color/home_search">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white">

<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp"
android:src="@drawable/logo2"/>

<TextView
android:fontFamily="@font/always_font"
android:textColor="@color/black"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign up"
android:textSize="@dimen/_25sdp"
android:textStyle="bold"
android:layout_marginHorizontal="@dimen/_25sdp"/>

<EditText
android:inputType="text"
android:id="@+id/sign_up_name"
style="@style/input"
android:layout_marginTop="@dimen/_15sdp"
android:hint="Name"
android:drawableStart="@drawable/person"/>
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

<EditText
android:inputType="number"
android:id="@+id/sign_up_number"
style="@style/input"
android:layout_marginTop="@dimen/_5sdp"
android:hint="Enter your Phone Numder"
android:drawableStart="@drawable/baseline_local_phone_24"/>

<EditText
android:inputType="textEmailAddress"
android:id="@+id/sign_up_email"
style="@style/input"
android:layout_marginTop="@dimen/_5sdp"
android:hint="Enter your Email"
android:drawableStart="@drawable/email"/>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/sign_up_password"
style="@style/input"
android:inputType="textPassword"
android:layout_marginTop="@dimen/_5sdp"
android:hint="Enter your Password"
android:drawableStart="@drawable/lock"/>

<ImageView
android:id="@+id/seen"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:src="@drawable/seen"
app:tint="@color/white"
android:layout_alignParentEnd="true"
android:layout_centerHorizontal="true"
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

android:layout_marginTop="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_35sdp"/>

<ImageView
android:id="@+id/hide"
android:visibility="gone"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:src="@drawable/hide"
app:tint="@color/white"
android:layout_alignParentEnd="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_35sdp"/>

</RelativeLayout>

</FrameLayout>

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<EditText
android:id="@+id/sign_up_cpassword"
style="@style/input"
android:inputType="textPassword"
android:layout_marginTop="@dimen/_5sdp"
android:hint="Confirm Password"
android:drawableStart="@drawable/lock"/>

<ImageView
android:id="@+id/seen2"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:src="@drawable/seen"
app:tint="@color/white"
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

android:layout_alignParentEnd="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_35sdp"/>

<ImageView
android:id="@+id/hide2"
android:visibility="gone"
android:layout_width="@dimen/_25sdp"
android:layout_height="@dimen/_25sdp"
android:src="@drawable/hide"
app:tint="@color/white"
android:layout_alignParentEnd="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_35sdp"/>

</RelativeLayout>

</FrameLayout>

<Button
android:id="@+id/sign_up_button"
android:layout_marginTop="@dimen/_15sdp"
style="@style/button"
app:backgroundTint="@null"
android:text="Sign in"
/>

<LinearLayout
android:layout_marginBottom="@dimen/_30sdp"
android:layout_marginTop="@dimen/_15sdp"
android:layout_marginEnd="@dimen/_20sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"

android:layout_marginHorizontal="@dimen/_20sdp">

<TextView
style="@style/sign_in_bottom"
android:text="Already have Account?"
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

android:gravity="end"
android:layout_marginStart="@dimen/_30sdp"
android:layout_weight="1"
android:layout_marginEnd="@dimen/_5sdp"/>

<TextView
android:id="@+id/sign_up_in"
style="@style/sign_in_bottom"
android:layout_weight="2"
android:textColor="@color/button_back"
android:text="Sign_in"/>

</LinearLayout>

</LinearLayout>

</ScrollView>
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

2. Sign in page:-

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

import [Link];
import [Link];

import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];

public class sign_in extends AppCompatActivity {

ImageView seen, hide;


TextView sign_up;
EditText number, password;
Button button, send;
SQLiteDatabase db;
SharedPreferences sp;
private static final int SMS_PERMISSION_CODE = 1;
Random r = new Random();
AlertDialog dialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
[Link](this);
setContentView([Link].activity_sign_in);
[Link](findViewById([Link]), (v, insets) -
>{
Insets systemBars = [Link]([Link]());
[Link]([Link], [Link], [Link],
[Link]);
return insets;
});

// connect sp
sp = getSharedPreferences([Link], MODE_PRIVATE);

// database connection
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

db = openOrCreateDatabase("[Link]", MODE_PRIVATE, null);

number = findViewById([Link].sign_in_number);
password = findViewById([Link].sign_in_password);
button = findViewById([Link].sign_in_button);
send = findViewById([Link].sign_in_send);

[Link](new [Link]() {
@Override
public void onClick(View view) {
if ([Link]().toString().trim().equals("")){
[Link]("number required");
}
else if (!([Link]().toString().trim().length() == 10)){
[Link]("invalid number");
}
else {
[Link]([Link]);
[Link]([Link]);
[Link]([Link]);
[Link] builder = new [Link](sign_in.this);
View progress =
[Link](sign_in.this).inflate([Link].custom_progress, null);
[Link](progress);
[Link](false);
dialog = [Link]();
[Link]().setBackgroundDrawable(new
ColorDrawable([Link]));
[Link]();
checknumber();
}
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
if ([Link]().toString().trim().equals("")){
[Link]("number required");
}
else if (!([Link]().toString().trim().length() == 10)){
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

[Link]("invalid number");
}
else if ([Link]().toString().trim().equals("")) {
[Link]("OTP required");
}
else {
[Link] builder = new [Link](sign_in.this);
View progress =
[Link](sign_in.this).inflate([Link].custom_progress, null);
[Link](progress);
[Link](false);
dialog = [Link]();
[Link]().setBackgroundDrawable(new
ColorDrawable([Link]));
[Link]();
checkOTP();
}
}
});

sign_up = findViewById([Link].sign_in_up);

// registration
sign_up.setOnClickListener(new [Link]() {
@Override
public void onClick(View view) {
Intent intent = new Intent(sign_in.this,
[Link].sign_up.class);
startActivity(intent);
}
});
}

private void checkOTP() {


if ([Link]().toString().equals([Link]([Link], ""))){
new CommonMethod(sign_in.this, "Login successfully");
FirebaseDatabase database = [Link]();
DatabaseReference myRef = [Link]("details");
Query check =
[Link]("number").equalTo([Link]().toString());
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

[Link](new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {

if ([Link]()){
[Link]();
[Link]().putString([Link],
[Link]([Link]().toString()).child("name").getValue([Link])).commit
();
[Link]().putString([Link],
[Link]([Link]().toString()).child("number").getValue([Link])).com
mit();
[Link]().putString([Link],
[Link]([Link]().toString()).child("email").getValue([Link])).commit
();
[Link]().putString([Link],
[Link]([Link]().toString()).child("password").getValue([Link])).co
mmit();

[Link]().putString([Link], "").commit();

Intent intent = new Intent(sign_in.this, [Link]);


[Link]();
startActivity(intent);
}
}

@Override
public void onCancelled(@NonNull DatabaseError error) {
[Link]();
}
});
}
else {
[Link]();
new CommonMethod(sign_in.this, "Wrong OTP");
}
}

private void checknumber() {


Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

FirebaseDatabase database = [Link]();


DatabaseReference myRef = [Link]("details");
Query check = [Link]("number").equalTo([Link]().toString());

[Link](new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {

if ([Link]()){
String phone = [Link]().toString();
int i1 = [Link](9999 - 1111);
[Link]().putString([Link], [Link](i1)).commit();
String message = i1 + " is your Login OTP for Sweet House app. Do not share it
with anyone";

if ([Link](sign_in.this,
[Link].SEND_SMS) != PackageManager.PERMISSION_GRANTED) {
[Link](sign_in.this, new
String[]{[Link].SEND_SMS}, SMS_PERMISSION_CODE);
checknumber();
} else {
SmsManager smsManager = [Link]();
try {
[Link](phone, null, message, null, null);
[Link](sign_in.this, "OTP sent!", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
[Link](sign_in.this, "Failed to send message.",
Toast.LENGTH_SHORT).show();
}
}
[Link]();
}
else {
[Link]();
new CommonMethod(sign_in.this, "number don't exists");
}
}

@Override
public void onCancelled(@NonNull DatabaseError error) {
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

}
});
}

@Override
public void onBackPressed() {
[Link]();
finishAffinity();
}
}

xml file :

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".sign_in"
android:background="@color/home_search"
>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">

<ImageView
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="@dimen/_200sdp"
android:src="@drawable/logo2"/>

<TextView
android:id="@+id/title"
android:fontFamily="@font/always_font"
android:textColor="@color/black"
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in"
android:textSize="@dimen/_25sdp"
android:textStyle="bold"
android:layout_below="@+id/img"
android:layout_marginHorizontal="@dimen/_25sdp"/>

<EditText
android:id="@+id/sign_in_number"
android:layout_below="@+id/title"
style="@style/input"
android:inputType="number"
android:layout_marginTop="@dimen/_20sdp"
android:hint="Enter your mobile number"
android:drawableStart="@drawable/baseline_local_phone_24"/>

<EditText
android:id="@+id/sign_in_password"
android:layout_below="@+id/sign_in_number"
style="@style/input"
android:visibility="gone"
android:inputType="number"
android:layout_marginTop="@dimen/_20sdp"
android:hint="Enter OTP here"
android:drawableStart="@drawable/otp"
app:drawableTint="@color/white"/>

<Button
android:id="@+id/sign_in_button"
android:visibility="gone"
android:layout_marginTop="@dimen/_20sdp"
style="@style/button"
app:backgroundTint="@null"
android:text="Sign in"
android:layout_below="@id/sign_in_password"
/>

<Button
android:id="@+id/sign_in_send"
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

android:layout_marginTop="@dimen/_20sdp"
style="@style/button"
app:backgroundTint="@null"
android:text="Send OTP"
android:layout_below="@id/sign_in_password"
/>

<LinearLayout
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/_40sdp">

<TextView
style="@style/sign_in_bottom"
android:text="Don't have Account?"
android:gravity="end"
android:layout_weight="1"
android:layout_marginEnd="@dimen/_5sdp"/>

<TextView
android:id="@+id/sign_in_up"
style="@style/sign_in_bottom"
android:layout_weight="2"
android:textColor="@color/button_back"
android:text="Sign_up"/>

</LinearLayout>

</RelativeLayout>

</LinearLayout>
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

3. Main Page :

package [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];

public class MainActivity extends AppCompatActivity {

View home_line, category_line, cart_line, profile_line;


int total;
// sp
SharedPreferences sp;

// nav item
ImageView home, category, cart, profile;

@Override
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

protected void onCreate(Bundle savedInstanceState) {


[Link](savedInstanceState);
[Link](this);
setContentView([Link].activity_main);
[Link](findViewById([Link]), (v, insets) -
>{
Insets systemBars = [Link]([Link]());
[Link]([Link], [Link], [Link],
[Link]);
return insets;
});

// connect sp
sp = getSharedPreferences([Link], MODE_PRIVATE);
FirebaseDatabase database = [Link]();
DatabaseReference myRef = [Link]("cart");

[Link](new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if ([Link]()) {
for (DataSnapshot dataSnapshot : [Link]()) {
String db_email = [Link]("email").getValue([Link]);
if ([Link](db_email, [Link]([Link], ""))) {
total +=
[Link]([Link]("total_amount").getValue([Link]));
[Link]().putString(Session.total_amount,
[Link](total)).commit();
}
}
}
}

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

}
});

// fragment set and condition


Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

home_line = findViewById([Link].home_line);
category_line = findViewById([Link].category_line);
cart_line = findViewById([Link].cart_line);
profile_line = findViewById([Link].profile_line);

if ([Link]([Link],"").equals("profile")){
// clearColor();
profile_line.setBackgroundColor([Link]("#f37b2d"));
FragmentManager manager4 = getSupportFragmentManager();
[Link]().replace([Link].fragment_place, new
profileFragment()).commit();
} else if ([Link]([Link], "").equals("cart")) {
cart_line.setBackgroundColor([Link]("#f37b2d"));
FragmentManager manager4 = getSupportFragmentManager();
[Link]().replace([Link].fragment_place, new
CartFragment()).commit();
} else {
// clearColor();
home_line.setBackgroundColor([Link]("#f37b2d"));
FragmentManager manager = getSupportFragmentManager();
[Link]().replace([Link].fragment_place, new
HomeFragment()).commit();
}

// fragment changer

home = findViewById([Link].home_item);
cart = findViewById([Link]);
category = findViewById([Link]);
profile = findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View view) {
clearColor();
home_line.setBackgroundColor([Link]("#f37b2d"));
FragmentManager manager = getSupportFragmentManager();
[Link]().replace([Link].fragment_place, new
HomeFragment()).commit();
}
});
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

[Link](new [Link]() {
@Override
public void onClick(View view) {
clearColor();
category_line.setBackgroundColor([Link]("#f37b2d"));
FragmentManager manager2 = getSupportFragmentManager();
[Link]().replace([Link].fragment_place, new
CategoryFragment()).commit();
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
clearColor();
cart_line.setBackgroundColor([Link]("#f37b2d"));
FragmentManager manager3 = getSupportFragmentManager();
[Link]().replace([Link].fragment_place, new
CartFragment()).commit();
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
clearColor();
profile_line.setBackgroundColor([Link]("#f37b2d"));
FragmentManager manager4 = getSupportFragmentManager();
[Link]().replace([Link].fragment_place, new
profileFragment()).commit();
}
});

}
public void clearColor () {
home_line.setBackgroundColor([Link]("#00FFFFFF"));
category_line.setBackgroundColor([Link]("#00FFFFFF"));
cart_line.setBackgroundColor([Link]("#00FFFFFF"));
profile_line.setBackgroundColor([Link]("#00FFFFFF"));
}
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

@Override
public void onBackPressed() {
[Link]();
finishAffinity();
}
}

xml file :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@color/home_search">

<LinearLayout
android:id="@+id/fragment_place"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">

</LinearLayout>

<[Link]
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/nav">

<LinearLayout
android:layout_marginTop="@dimen/_2sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginHorizontal="@dimen/_15sdp">
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

<View
android:id="@+id/home_line"
android:layout_width="match_parent"
android:layout_height="@dimen/_4sdp"
android:layout_weight="1"/>

<View
android:id="@+id/category_line"
android:layout_width="match_parent"
android:layout_height="@dimen/_4sdp"
android:layout_weight="1"/>

<View
android:id="@+id/cart_line"
android:layout_width="match_parent"
android:layout_height="@dimen/_4sdp"
android:layout_weight="1"/>

<View
android:id="@+id/profile_line"
android:layout_width="match_parent"
android:layout_height="@dimen/_4sdp"
android:layout_weight="1"/>

</LinearLayout>

<LinearLayout
android:layout_margin="@dimen/_15sdp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/home_item"
style="@style/nav_item"
android:src="@drawable/home"
app:tint="@color/color1"
/>

<ImageView
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

android:id="@+id/category"
style="@style/nav_item"
android:src="@drawable/category"
app:tint="@color/color1"
/>

<ImageView
android:id="@+id/cart"
style="@style/nav_item"
android:src="@drawable/customcart"
app:tint="@color/color1"
/>

<ImageView
android:id="@+id/profile"
style="@style/nav_item"
android:src="@drawable/profile"
app:tint="@color/color1" />

</LinearLayout>

</[Link]>

</RelativeLayout>
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

Screenshot (Sweethouse) : -
1. Splash :

2. Sign in :
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

3. Sign up :

4. Home fragment :
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

5. Category fragment :
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

6. Cart Fragment :

7. Profile fragment :
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

8. Edit profile :

9. Sub category :
Mobile Application Development using Android (4350703) GOVERNMENT POLYTECHNIC, AHMEDABAD

10. Logout dialog box :

You might also like