<?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:keepScreenOn="true"
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:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3">
<ImageView
android:id="@+id/back_btn"
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:visibility="gone"
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|left"
android:visibility="visible"
android:clickable="false"
android:focusable="false"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="center|left"
android:paddingLeft="30dp"
android:text="S.no"
android:textColor="#343434"
android:textSize="@dimen/text_size_small" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="60">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="20">
</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.7"
android:orientation="horizontal"
>
<TextView
android:id="@+id/customerdeatilsSS"
android:layout_width="0dp"
android:layout_weight="3.5"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:clickable="false"
android:focusable="false"
android:gravity="center|left"
android:text="Order #"
android:paddingLeft="25dp"
android:textColor="#717171"
android:fontFamily="@font/source_sans_pro_regular"
android:textSize="@dimen/text_size_medium_small" />
<TextView
android:id="@+id/custemer_details"
android:layout_width="0dp"
android:layout_weight="3.5"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:clickable="false"
android:focusable="false"
android:gravity="center|right"
android:text="custemer_details"
android:paddingRight="20dp"
android:fontFamily="@font/source_sans_pro_regular"
android:textColor="#717171"
android:textSize="@dimen/text_size_medium_small" />
<TextView
android:id="@+id/Phonenumber"
android:layout_width="0dp"
android:layout_weight="2.5"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:clickable="false"
android:drawableLeft="@drawable/called"
android:focusable="false"
android:gravity="center|left"
android:text="Price"
android:textColor="#03A9F4"
android:fontFamily="@font/source_sans_pro_regular"
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:layout_height="0dp"
android:layout_weight="0.5"
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_bold"
android:gravity="center"
android:text="S.no"
android:textColor="#717171"
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="2.5"
android:clickable="false"
android:focusable="false"
android:fontFamily="@font/source_sans_pro_bold"
android:gravity="center"
android:text="Item"
android:textColor="#717171"
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="2"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false"
android:fontFamily="@font/source_sans_pro_bold"
android:gravity="center"
android:text="Kitchen Status"
android:textColor="#717171"
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/customerdeatilsss"
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_bold"
android:gravity="center"
android:text="Quantity"
android:textColor="#717171"
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_bold"
android:gravity="center"
android:text="Price"
android:textColor="#717171"
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_history_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="1dp"
android:background="#D2D2D2"></LinearLayout>
<LinearLayout
android:id="@+id/MessageHide"
android:layout_width="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layout_height="@dimen/bottom_menu_hegiht_width_40">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="8"
android:weightSum="1"
android:background="@drawable/my_custom_background"
android:layout_height="match_parent">
<TextView
android:id="@+id/Message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|left"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:gravity="center|left"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:text="I think the Food Network is doing such a disservice to the home cook"
android:fontFamily="@font/source_sans_pro_regular"
android:textColor="#717171"
android:textSize="@dimen/text_size_medium_small"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="0.1"
android:layout_height="match_parent"></LinearLayout>
</LinearLayout>
<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: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: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_marginLeft="5dp"
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: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="Paid"
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" />
<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="00.00"
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:layout_marginTop="3dp"
android:layout_marginBottom="10dp"
android:clickable="false"
android:focusable="false"
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="1"
android:layout_height="match_parent"></LinearLayout>
</LinearLayout>
</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="0.7">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
>
<TextView
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_bold"
android:gravity="center"
android:textColor="#717171"
android:textSize="@dimen/text_size_medium_small" />
<TextView
android:id="@+id/CancelOrder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="2.5"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="center|right"
android:text="Cancel order"
android:textColor="#FA8080"
android:clickable="false"
android:textSize="@dimen/text_size_medium" />
<TextView
android:id="@+id/settle_via_cash"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="@font/source_sans_pro_regular"
android:gravity="center|right"
android:text="Print receipt"
android:textColor="#006FFF"
android:textSize="@dimen/text_size_medium" />
<LinearLayout
android:layout_width="50dp"
android:layout_height="match_parent"></LinearLayout>
<LinearLayout
android:layout_width="40dp"
android:layout_height="match_parent"></LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"></LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
2.:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#D2D2D2"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
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="#717171"
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/itemproduct"
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_regular"
android:gravity="center"
android:text="Item"
android:textColor="#717171"
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/KitchenStatus"
android:layout_width="0dp"
android:layout_weight="2"
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="Sent to kitchen"
android:textColor="#E26900"
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/Quantity"
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="#717171"
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/Price"
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="Price"
android:textColor="#717171"
android:textSize="@dimen/text_size_medium_small" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:paddingTop="10dp"
android:background="#D2D2D2"></LinearLayout>
</LinearLayout>
Sourse code:
import android.Manifest; import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Button; 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.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.cardview.widget.CardView; import androidx.core.app.ActivityCompat; import com.dfoe.frimaster.DataBaseServices.MasterDB; import com.dfoe.frimaster.FragmentForDashBorad.TakeAwayFragment; import com.dfoe.frimaster.RetrofitServices.RetrofitInterfaceTask; import com.google.gson.JsonObject; import com.squareup.picasso.Callback; import com.squareup.picasso.Picasso; import org.json.JSONArray; import org.json.JSONException; 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; import okhttp3.MediaType; import okhttp3.RequestBody; import retrofit2.Call; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; import static android.view.Gravity.LEFT; public class Take_Away_View_Details extends AppCompatActivity implements View.OnClickListener { ListView order_history_listview; // CustomListAdapter customListAdapter; ImageView back_btn, tax_details_btn; public static int orderNo = 0, restaurant_id, user_id; MasterDB db; JSONArray TakeAwayDeatilss = new JSONArray(); Take_Away_View_Details.OrderDeatilsListAdapter orderDeatilsListAdapter; Take_Away_View_Details.TaxDeatilsListAdapter taxDeatilsListAdapter; JSONArray OrderDeatilsArray, taxDeatilsArray, paymentDeatilsArray, MessageDetails; TextView Total_Amount_Paid, view_details, texts, itemTotal_txt, tax1_txt, Total_txt, masterName; public static TextView customerdeatilsSS, custemer_details, Phonenumber, Message; double itemAmount = 0; double taxAmount = 0; double totalTaxDeatils = 0.00; double discountAmount = 0; double discountprecents = 0; double reciveingAmount = 0; JSONArray taxArray = new JSONArray(); LinearLayout tax_layout, MessageHide; DecimalFormat df2 = new DecimalFormat("#.##"); public static String RestaurantName = ""; public String RestaurantImage = ""; CircleImageView restuarnt_img; TextView cancelOrder; private ClipboardManager myClipboard; private ClipData myClip; final int position = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); //will hide the title getSupportActionBar().hide(); // hide the title bar db = MasterDB.getInstance(getApplicationContext()); TakeAwayDeatilss = db.getOrderDetailsFromPayments(); setContentView(R.layout.takeaway_view_details_layout); order_history_listview = (ListView) findViewById(R.id.order_history_listview); back_btn = (ImageView) findViewById(R.id.back_btn); Total_Amount_Paid = (TextView) findViewById(R.id.Total_txt); tax1_txt = (TextView) findViewById(R.id.tax1_txt); itemTotal_txt = (TextView) findViewById(R.id.itemTotal_txt); DecimalFormat df2 = new DecimalFormat("#.##"); RestaurantName = db.getRestaurantDeatils(); tax_layout = (LinearLayout) findViewById(R.id.tax_layout); tax_layout.setOnClickListener(this); restuarnt_img = (CircleImageView) findViewById(R.id.restuarnt_img); masterName = (TextView) findViewById(R.id.masterName); customerdeatilsSS = (TextView) findViewById(R.id.customerdeatilsSS); tax_details_btn = (ImageView) findViewById(R.id.tax_details_btn); custemer_details = (TextView) findViewById(R.id.custemer_details); Phonenumber = (TextView) findViewById(R.id.Phonenumber); cancelOrder = (TextView) findViewById(R.id.CancelOrder); Message = (TextView) findViewById(R.id.Message); MessageHide = (LinearLayout) findViewById(R.id.MessageHide); tax_details_btn.setOnClickListener(this); RestaurantImage = db.getRestaurantImage(); // masterName.setText(RestaurantName + " "); masterName.setText(DashBoard.RestaurantName + " "); myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); Picasso.with(Take_Away_View_Details.this).load(RestaurantImage).error(R.drawable.ic_fri_logo).into(restuarnt_img, new Callback() { @Override public void onSuccess() { } @Override public void onError() { } }); // tax_details_btn.setOnClickListener(this); /* Phonenumber.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT > 22) { if (ActivityCompat.checkSelfPermission(Take_Away_View_Details.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(Take_Away_View_Details.this, new String[]{Manifest.permission.CALL_PHONE}, 101); return; } Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:+" + Phonenumber.getText().toString().trim())); startActivity(callIntent); } else { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:+" + Phonenumber.getText().toString().trim())); startActivity(callIntent); } } });*/ Phonenumber.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String text; text = Phonenumber.getText().toString(); myClip = ClipData.newPlainText("text", text); myClipboard.setPrimaryClip(myClip); Toast.makeText(getApplicationContext(), "Phone number copied", Toast.LENGTH_SHORT).show(); } }); Bundle extras = getIntent().getExtras(); if (extras != null) { orderNo = extras.getInt("order_no"); } OrderDeatilsArray = new JSONArray(); taxDeatilsArray = new JSONArray(); MessageDetails = new JSONArray(); if (orderNo != 0) { OrderDeatilsArray = db.getOrderDeatilsForOrderNo(orderNo); paymentDeatilsArray = db.getPaymentdeatils(orderNo); taxDeatilsArray = db.getTaxdeatils(); MessageDetails = db.getMessagesDeatilsForOrderNo(orderNo); } try { if (MessageDetails==null || TextUtils.isEmpty(MessageDetails.getJSONObject(0).getString("message")) || MessageDetails.getJSONObject(0).getString("message") == null || MessageDetails.getJSONObject(0).getString("message").equalsIgnoreCase("null")) { MessageHide.setVisibility(View.GONE); } } catch (JSONException e) { e.printStackTrace(); } if (OrderDeatilsArray != null && paymentDeatilsArray != null) { try { Double amount = paymentDeatilsArray.getJSONObject(0).getDouble("amount"); // itemTotal_txt.setText(DashBoard.currency + amount); Total_Amount_Paid.setText(DashBoard.currency + paymentDeatilsArray.getJSONObject(0).getDouble("total_amount")); custemer_details.setText("Customer detail:\t" + OrderDeatilsArray.getJSONObject(0).getString("name")); Phonenumber.setText(OrderDeatilsArray.getJSONObject(0).getString("user_phone")); if (OrderDeatilsArray.getJSONObject(0).getInt("order_status") != 0) { cancelOrder.setClickable(true); cancelOrder.setOnClickListener(this); cancelOrder.setTextColor(Color.parseColor("#FF0000")); } } catch (Exception ex) { } } if (MessageDetails != null) { try { Message.setText(MessageDetails.getJSONObject(0).getString("message")); } catch (Exception ex) { } } else { MessageHide.setVisibility(View.GONE); } for (int count = 0; count < OrderDeatilsArray.length(); count++) { try { itemAmount += OrderDeatilsArray.getJSONObject(count).getDouble("menu_price"); } catch (JSONException e) { e.printStackTrace(); } } // texts.setText(""+ df2.format(itemAmount));// itemTotal_txt.setText(""+ df2.format(itemAmount)); itemTotal_txt.setText(DashBoard.currency + 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) / 100.00); taxAmount += taxDeatil; } tax1_txt.setText("" + df2.format(taxAmount)); } catch (Exception ex) { } } double toatalAmount = itemAmount + taxAmount; // texts.setText(""+df2.format(toatalAmount)); back_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); SetUpUi(); } /* @Override public void onBackPressed() { Intent j = new Intent(Take_Away_View_Details.this, TakeAwayFragment.class); //Intent j = new Intent(UserProfile.this, OrderHistory.class); startActivity(j); finish(); }*/ public void SetUpUi() { try { if (TakeAwayDeatilss != null) { Double subTotal1 = 0.00; orderDeatilsListAdapter = new OrderDeatilsListAdapter(Take_Away_View_Details.this); order_history_listview.setAdapter(orderDeatilsListAdapter); } } catch (Exception ex) { } } @Override public void onClick(View view) { switch (view.getId()) { case R.id.back_btn: finish(); break; case R.id.tax_details_btn: if (taxDeatilsArray != null) showDialogForSelstingMenuQuantityItem(); break; case R.id.CancelOrder: showCancelOrderDialog(); break; } } public void showDialogForSelstingMenuQuantityItem() { final Dialog OrderQuantityDialog = new Dialog(Take_Away_View_Details.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 Take_Away_View_Details.TaxDeatilsListAdapter(Take_Away_View_Details.this); tax_listview.setAdapter(taxDeatilsListAdapter); OrderQuantityDialog.setCancelable(true); OrderQuantityDialog.show(); } 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) Take_Away_View_Details.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")) { Double amount = paymentDeatilsArray.getJSONObject(0).getDouble("amount"); Double grossAmount = amount - paymentDeatilsArray.getJSONObject(0).getDouble("discount_amount"); double taxDeatils = object.getDouble("tax_amount"); double taxDeatil = ((taxDeatils * grossAmount) / 100.00); taxamounts.setText(DashBoard.currency + 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; TextView itemproduct, OrderNo; TextView Quantity, Price, KitchenStatus; final LayoutInflater inflater = (LayoutInflater) Take_Away_View_Details.this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.takeway_listview_item_order_deatils_layout, null); sno = (TextView) convertView.findViewById(R.id.sno); itemproduct = (TextView) convertView.findViewById(R.id.itemproduct); OrderNo = (TextView) convertView.findViewById(R.id.OrderNo); Quantity = (TextView) convertView.findViewById(R.id.Quantity); Price = (TextView) convertView.findViewById(R.id.Price); KitchenStatus = (TextView) convertView.findViewById(R.id.KitchenStatus); int i = position + 1; sno.setText("" + i); try { JSONObject object = OrderDeatilsArray.getJSONObject(position); /* if(object.has("order_no")) { OrderNo.setText("order_no"+orderNo); //OrderNo.setText(""+object.getInt("order_no")); }*/ if (object.has("item_quantity")) { Quantity.setText("" + object.getInt("item_quantity")); } if (object.has("menu_price")) { Price.setText(DashBoard.currency + object.getDouble("menu_price")); } if (object.has("menu_name")) { itemproduct.setText("" + object.getString("menu_name")); } /* if (object.has("served_status")) { int server_status = object.getInt("served_status"); if (server_status == 0) { KitchenStatus.setText("Send to kitchen"); } else if (server_status == 1) { KitchenStatus.setText("Cooking"); } else if (server_status == 2) { KitchenStatus.setText("Ready to serve"); } }*/ if (object.has("served_status")) { int server_status = object.getInt("served_status"); if (object.has("order_status") && object.getInt("order_status") == 0) { KitchenStatus.setText("NA"); } else if (server_status == 0) { KitchenStatus.setText("Sent to kitchen"); } else if (server_status == 1) { KitchenStatus.setText("Cooking"); } else if (server_status == 2) { KitchenStatus.setText("Ready to serve"); } else { KitchenStatus.setText("N/A"); } } } catch (Exception ex) { } if (OrderDeatilsArray != null) { try { customerdeatilsSS.setText("Order #" + orderNo); // OrderNo.setText("" + orderNo); } catch (Exception ex) { } } convertView.setTag(position); return convertView; } } private void showCancelOrderDialog() { final Dialog OrderQuantityDialog = new Dialog(this, android.R.style.Theme_Black_NoTitleBar); OrderQuantityDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); OrderQuantityDialog.setContentView(R.layout.dialog_removedata_layout); CardView cancel_button = (CardView) OrderQuantityDialog.findViewById(R.id.cancel_button); CardView confirm_button = (CardView) OrderQuantityDialog.findViewById(R.id.confirm_button); TextView textWarningMsg = (TextView) OrderQuantityDialog.findViewById(R.id.textWarningMsg); textWarningMsg.setText(" This order will be Cancelled and a refund will be initiated for the customer."); final EditText EditTextFeedbackBody = (EditText) OrderQuantityDialog.findViewById(R.id.EditTextFeedbackBody); EditTextFeedbackBody.setHint("Please mention the reason for cancellation"); confirm_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { /* int id = 0; // db.deleteTakewaydOrders(id); int position = 0; TakeAwayDeatilss.remove(position); orderHistoryListAdapters.notifyDataSetChanged(); Toast.makeText(getActivity(), "Item Deleted", Toast.LENGTH_LONG).show(); OrderQuantityDialog.dismiss();*/ String CancelMessage = EditTextFeedbackBody.getText().toString(); if (DashBoard.socketIoClass.client.connected()) { try { JSONObject object = new JSONObject(); object.put("type", "cancel_order"); JSONObject messgae = new JSONObject(); messgae.put("SocketId", DashBoard.socketIoClass.mySocketId); messgae.put("restaurant_id", DashBoard.restaurant_id); messgae.put("order_no", orderNo); messgae.put("user_id", DashBoard.user_id); messgae.put("message", CancelMessage); object.put("message", messgae); DashBoard.socketIoClass.sendMessage(object); Toast.makeText(Take_Away_View_Details.this, "Cancel Order", Toast.LENGTH_LONG).show(); OrderQuantityDialog.dismiss(); finish(); } catch (Exception ex) { } } } }); cancel_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { OrderQuantityDialog.dismiss(); } }); OrderQuantityDialog.setCancelable(false); OrderQuantityDialog.show(); } }
No comments:
Post a Comment