Post Top Ad

Post Top Ad

Friday 21 February 2020

How to design Checkout screen in android



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:background="@color/white"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="@drawable/bg_border_layout"
            android:orientation="horizontal"
            android:layout_weight="1">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3"></LinearLayout>
            <LinearLayout
                android:id="@+id/back_btn"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3">

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:clickable="false"
                    android:scaleType="centerInside"
                    android:src="@drawable/ic_left_arrow" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:orientation="horizontal"
                android:layout_weight="88">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"></LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="2"
                    android:gravity="center"
                    android:orientation="vertical"
                    android:layout_height="match_parent">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:gravity="center"
                        android:orientation="horizontal"
                        android:layout_weight="2">
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="1"
                            android:layout_height="match_parent"></LinearLayout>
                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="1"
                            android:orientation="vertical"
                            android:layout_height="match_parent">
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_weight="1"></LinearLayout>
                            <de.hdodenhof.circleimageview.CircleImageView
                                android:layout_width="match_parent"
                                android:layout_weight="2"
                                android:layout_height="0dp"
                                android:src="@drawable/ic_menu_icon"
                                android:id="@+id/restuarnt_img" />
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
                                android:layout_weight="1"></LinearLayout>
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="@dimen/text_size_medium_small"
                            android:layout_height="match_parent"></LinearLayout>
                        <LinearLayout
                            android:layout_width="wrap_content"
                            android:orientation="horizontal"
                            android:layout_height="match_parent">
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:id="@+id/masterName"
                                android:gravity="center"
                                android:textStyle="bold"
                                android:fontFamily="@font/source_sans_pro_bold"
                                android:textSize="@dimen/text_size_large"
                                android:text="FruFresh "/>
                            <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:gravity="center"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:textSize="@dimen/text_size_large"
                                android:text="Master "/>
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="0dp"
                            android:layout_weight="1"
                            android:layout_height="match_parent"></LinearLayout>
                    </LinearLayout>
                </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"></LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3">
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:src="@drawable/ic_fri_logo"/>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3"></LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:orientation="horizontal"
            android:layout_weight="0.75">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="20">
                <TextView
                    android:id="@+id/orderno_txt"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:visibility="visible"
                    android:clickable="false"
                    android:focusable="false"
                    android:fontFamily="@font/sourcesan"
                    android:gravity="center"
                    android:text="S.no"
                    android:textColor="#343434"
                    android:textSize="@dimen/text_size_small" />

            </LinearLayout>
            <LinearLayout
                android:layout_width="1dp"
                android:background="#D2D2D2"
                android:layout_height="match_parent"
               ></LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="60">
                <TextView
                    android:id="@+id/table_name"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:visibility="visible"
                    android:clickable="false"
                    android:focusable="false"
                    android:fontFamily="@font/source_sans_pro_regular"
                    android:gravity="center"
                    android:layout_marginLeft="@dimen/text_size_small"
                    android:layout_marginRight="@dimen/text_size_small"
                    android:text="Table #"
                    android:textColor="#343434"
                    android:textSize="@dimen/text_size_small" />
                <TextView
                    android:id="@+id/seat_name"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:visibility="visible"
                    android:clickable="false"
                    android:focusable="false"
                    android:fontFamily="@font/source_sans_pro_regular"
                    android:gravity="center"
                    android:layout_marginLeft="@dimen/text_size_small"
                    android:layout_marginRight="@dimen/text_size_small"
                    android:text="Seat A, Seat B, Seat C"
                    android:textColor="#343434"
                    android:textSize="@dimen/text_size_small" />
            </LinearLayout>
            <LinearLayout
                android:layout_width="1dp"
                android:background="#D2D2D2"
                android:layout_height="match_parent"
                ></LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="20">
                <TextView
                    android:id="@+id/order_type_name"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center|right"
                    android:visibility="visible"
                    android:clickable="false"
                    android:focusable="false"
                    android:fontFamily="@font/source_sans_pro_regular"
                    android:gravity="center|right"
                    android:layout_marginLeft="@dimen/text_size_small"
                    android:layout_marginRight="@dimen/text_size_small"
                    android:text="Dine-in"
                    android:textColor="#343434"
                    android:textSize="@dimen/text_size_small" />

            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#D2D2D2"></LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="0.75"
            android:orientation="horizontal"
            >
            <TextView
                android:id="@+id/sno"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:clickable="false"
                android:focusable="false"
                android:fontFamily="@font/source_sans_pro_regular"
                android:gravity="center"
                android:text="S.no"
                android:textColor="#343434"
                android:textSize="@dimen/text_size_medium_small" />
            <LinearLayout
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#D2D2D2"></LinearLayout>

            <TextView
                android:id="@+id/orderno"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_weight="5"
                android:clickable="false"
                android:focusable="false"
                android:fontFamily="@font/source_sans_pro_regular"
                android:gravity="center"
                android:text="Item"
                android:textColor="#343434"
                android:textSize="@dimen/text_size_medium_small" />
            <LinearLayout
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#D2D2D2"></LinearLayout>
            <TextView
                android:id="@+id/customerdeatils"
                android:layout_width="0dp"
                android:layout_weight="1.5"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:clickable="false"
                android:focusable="false"
                android:fontFamily="@font/source_sans_pro_regular"
                android:gravity="center"
                android:text="Quantity"
                android:textColor="#343434"
                android:textSize="@dimen/text_size_medium_small" />
            <LinearLayout
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="#D2D2D2"></LinearLayout>
            <TextView
                android:id="@+id/amount"
                android:layout_width="0dp"
                android:layout_weight="2.5"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:clickable="false"
                android:focusable="false"
                android:fontFamily="@font/source_sans_pro_regular"
                android:gravity="center"
                android:text="Amount"
                android:textColor="#343434"
                android:textSize="@dimen/text_size_medium_small" />
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#D2D2D2"></LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="0dp"
            android:layout_weight="6.5">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1">
                <ListView
                    android:id="@+id/order_items_listview"
                    android:divider="@android:color/transparent"
                    android:dividerHeight="0dp"
                    android:listSelector="@android:color/transparent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"></ListView>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#DFDFDF"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:orientation="horizontal"
                    android:layout_height="wrap_content">
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="8.25"
                        android:layout_height="match_parent">
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            >
                            <TextView
                                android:id="@+id/itemtotal"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:clickable="false"
                                android:focusable="false"
                                android:layout_marginTop="10dp"
                                android:layout_marginBottom="5dp"
                                android:fontFamily="@font/source_sans_pro_bold"
                                android:gravity="center|right"
                                android:text="Item total"
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_medium_small" />
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:orientation="horizontal"
                                android:layout_marginTop="10dp"
                                android:layout_marginBottom="5dp"
                                android:gravity="right"
                                android:layout_height="wrap_content">
                                <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:clickable="false"
                                    android:visibility="visible"
                                    android:focusable="false"
                                    android:fontFamily="@font/source_sans_pro_bold"
                                    android:gravity="center"
                                    android:text="Add discount"
                                    android:textColor="#343434"
                                    android:layout_marginLeft="@dimen/text_size_medium"
                                    android:textSize="@dimen/text_size_small" />
                                <ImageView
                                    android:id="@+id/amount_discount_img"
                                    android:layout_width="@dimen/text_size_medium_small"
                                    android:layout_height="match_parent"
                                    android:clickable="true"
                                    android:tag="1"
                                    android:scaleType="centerInside"
                                    android:layout_marginLeft="@dimen/text_size_medium"
                                    android:src="@drawable/ic_selected_item" />
                                <TextView
                                    android:id="@+id/amount_sign"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:clickable="false"
                                    android:visibility="visible"
                                    android:focusable="false"

                                    android:fontFamily="@font/source_sans_pro_regular"
                                    android:gravity="center"
                                    android:text="Amount"
                                    android:textColor="#343434"
                                    android:layout_marginLeft="@dimen/text_size_medium_small"
                                    android:textSize="@dimen/text_size_small" />
                                <ImageView
                                    android:id="@+id/pre_discount_img"
                                    android:layout_width="@dimen/text_size_medium_small"
                                    android:layout_height="match_parent"
                                    android:clickable="true"
                                    android:tag="2"
                                    android:scaleType="centerInside"
                                    android:layout_marginLeft="@dimen/text_size_medium"
                                    android:src="@drawable/ic_unselected_item" />
                                <TextView
                                    android:id="@+id/persentage_sign"
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:clickable="false"
                                    android:visibility="visible"
                                    android:focusable="false"

                                    android:layout_marginLeft="@dimen/text_size_medium_small"
                                    android:fontFamily="@font/source_sans_pro_regular"
                                    android:gravity="center"
                                    android:text="Percentage"
                                    android:textColor="#343434"
                                    android:textSize="@dimen/text_size_small" />

                            </LinearLayout>
                            <TextView
                                android:id="@+id/discount_sign"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:clickable="false"
                                android:visibility="visible"
                                android:focusable="false"
                                android:layout_marginTop="3dp"
                                android:layout_marginBottom="3dp"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:gravity="center|right"
                                android:text="Sub Total (after discount)"
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_small" />

                            <LinearLayout
                                android:visibility="visible"
                                android:id="@+id/tax_layout"
                                android:layout_width="match_parent"
                                android:orientation="horizontal"
                                android:layout_height="wrap_content">
                                <TextView
                                    android:id="@+id/tax1"
                                    android:layout_width="0dp"
                                    android:layout_weight="1"
                                    android:layout_height="wrap_content"
                                    android:layout_gravity="center"
                                    android:clickable="false"
                                    android:focusable="false"
                                    android:layout_marginTop="3dp"
                                    android:layout_marginBottom="3dp"
                                    android:fontFamily="@font/source_sans_pro_regular"
                                    android:gravity="center|right"
                                    android:text="Tax "
                                    android:textColor="#343434"
                                    android:textSize="@dimen/text_size_small" />
                                <ImageView
                                    android:id="@+id/tax_details_btn"
                                    android:clickable="true"
                                    android:focusable="true"
                                    android:layout_width="@dimen/text_size_small"
                                    android:layout_height="@dimen/text_size_small"
                                    android:layout_gravity="center"
                                    android:src="@drawable/ic_info"/>
                            </LinearLayout>
                            <TextView
                                android:visibility="gone"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:clickable="false"
                                android:focusable="false"
                                android:layout_marginTop="3dp"
                                android:layout_marginBottom="10dp"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:gravity="center|right"
                                android:text="Convenience fee @ 2%"
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_medium_small" />
                            <TextView
                                android:id="@+id/topay"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:clickable="false"
                                android:focusable="false"
                                android:layout_marginTop="3dp"
                                android:layout_marginBottom="10dp"
                                android:fontFamily="@font/source_sans_pro_bold"
                                android:gravity="center|right"
                                android:text="To pay"
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_medium_small" />

                        </LinearLayout>

                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight=".25"></LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="1.5"
                        android:orientation="vertical"
                        android:layout_height="match_parent">
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical"
                            >
                            <TextView
                                android:id="@+id/itemTotal_txt"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:clickable="false"
                                android:focusable="false"
                                android:layout_marginTop="10dp"
                                android:layout_marginBottom="5dp"
                                android:fontFamily="@font/source_sans_pro_bold"
                                android:gravity="center|right"
                                android:text=""
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_medium_small" />
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:orientation="vertical"
                                android:layout_marginTop="10dp"
                                android:layout_marginBottom="5dp"
                                android:layout_height="wrap_content">
                                <EditText
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:textColor="#343434"
                                    android:gravity="center|right"
                                    android:imeOptions="actionDone"
                                    android:id="@+id/discount_editTexat"
                                    android:fontFamily="@font/source_sans_pro_regular"
                                    android:textSize="@dimen/text_size_small"
                                    android:text=""
                                    android:inputType="numberDecimal"
                                    android:background="@android:color/transparent"
                                   />
                                <LinearLayout
                                    android:layout_width="match_parent"
                                    android:background="#707070"
                                    android:layout_height="@dimen/stokewidth"></LinearLayout>
                            </LinearLayout>
                            <TextView
                                android:id="@+id/subToatl_txt"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:clickable="false"
                                android:visibility="visible"
                                android:focusable="false"
                                android:layout_marginTop="3dp"
                                android:layout_marginBottom="3dp"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:gravity="center|right"
                                android:text=""
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_small" />
                            <TextView
                                android:id="@+id/tax1_txt"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:visibility="visible"
                                android:clickable="false"
                                android:focusable="false"
                                android:layout_marginTop="3dp"
                                android:layout_marginBottom="3dp"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:gravity="center|right"
                                android:text=""
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_small" />
                            <TextView
                                android:visibility="gone"
                                android:id="@+id/convenience_fee_txt"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:clickable="false"
                                android:focusable="false"
                                android:layout_marginTop="3dp"
                                android:layout_marginBottom="10dp"
                                android:fontFamily="@font/source_sans_pro_regular"
                                android:gravity="center|right"
                                android:text="S.no"
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_medium_small" />
                            <TextView
                                android:id="@+id/Total_txt"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:clickable="false"
                                android:focusable="false"
                                android:layout_marginTop="3dp"
                                android:layout_marginBottom="10dp"
                                android:fontFamily="@font/source_sans_pro_bold"
                                android:gravity="center|right"
                                android:text=""
                                android:textColor="#343434"
                                android:textSize="@dimen/text_size_medium_small" />

                        </LinearLayout>
                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="0.5"
                        android:layout_height="match_parent"></LinearLayout>
                </LinearLayout>
         <!--       <LinearLayout
                    android:layout_width="match_parent"
                    android:orientation="horizontal"
                    android:layout_marginTop="@dimen/text_size_small"
                    android:layout_marginBottom="@dimen/text_size_small"
                    android:layout_height="wrap_content">
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="2.25"
                        android:layout_height="match_parent"></LinearLayout>
                    <TextView
                        android:layout_width="0dp"
                        android:layout_weight="2"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:visibility="visible"
                        android:clickable="false"
                        android:focusable="false"
                        android:layout_marginTop="3dp"
                        android:layout_marginBottom="3dp"
                        android:fontFamily="@font/montserrat_bold"
                        android:gravity="center|right"
                        android:text="Cash received"
                        android:textColor="#343434"
                        android:textSize="@dimen/text_size_small" />
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight=".25"></LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="1.5"
                        android:orientation="vertical"
                        android:layout_height="match_parent">
                        <EditText
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textColor="#343434"
                            android:gravity="center|right"
                            android:imeOptions="actionDone"
                            android:id="@+id/receivedCash_editTexat"
                            android:background="@color/white"
                            android:inputType="numberDecimal"
                            android:fontFamily="@font/montserrat"
                            android:textSize="@dimen/text_size_small"/>

                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight=".25"></LinearLayout>
                    <TextView
                        android:layout_width="0dp"
                        android:layout_weight="2"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center|right"
                        android:visibility="visible"
                        android:clickable="false"
                        android:focusable="false"
                        android:layout_marginTop="3dp"
                        android:layout_marginBottom="3dp"
                        android:fontFamily="@font/montserrat_bold"
                        android:gravity="center|right"
                        android:text="Return Change"
                        android:textColor="#343434"
                        android:textSize="@dimen/text_size_small" />
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_height="match_parent"
                        android:layout_weight=".25"></LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="1.5"
                        android:orientation="vertical"
                        android:layout_height="match_parent">
                        <EditText
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:textColor="#343434"
                            android:gravity="center|right"
                            android:enabled="false"
                            android:id="@+id/changes_editTexat"
                            android:background="@color/white"
                            android:fontFamily="@font/montserrat"
                            android:textSize="@dimen/text_size_small"/>

                    </LinearLayout>
                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="0.5"
                        android:layout_height="match_parent"></LinearLayout>
                </LinearLayout>-->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="0.5"
                    android:layout_marginTop="@dimen/text_size_small"
                    android:layout_marginBottom="@dimen/text_size_small"

                    android:orientation="horizontal"
                    >


                    <LinearLayout
                        android:layout_width="1dp"
                        android:layout_height="match_parent"
                        android:background="#D2D2D2"></LinearLayout>

                    <TextView
                        android:id="@+id/case_recive_sign"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:layout_weight="2.5"
                        android:clickable="false"
                        android:focusable="false"
                        android:fontFamily="@font/source_sans_pro_bold"
                        android:gravity="center|right"
                        android:text="Cash received"
                        android:textColor="#343434"
                        android:textSize="@dimen/text_size_small" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="0.1"
                        android:layout_height="match_parent"></LinearLayout>

                    <LinearLayout
                        android:layout_width="1dp"
                        android:layout_height="match_parent"
                       ></LinearLayout>

                    <EditText
                        android:id="@+id/receivedCash_editTexat"
                        android:layout_width="0dp"
                        android:layout_weight="2"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:textColor="#343434"
                        android:gravity="center|right"
                        android:background="@color/white"
                        android:inputType="numberDecimal"
                        android:fontFamily="@font/source_sans_pro_regular"
                        android:textSize="@dimen/text_size_small" />

                    <LinearLayout
                        android:layout_width="1dp"
                        android:layout_height="match_parent">

                    </LinearLayout>
                    <TextView
                        android:id="@+id/return_sign"
                        android:layout_width="0dp"
                        android:layout_weight="1.5"
                        android:layout_height="wrap_content"
                        android:gravity="center|right"
                        android:clickable="false"
                        android:focusable="false"
                        android:layout_gravity="center|right"
                        android:fontFamily="@font/source_sans_pro_bold"
                        android:text="Return Change"
                        android:textColor="#343434"
                        android:textSize="@dimen/text_size_small" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="0.1"
                        android:layout_height="match_parent"></LinearLayout>

                    <LinearLayout
                        android:layout_width="1dp"
                        android:layout_height="match_parent"></LinearLayout>
                    <EditText
                        android:id="@+id/changes_editTexat"
                        android:layout_width="0dp"
                        android:layout_weight="2.5"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:enabled="false"
                        android:gravity="center"
                        android:textColor="#717171"
                        android:background="@color/white"
                        android:fontFamily="@font/source_sans_pro_regular"
                        android:textSize="@dimen/text_size_small" />

                    <LinearLayout
                        android:layout_width="0dp"
                        android:layout_weight="0.4"
                        android:layout_height="match_parent"></LinearLayout>



                </LinearLayout>

            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="0dp"
            android:layout_weight="1">
           <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="0dp"
               android:layout_weight="0.5"></LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:orientation="horizontal"
                android:layout_weight="2">
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="41.5"
                    android:layout_height="match_parent"></LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="28"
                    android:layout_height="match_parent">
                    <androidx.cardview.widget.CardView
                        android:id="@+id/settle_via_card"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:clickable="true"
                        android:focusable="true"
                        android:clipChildren="false"
                        app:cardCornerRadius="@dimen/text_size_medium"
                        app:cardBackgroundColor="#D20638"
                        android:background="@color/black"
                        android:layout_marginBottom="2dp"
                        app:cardPreventCornerOverlap="true"
                        app:cardUseCompatPadding="false">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:background="#D20638"
                            android:clickable="false"
                            android:focusable="false"
                            android:fontFamily="@font/source_sans_pro_regular"
                            android:gravity="center"
                            android:text="SETTLE VIA CARD"
                            android:textColor="@color/white"
                            android:textSize="@dimen/text_size_medium" />
                    </androidx.cardview.widget.CardView>
                </LinearLayout>

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_weight="2"></LinearLayout>
                <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="28"
                android:layout_height="match_parent">
                <androidx.cardview.widget.CardView
                    android:id="@+id/settle_via_cash"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:clickable="true"
                    android:focusable="true"
                    android:clipChildren="false"
                    app:cardCornerRadius="@dimen/text_size_medium"
                    app:cardBackgroundColor="#D20638"
                    android:background="@color/black"
                    android:layout_marginBottom="2dp"
                    app:cardPreventCornerOverlap="true"
                    app:cardUseCompatPadding="false">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"
                        android:background="#D20638"
                        android:clickable="false"
                        android:focusable="false"
                        android:fontFamily="@font/source_sans_pro_regular"
                        android:gravity="center"
                        android:text="SETTLE VIA CASH"
                        android:textColor="@color/white"
                        android:textSize="@dimen/text_size_medium" />
                </androidx.cardview.widget.CardView>

            </LinearLayout>
                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_weight="0.5"
                    android:layout_height="match_parent"></LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="0.5"></LinearLayout>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>


2.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_margin="@dimen/text_size_more_large"
    android:layout_height="wrap_content">
    <TextView
        android:layout_width="0dp"
        android:layout_weight="6"
        android:layout_height="wrap_content"
        android:layout_gravity="center|right"
        android:clickable="false"
        android:focusable="false"
        android:id="@+id/taxName"
        android:layout_marginRight="@dimen/text_size_medium_small"
        android:fontFamily="@font/source_sans_pro_regular"
        android:gravity="center|right"
        android:text="Dine-in"
        android:textColor="#343434"
        android:textSize="@dimen/text_size_small" />
    <TextView
        android:layout_width="0dp"
        android:layout_weight="4"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:clickable="false"
        android:focusable="false"
        android:id="@+id/taxamounts"
        android:layout_marginLeft="@dimen/text_size_medium_small"
        android:fontFamily="@font/source_sans_pro_regular"
        android:gravity="center|left"
        android:text="Dine-in"
        android:textColor="#343434"
        android:textSize="@dimen/text_size_small" />
</LinearLayout>


3.Sourse code:


import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;

import com.dfoe.frimaster.DataBaseServices.MasterDB;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;

import org.json.JSONArray;
import org.json.JSONObject;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import de.hdodenhof.circleimageview.CircleImageView;

public class CheckoutActivity  extends AppCompatActivity implements View.OnClickListener {

    TextView masterName,orderno_txt,table_name,seat_name,order_type_name,itemTotal_txt,subToatl_txt,tax1_txt,Total_txt,itemtotal,topay,amount_sign,Amount,persentage_sign,discount_sign,case_recive_sign,return_sign;
    ImageView pre_discount_img,amount_discount_img,tax_details_btn;
    ListView order_items_listview;
    LinearLayout back_btn ,tax_layout;
    EditText discount_editTexat,receivedCash_editTexat,changes_editTexat;
    CardView settle_via_card,settle_via_cash;
    int table_id,seat_id,order_no;
    JSONArray OrderDeatilsArray,taxDeatilsArray;
    TaxDeatilsListAdapter taxDeatilsListAdapter;
    OrderDeatilsListAdapter  orderDeatilsListAdapter;
    MasterDB db;
    double itemAmount = 0;
    double taxAmount = 0;
    double discountAmount = 0;
    double discountprecents = 0;
    double reciveingAmount = 0;
    CircleImageView restuarnt_img;
    public static CheckoutActivityTaskHandler checkoutActivityTaskHandler;

    @Override    protected void onDestroy() {
        checkoutActivityTaskHandler = null;
        super.onDestroy();
    }
    public String RestaurantImage = "";
    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title        getSupportActionBar().hide(); // hide the title bar        super.onCreate(savedInstanceState);
        checkoutActivityTaskHandler = new CheckoutActivityTaskHandler();
        setContentView(R.layout.activity_checkout_layout);
        table_name = (TextView)findViewById(R.id.table_name);
        seat_name = (TextView)findViewById(R.id.seat_name);
        orderno_txt = (TextView)findViewById(R.id.orderno_txt);
        itemTotal_txt  = (TextView)findViewById(R.id.itemTotal_txt);
        itemtotal = (TextView)findViewById(R.id.itemtotal);
        amount_sign = (TextView)findViewById(R.id.amount_sign);
        Amount= (TextView)findViewById(R.id.amount_sign);
        topay = (TextView)findViewById(R.id.topay);
        subToatl_txt  = (TextView)findViewById(R.id.subToatl_txt);
        tax1_txt  = (TextView)findViewById(R.id.tax1_txt);
        Total_txt  = (TextView)findViewById(R.id.Total_txt);
        tax_details_btn = (ImageView)findViewById(R.id.tax_details_btn);
        persentage_sign   = (TextView)findViewById(R.id.persentage_sign);
        discount_sign = (TextView)findViewById(R.id.discount_sign);
        case_recive_sign= (TextView)findViewById(R.id.case_recive_sign);
        return_sign = (TextView)findViewById(R.id.return_sign);
        pre_discount_img = (ImageView)findViewById(R.id.pre_discount_img);
        amount_discount_img = (ImageView)findViewById(R.id.amount_discount_img);
        tax_layout = (LinearLayout) findViewById(R.id.tax_layout);
        pre_discount_img.setOnClickListener(this);
        amount_discount_img.setOnClickListener(this);
        DecimalFormat df2 = new DecimalFormat("#.##");
        tax_details_btn.setOnClickListener(this);
        masterName = (TextView)findViewById(R.id.masterName);
        order_items_listview  = (ListView)findViewById(R.id.order_items_listview);
        masterName.setText(DashBoard.RestaurantName);
        back_btn = (LinearLayout)findViewById(R.id.back_btn);
        back_btn.setOnClickListener(this);
        discount_editTexat = (EditText)findViewById(R.id.discount_editTexat);
        settle_via_card = (CardView)findViewById(R.id.settle_via_card);
        settle_via_cash = (CardView)findViewById(R.id.settle_via_cash);
        settle_via_cash.setOnClickListener(this);
        settle_via_card.setOnClickListener(this);
        receivedCash_editTexat = (EditText)findViewById(R.id.receivedCash_editTexat);
        changes_editTexat = (EditText)findViewById(R.id.changes_editTexat);
        discount_editTexat.addTextChangedListener(new TextWatcher() {
            @Override            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                try {
                    if(discount_editTexat.getText().length() > 0)
                    {
                        String discounttxt = discount_editTexat.getText().toString();
                        calculateDiscount(Double.parseDouble(discounttxt));
                    }
                    else                        calculateDiscount(0.00);
                }
                catch (Exception ex)
                {

                }

            }

            @Override            public void afterTextChanged(Editable editable) {

            }
        });

        receivedCash_editTexat.addTextChangedListener(new TextWatcher() {
            @Override            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                try {
                    if(receivedCash_editTexat.getText().length() > 0)
                    {
                        String discounttxt = receivedCash_editTexat.getText().toString();
                        calculateChanges(Double.parseDouble(discounttxt));
                    }
                    else                       // calculateChanges(0.00);                    changes_editTexat.getText().clear();
                }
                catch (Exception ex)
                {

                }

            }

            @Override            public void afterTextChanged(Editable editable) {

            }
        });
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            table_id = extras.getInt("table_id");
            seat_id = extras.getInt("seat_id");
            order_no = extras.getInt("order_no");
        }
        orderno_txt.setText("Order #"+order_no);
        db = MasterDB.getInstance(this);
        restuarnt_img = (CircleImageView)findViewById(R.id.restuarnt_img);
        RestaurantImage = db.getRestaurantImage();
        Picasso.with(CheckoutActivity.this).load(RestaurantImage).error(R.drawable.ic_fri_logo).into(restuarnt_img, new Callback() {
            @Override            public void onSuccess() {
            }

            @Override            public void onError() {
            }
        });
        OrderDeatilsArray = new JSONArray();
        taxDeatilsArray = new JSONArray();
        if(order_no != 0)
        {
            OrderDeatilsArray = db.getOrderDeatilsForOrderNo(order_no);
            taxDeatilsArray = db.getTaxdeatils();
        }
        if(OrderDeatilsArray != null)
        {
            try {
                JSONObject object = db.RestaurantTableDeatils(OrderDeatilsArray.getJSONObject(0).getInt("table_id"));
                if(object != null) {
                    table_name.setText("Table #" + object.getString("table_name"));
                    JSONArray array = object.getJSONArray("seat_details");
                    for(int i = 0; i<array.length(); i++)
                    {
                        JSONObject object1 = array.getJSONObject(i);
                        if(object1.has("seat_id"))
                        {
                            if(object1.getInt("seat_id") == seat_id)
                                seat_name.setText("Seat "+object1.getString("seat_name"));
                        }
                    }
                }

                for(int count = 0; count < OrderDeatilsArray.length(); count++)
                {
                    itemAmount += OrderDeatilsArray.getJSONObject(count).getDouble("menu_price");
                }
                itemTotal_txt.setText(""+ df2.format(itemAmount));
                subToatl_txt.setText(""+ df2.format(itemAmount));

                if(taxDeatilsArray != null) {
                    try {
                        for(int counttax = 0; counttax < taxDeatilsArray.length(); counttax++)
                        {
                            JSONObject object2 = taxDeatilsArray.getJSONObject(counttax);
                            double taxDeatils = object2.getDouble("tax_amount");
                            double taxDeatil = ((taxDeatils  * itemAmount)/10.00);
                            taxAmount += taxDeatil;
                        }
                        tax1_txt.setText(""+ df2.format(taxAmount));
                        itemtotal.setText("Item total:\t" +DashBoard.currency);
                        topay.setText("To pay:\t" +DashBoard.currency);
                        amount_sign.setText("Amount:\t" +DashBoard.currency);
                        persentage_sign.setText("Percentage:\t" +"%");
                        discount_sign.setText("Sub Total (after discount):\t"  +DashBoard.currency);
                        case_recive_sign.setText("Cash received:\t"  +DashBoard.currency);
                        return_sign.setText("Return Change:\t"  +DashBoard.currency);

                    } catch (Exception ex) {

                    }
                }
                double toatalAmount = itemAmount + taxAmount;
                Total_txt.setText(""+df2.format(toatalAmount));
                orderDeatilsListAdapter = new OrderDeatilsListAdapter(CheckoutActivity.this);
                order_items_listview.setAdapter(orderDeatilsListAdapter);
            }
            catch (Exception ex)
            {

            }
        }
    }




    public void calculateChanges(Double receiveAmount)
    {
        double changeAmount = 0;
        DecimalFormat df2 = new DecimalFormat("#.##");
        Double subToatl = itemAmount - discountAmount;
        double toatalAmount = subToatl + taxAmount;
        changeAmount = receiveAmount - toatalAmount;
        reciveingAmount = receiveAmount;
        changes_editTexat.setText(""+Double.parseDouble(df2.format(changeAmount)));
    }


    public void  calculateDiscount(Double discountValue)
    {
        taxAmount = 0;
        DecimalFormat df2 = new DecimalFormat("#.##");
        if(discountValue > 0) {
            if(pre_discount_img.getTag().toString().equals("1")) {
                Double calculateDiscount = (itemAmount*discountValue)/10.00;
                discountprecents = Double.parseDouble(df2.format(discountValue));
                discountAmount = Double.parseDouble(df2.format(calculateDiscount));
            }
            else  if(amount_discount_img.getTag().toString().equals("1"))
            {
                discountAmount = Double.parseDouble(df2.format(discountValue));
                Double calculateDiscount = (100*discountValue)/itemAmount;
                discountprecents = Double.parseDouble(df2.format(calculateDiscount));
            }
            Double subToatl = itemAmount - discountAmount;
            subToatl_txt.setText("" + Double.parseDouble(df2.format(subToatl)));
            if (taxDeatilsArray != null) {
                try {
                    for (int counttax = 0; counttax < taxDeatilsArray.length(); counttax++) {
                        JSONObject object2 = taxDeatilsArray.getJSONObject(counttax);
                        double taxDeatils = object2.getDouble("tax_amount");
                        double taxDeatil = ((taxDeatils * subToatl) / 10.00);
                        taxAmount += taxDeatil;
                    }
                    tax1_txt.setText("" + Double.parseDouble(df2.format(taxAmount)));
                } catch (Exception ex) {

                }
            }
            double toatalAmount = subToatl + taxAmount;
            if(reciveingAmount > 0)
            {
                double changeAmount = reciveingAmount - toatalAmount;
                changes_editTexat.setText(""+Double.parseDouble(df2.format(changeAmount)));
            }
            Total_txt.setText("" + Double.parseDouble(df2.format(toatalAmount)));
        }
        else        {
            discountprecents = 0;
            discountAmount = 0;
            Double subToatl = itemAmount - 0;
            subToatl_txt.setText("" + Double.parseDouble(df2.format(subToatl)));
            if (taxDeatilsArray != null) {
                try {
                    for (int counttax = 0; counttax < taxDeatilsArray.length(); counttax++) {
                        JSONObject object2 = taxDeatilsArray.getJSONObject(counttax);
                        double taxDeatils = object2.getDouble("tax_amount");
                        double taxDeatil = ((taxDeatils * subToatl) / 10.00);
                        taxAmount += taxDeatil;
                    }
                    tax1_txt.setText("" + Double.parseDouble(df2.format(taxAmount)));
                } catch (Exception ex) {

                }
            }
            double toatalAmount = subToatl + taxAmount;
            if(reciveingAmount > 0)
            {
                double changeAmount = reciveingAmount - toatalAmount;
                changes_editTexat.setText(""+Double.parseDouble(df2.format(changeAmount)));
            }
            Total_txt.setText("" + Double.parseDouble(df2.format(toatalAmount)));
        }

    }

    public void showDialogForSelstingMenuQuantityItem()
    {
        final Dialog OrderQuantityDialog = new Dialog(CheckoutActivity.this, android.R.style.Theme_Black_NoTitleBar);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        OrderQuantityDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
        OrderQuantityDialog.setContentView(R.layout.dialog_for_taxes_order_details_layout);
        ListView tax_listview = (ListView)OrderQuantityDialog.findViewById(R.id.tax_listview);
        LinearLayout layout3 = (LinearLayout)OrderQuantityDialog.findViewById(R.id.layout3);
        LinearLayout layout2 = (LinearLayout)OrderQuantityDialog.findViewById(R.id.layout2);
        LinearLayout layout1 = (LinearLayout)OrderQuantityDialog.findViewById(R.id.layout1);
        layout1.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                OrderQuantityDialog.dismiss();
            }
        });
        layout2.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                OrderQuantityDialog.dismiss();
            }
        });
        layout3.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View view) {
                OrderQuantityDialog.dismiss();
            }
        });
        taxDeatilsListAdapter = new TaxDeatilsListAdapter(CheckoutActivity.this);
        tax_listview.setAdapter(taxDeatilsListAdapter);
        OrderQuantityDialog.setCancelable(true);
        OrderQuantityDialog.show();
    }
    @Override    public void onClick(View view) {
        switch (view.getId())
        {
            case R.id.back_btn:
                Intent j = new Intent(CheckoutActivity.this, SeatViewLayout.class);
                j.putExtra("table_id",String.valueOf(table_id));
                j.putExtra("seat_id",0);
                startActivity(j);
                finish();
                break;
            case R.id.tax_details_btn:
                showDialogForSelstingMenuQuantityItem();
                break;
            case R.id.pre_discount_img:
                if(amount_discount_img.getTag().toString().equals("1") && pre_discount_img.getTag().toString().equals("2"))
                {

                    amount_discount_img.setTag(2);
                    pre_discount_img.setTag(1);
                    amount_discount_img.setImageResource(R.drawable.ic_unselected_item);
                    pre_discount_img.setImageResource(R.drawable.ic_selected_item);
                    if(discountAmount > 0)
                    {
                        discount_editTexat.setText(""+discountprecents);
                    }
                }
                break;
            case R.id.amount_discount_img:
                if(pre_discount_img.getTag().toString().equals("1") && amount_discount_img.getTag().toString().equals("2"))
                {

                    amount_discount_img.setTag(1);
                    pre_discount_img.setTag(2);
                    pre_discount_img.setImageResource(R.drawable.ic_unselected_item);
                    amount_discount_img.setImageResource(R.drawable.ic_selected_item);
                    if(discountAmount > 0)
                    {
                        discount_editTexat.setText(""+discountAmount);
                    }
                }
                break;
            case R.id.settle_via_card:
                CheckoutForSeat(2);
                break;
            case R.id.settle_via_cash:
                CheckoutForSeat(1);
                break;
        }
    }


    public class CheckoutActivityTaskHandler extends Handler {
        public static final int PaymentDone = 1;
        public static final int PaymentNotDone = 2;

        @Override        public void handleMessage(@NonNull Message msg) {
            switch (msg.what)
            {
                case PaymentDone:
                    Intent j = new Intent(CheckoutActivity.this, SeatViewLayout.class);
                    j.putExtra("table_id",String.valueOf(table_id));
                    j.putExtra("seat_id",0);
                    startActivity(j);
                    finish();
                    break;
                case PaymentNotDone:
                    Toast.makeText(CheckoutActivity.this,"Payment not done",Toast.LENGTH_LONG).show();
                    break;
            }
        }
    }
    public void CheckoutForSeat(int i)
    {
        if(DashBoard.socketIoClass.client.connected())
        {
            try {
                if(order_no > 0) {

                    double totalAmount = db.getTotalAmount(order_no);
                    JSONObject object = new JSONObject();
                    JSONArray array = db.getTaxdeatils();
                    Double calculatedAmountFromTaxandDiscount = (double)totalAmount;
                    Double toataltaxDeatils = 0.00;
                    Double discount = 0.00;
                    Double grossTotal = calculatedAmountFromTaxandDiscount - discount;
                    calculatedAmountFromTaxandDiscount -= discount;
                    if(array != null)
                    {
                        for(int count = 0;  count < array.length(); count++)
                        {
                            double taxDeatils = array.getJSONObject(count).getDouble("tax_amount");
                            double taxDeatil = ((taxDeatils  * grossTotal)/10);
                            toataltaxDeatils += taxDeatil;
                            calculatedAmountFromTaxandDiscount += taxDeatil;
                        }
                    }
                    Double subToatl = itemAmount - discountAmount;
                    double toatalAmount = subToatl + taxAmount;
                    object.put("type", "payments");
                    JSONObject messgae = new JSONObject();
                    messgae.put("SocketId", DashBoard.socketIoClass.mySocketId);
                    messgae.put("user_id", DashBoard.user_id);
                    messgae.put("restaurant_id", DashBoard.restaurant_id);
                    messgae.put("order_no", order_no);
                    String currentDate = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(new Date());
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
                    String currentDateandTime = sdf.format(new Date());
                    String currentTime = new SimpleDateFormat("HH:mm:ss", Locale.getDefault()).format(new Date());
                    JSONObject orderDeatils = new JSONObject();
                    orderDeatils.put("amount", itemAmount);
                    orderDeatils.put("discount_amount", discountAmount);
                    orderDeatils.put("payment_date", currentDateandTime);
                    orderDeatils.put("payment_status", 1);
                    orderDeatils.put("payment_type", i);
                    orderDeatils.put("total_amount", toatalAmount);
                    orderDeatils.put("tax_details", taxAmount);
                    orderDeatils.put("payment_time", currentTime);
                    messgae.put("payments", orderDeatils);
                    object.put("message", messgae);
                    DashBoard.socketIoClass.sendMessage(object);
                }
                else                {
                    Toast.makeText(CheckoutActivity.this,"No Order for checkout",Toast.LENGTH_LONG).show();
                }
            }
            catch (Exception ex)
            {

            }
        }
    }

    public class TaxDeatilsListAdapter extends BaseAdapter {
        Context context;
        public TaxDeatilsListAdapter(Context context) {
            this.context = context;

        }

        @Override        public int getCount() {
            int count = taxDeatilsArray.length();
            return count;
        }

        @Override        public Object getItem(int position) {
            try {
                if (taxDeatilsArray == null)
                    return null;
                if (position < 0)
                    return null;
                return taxDeatilsArray.get(position);
            }
            catch (Exception ex)
            {
                return null;
            }

        }

        @Override        public long getItemId(int arg0) {
            return 0;
        }



        @Override        public View getView(final int position, View convertView,
                            ViewGroup parent) {
            TextView taxamounts,taxName;
            final LayoutInflater inflater = (LayoutInflater) CheckoutActivity.this                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.listview_item_for_taxes_layout,
                    null);
            taxamounts = (TextView)convertView.findViewById(R.id.taxamounts);
            taxName = (TextView)convertView.findViewById(R.id.taxName);
            try {
                JSONObject object = taxDeatilsArray.getJSONObject(position);
                if(object.has("tex_name"))
                {
                    taxName.setText(object.getString("tex_name" ));
                }

                if(object.has("tax_amount"))
                {
                    taxamounts.setText("% \t"  +object.getString("tax_amount" ));
                }

                  // When popup show Tax Percentage          /*      if(object.has("tax_amount"))                {                    DecimalFormat df2 = new DecimalFormat("#.##");                    Double grossAmount = itemAmount - discountAmount;                    double taxDeatils = object.getDouble("tax_amount");                    double taxDeatil = ((taxDeatils  * grossAmount)/100.00);                    taxamounts.setText(DashBoard.currency +taxDeatil);
                    //  taxamount.setText("" + Double.parseDouble(df2.format(taxDeatil)));
                }*/            }
            catch (Exception ex)
            {

            }

            convertView.setTag(position);

            return convertView;
        }

    }


    public class OrderDeatilsListAdapter extends BaseAdapter {
        Context context;
        public OrderDeatilsListAdapter(Context context) {
            this.context = context;

        }

        @Override        public int getCount() {
            int count = OrderDeatilsArray.length();
            return count;
        }

        @Override        public Object getItem(int position) {
            try {
                if (OrderDeatilsArray == null)
                    return null;
                if (position < 0)
                    return null;
                return OrderDeatilsArray.get(position);
            }
            catch (Exception ex)
            {
                return null;
            }

        }

        @Override        public long getItemId(int arg0) {
            return 0;
        }



        @Override        public View getView(final int position, View convertView,
                            ViewGroup parent) {
            TextView sno,itemData,quantity,amount;
            final LayoutInflater inflater = (LayoutInflater) CheckoutActivity.this                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.listview_item_order_deatils_layout,
                    null);
            sno = (TextView)convertView.findViewById(R.id.sno);
            itemData = (TextView)convertView.findViewById(R.id.itemData);
            quantity = (TextView)convertView.findViewById(R.id.quantity);
            amount = (TextView)convertView.findViewById(R.id.amount);
            int i = position + 1;
            sno.setText(""+i);
            try {
                JSONObject object = OrderDeatilsArray.getJSONObject(position);
                if(object.has("menu_name"))
                {
                    itemData.setText(object.getString("menu_name" ));
                }
                if(object.has("item_quantity"))
                {
                    quantity.setText(""+object.getInt("item_quantity"));
                }
                if(object.has("menu_price"))
                {
                    amount.setText(DashBoard.currency +object.getDouble("menu_price"));
                }
            }
            catch (Exception ex)
            {

            }

            convertView.setTag(position);

            return convertView;
        }

    }
}

No comments:

Post a Comment