Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
67 kB
1
Indexable
Never
package com.apexmart.second_pocket.ui;

import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.database.Cursor;
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.provider.MediaStore;
import android.provider.Settings;
import android.text.Editable;
import android.text.Html;
import android.text.InputFilter;
import android.text.InputType;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
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.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
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.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.apexmart.second_pocket.Fragment.my_order_fragment;
import com.apexmart.second_pocket.Network.WebService;
import com.apexmart.second_pocket.R;
import com.apexmart.second_pocket.Util.Constants;
import com.apexmart.second_pocket.pojo.Delete_product_POJO;
import com.apexmart.second_pocket.pojo.MyOrder_POJO;
import com.apexmart.second_pocket.pojo.Update_product_POJO;
import com.apexmart.second_pocket.pojo.amz_MODAL;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.facebook.shimmer.ShimmerFrameLayout;
import com.google.android.material.snackbar.Snackbar;
import com.hbisoft.pickit.PickiT;
import com.hbisoft.pickit.PickiTCallbacks;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class OrderDetail extends AppCompatActivity implements PickiTCallbacks {
    ImageView img_back, checkPoint1, checkPoint2, checkPoint3, checkPoint5, checkPoint6, checkPoint7, product_imgD, brand_imgD, offer_imgD;
    TextView image, orderID, shippingID, shippingID_courier, btn_save, offer_disD, disD2, disD, compny_nameD, other_txt, flash_coin_txt, earn_text, cash_txt, flipkart_coin_txt, product_tds_txt;
    TextView mobile_noPrint, OTP_order_print, ord_deliver_name;
    TextView detail_pincode, detail_city, detail_address1, detail_address2, detail_state, editor_title2, editor_title, my_order_holder_odr_now;
    ShimmerFrameLayout btn_shimmer;
    ImageView image_preview;
    TextView product_title_s1, product_title_s2, product_title_s3, product_title_s4;
    TextView product_s1, product_s2, product_s3, product_s4;
    String waypathPhoto_book;
    String invoice;
    EditText editor_edt;
    String brand_photo, product_photo, link, offer_photo, photo_back, time, product_id, status, order_status, shipping_status, delivery_status;
    LinearLayout product_ll11, product_ll22, product_ll44, odr_ll;
    ClipData clip;
    ClipboardManager clipboard;

    TextView order_date, order_id_date, tracking_id_date, mobile_date, otp_date, image_date, select, cancel_odr_btn, title_text;
    TextView edit_order_id, edit_tracking_id, edit_mobile, edit_otp;
    String status_date, order_status_date, shipping_status_date;
    SimpleDateFormat simpleDateFormat;
    String dateTime;
    String courier_c_name = "";
    ConstraintLayout order_cc;
    String mimeType;
    boolean allSub = false;
    PickiT pickiT;
    Uri selectedImageUri = null;
    boolean patter_flag = false;
    boolean order_id_flag = false;
    boolean UPLOAD_FLAG = false;
    String line_1;

    MyOrder_POJO.Cart cartList;
    MyOrder_POJO.Add addList;

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

        simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");
        dateTime = simpleDateFormat.format(Calendar.getInstance().getTime());
        clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

        checkPoint1 = findViewById(R.id.checkPoint1);
        checkPoint2 = findViewById(R.id.checkPoint2);
        checkPoint3 = findViewById(R.id.checkPoint3);
        checkPoint5 = findViewById(R.id.checkPoint5);
        checkPoint6 = findViewById(R.id.checkPoint6);
        checkPoint7 = findViewById(R.id.checkPoint7);

        order_date = findViewById(R.id.order_date);
        order_id_date = findViewById(R.id.order_id_date);
        edit_order_id = findViewById(R.id.edit_order_id);
        tracking_id_date = findViewById(R.id.tracking_id_date);
        edit_tracking_id = findViewById(R.id.edit_tracking_id);
        mobile_date = findViewById(R.id.mobile_date);
        edit_mobile = findViewById(R.id.edit_mobile);
        otp_date = findViewById(R.id.otp_date);
        edit_otp = findViewById(R.id.edit_otp);
        image_date = findViewById(R.id.image_date);
        select = findViewById(R.id.select);
        cancel_odr_btn = findViewById(R.id.cancel_odr_btn);
        editor_title = findViewById(R.id.editor_title);
        editor_title2 = findViewById(R.id.editor_title2);
        my_order_holder_odr_now = findViewById(R.id.my_order_holder_odr_now);

        pickiT = new PickiT(this, this, this);
        img_back = findViewById(R.id.img_back);
        image = findViewById(R.id.image);
        title_text = findViewById(R.id.title_text);
        offer_imgD = findViewById(R.id.offer_imgD);
        brand_imgD = findViewById(R.id.brand_imgD);
//        accepted_date = findViewById(R.id.accepted_date);
//        order_date = findViewById(R.id.order_date);
//        shipping_date = findViewById(R.id.shipping_date);
//        delivered_date = findViewById(R.id.delivered_date);
        product_imgD = findViewById(R.id.product_imgD);
        compny_nameD = findViewById(R.id.compny_nameD);
        disD = findViewById(R.id.disD);
        disD2 = findViewById(R.id.disD2);
        btn_save = findViewById(R.id.btn_save);
        btn_shimmer = findViewById(R.id.btn_shimmer);
        editor_edt = findViewById(R.id.editor_edt);
        orderID = findViewById(R.id.orderID);
        shippingID = findViewById(R.id.shippingID);
        shippingID_courier = findViewById(R.id.shippingID_courier);
        offer_disD = findViewById(R.id.offer_discriptionD);
        mobile_noPrint = findViewById(R.id.mobile_noPrint);
        OTP_order_print = findViewById(R.id.OTP_order_print);
        ord_deliver_name = findViewById(R.id.ord_deliver_name);
        odr_ll = findViewById(R.id.odr_ll);
        order_cc = findViewById(R.id.order_cc22);
        cash_txt = findViewById(R.id.cash_txt);
        earn_text = findViewById(R.id.earn_text);
        flipkart_coin_txt = findViewById(R.id.flipkart_coin_txt);
        flash_coin_txt = findViewById(R.id.flash_coin_txt);
        other_txt = findViewById(R.id.other_txt);
        product_tds_txt = findViewById(R.id.product_tds_txt);

        detail_address1 = findViewById(R.id.detail_address1);
        detail_address2 = findViewById(R.id.detail_address2);
        detail_pincode = findViewById(R.id.detail_pincode);
        detail_city = findViewById(R.id.detail_city);
        detail_state = findViewById(R.id.detail_state);

        product_s1 = findViewById(R.id.product_s1);
        product_s2 = findViewById(R.id.product_s2);
        product_s3 = findViewById(R.id.product_s3);
        product_s4 = findViewById(R.id.product_s4);

        product_title_s1 = findViewById(R.id.product_title_s1);
        product_title_s2 = findViewById(R.id.product_title_s2);
        product_title_s3 = findViewById(R.id.product_title_s3);
        product_title_s4 = findViewById(R.id.product_title_s4);

        product_ll11 = findViewById(R.id.product_ll11);
        product_ll22 = findViewById(R.id.product_ll22);
        product_ll44 = findViewById(R.id.product_ll44);

//      editOrder =findViewById(R.id.editOrder);

        btn_shimmer.hideShimmer();
        title_text.setText("Deal Detail");

        Intent intent = getIntent();
        cartList = intent.getParcelableExtra("data");
        addList = intent.getParcelableExtra("data2");


        if (cartList != null) {
            CoinSet();
        }


        time = cartList.getDateTime();
        brand_photo = cartList.getBrandPhoto();
        product_photo = cartList.getProductPhoto();
        link = cartList.getLink();
        offer_photo = cartList.getOfferPhoto();
        photo_back = cartList.getPhotoBack();
        product_id = cartList.getId();
        status = cartList.getStatus();
        order_status = cartList.getOrderStatus();
        shipping_status = cartList.getShippingStatus();
        delivery_status = cartList.getDeliveryStatus();
        invoice = cartList.getImage();
        line_1 = cartList.getLine1();

        order_id_date.setText(cartList.getOrderIdDate());
        tracking_id_date.setText(cartList.getTrackingIdDate());
        mobile_date.setText(cartList.getMobileDate());
        otp_date.setText(cartList.getOtpDate());
        image_date.setText(cartList.getImageDate());


        offer_disD.setText(cartList.getOfferDiscription());
        disD.setText(cartList.getDiscription());
        disD2.setText(Html.fromHtml(cartList.getContent()));

        compny_nameD.setText(cartList.getCompnyName() + " " + cartList.getProductName());
//        product_nameD.setText(cartList.getStringExtra("product_name"));

        status_date = cartList.getStatusDate();
        order_status_date = cartList.getOrderStatus();
        shipping_status_date = cartList.getShippingStatus();

        detail_address1.setText(line_1);
        detail_address2.setText(addList.getFlat() + " " + addList.getArea() + " " + addList.getLandmark());
        detail_city.setText(addList.getCity());
        detail_pincode.setText(addList.getPincode());
        detail_state.setText(addList.getState());

        Glide.with(OrderDetail.this).load(brand_photo).timeout(30000).into(brand_imgD);
        Glide.with(OrderDetail.this).load(product_photo).timeout(30000).transition(DrawableTransitionOptions.withCrossFade()).into(product_imgD);
        Glide.with(OrderDetail.this).load(offer_photo).timeout(30000).transition(DrawableTransitionOptions.withCrossFade()).into(offer_imgD);

        order_date.setText(cartList.getDate());
        orderID.setText(cartList.getOrderId());
        shippingID.setText(cartList.getTrackingId());
        mobile_noPrint.setText(cartList.getMobile());
        OTP_order_print.setText(cartList.getOtp());
        ord_deliver_name.setText(addList.getFullName());
        courier_c_name = cartList.getDeliveryCom();


        product_title_s1.setText(cartList.getF1());
        product_s1.setText(cartList.getF11());
        product_title_s2.setText(cartList.getF2());
        product_s2.setText(cartList.getF22());
        product_title_s3.setText(cartList.getF3());
        product_s3.setText(cartList.getF33());
        product_title_s4.setText(cartList.getF4());
        product_s4.setText(cartList.getF44());

        checkPoint1.setBackgroundResource(R.drawable.ic_group_tick);
        if (!orderID.getText().toString().equals("")) {
            checkPoint2.setBackgroundResource(R.drawable.ic_group_tick);
            order_id_date.setVisibility(View.VISIBLE);
            edit_order_id.setVisibility(View.VISIBLE);
            editor_edt.setVisibility(View.GONE);
            select.setVisibility(View.VISIBLE);
            odr_ll.setVisibility(View.GONE);
            btn_save.setText("select");

        }
        if (!courier_c_name.equals("")) {
            shippingID_courier.setText(courier_c_name);
            shippingID.setVisibility(View.GONE);
            shippingID_courier.setVisibility(View.VISIBLE);
            edit_tracking_id.setVisibility(View.VISIBLE);
            editor_edt.setHint("88888888888888");
            editor_title.setText("Enter Tracking ID");
            editor_title2.setText("Select the courier service used and provide the tracking ID to track the order.");
            editor_edt.setVisibility(View.VISIBLE);
            select.setVisibility(View.GONE);
            btn_save.setText("save");
            checkPoint2.setBackgroundResource(R.drawable.ic_group_tick);
            order_id_date.setVisibility(View.VISIBLE);
            edit_order_id.setVisibility(View.VISIBLE);

            setEditor_length(courier_c_name);
        }
        if (!shippingID.getText().toString().equals("")) {
            shippingID.setVisibility(View.VISIBLE);
            edit_tracking_id.setVisibility(View.VISIBLE);
            tracking_id_date.setVisibility(View.VISIBLE);
            editor_edt.setHint("+88 8888888888");
            editor_title.setText("Enter Mobile Number");
            editor_title2.setText("Provide the mobile number used in the address to verify the details.");
            editor_edt.setInputType(InputType.TYPE_CLASS_NUMBER);
            editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(10)});

            checkPoint3.setBackgroundResource(R.drawable.ic_group_tick);


        }
        if (!mobile_noPrint.getText().toString().equals("")) {
            edit_mobile.setVisibility(View.VISIBLE);
            mobile_date.setVisibility(View.VISIBLE);
            editor_edt.setHint("888888");
            editor_title.setText("Enter OTP");
            editor_title2.setText("If no OTP is required, enter 0000. Submit the OTP on the day of delivery only.");
            editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(6)});

            checkPoint5.setBackgroundResource(R.drawable.ic_group_tick);


        }
        if (!OTP_order_print.getText().toString().equals("")) {
            editor_title.setText("Upload invoice");
            editor_title2.setText("upload the invoice you get from the order’s website when it’s delivered");
            edit_otp.setVisibility(View.VISIBLE);
            otp_date.setVisibility(View.VISIBLE);
            editor_edt.setVisibility(View.GONE);
            select.setVisibility(View.VISIBLE);
            select.setText("Upload new invoice");
            select.setCompoundDrawablesWithIntrinsicBounds(R.drawable.upload_icon, 0, 0, 0);
            btn_save.setText("select");
            checkPoint6.setBackgroundResource(R.drawable.ic_group_tick);


        }
        if (invoice.contains(".jpg") || invoice.contains(".png") || invoice.contains(".jpeg") || invoice.contains(".pdf")) {

            checkPoint7.setBackgroundResource(R.drawable.ic_group_tick);
            Log.d("skdmvksmfdv", "dsvsdv");
            image.setVisibility(View.VISIBLE);
            btn_save.setVisibility(View.GONE);
            image_date.setVisibility(View.VISIBLE);
            order_cc.setVisibility(View.GONE);

        }


        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                if (selectedImageUri != null && (selectedImageUri.toString().contains(".jpg") || selectedImageUri.toString().contains(".png") || selectedImageUri.toString().contains(".jpeg"))) {

                    showAlertDialogButtonClicked3(view, selectedImageUri);

                } else {

                    Intent target = new Intent(Intent.ACTION_VIEW);
                    target.setDataAndType(selectedImageUri, "application/pdf");
                    target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    target.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

                    Intent intent = Intent.createChooser(target, "Open File");
                    try {
                        startActivity(intent);
                    } catch (ActivityNotFoundException e) {
                        // Instruct the user to install a PDF reader here, or something
                    }
                }

            }
        });
        edit_order_id.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog(orderID.getText().toString(), orderID, "Order ID");
            }
        });
        edit_tracking_id.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TextUtils.isEmpty(shippingID.getText().toString())) {
                    dialog2(false);
                } else {

                    dialog(shippingID.getText().toString(), shippingID, "Tracking ID");
                }

            }
        });
        edit_mobile.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                dialog(mobile_noPrint.getText().toString(), mobile_noPrint, "Mobile Number");

            }
        });
        edit_otp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog(OTP_order_print.getText().toString(), OTP_order_print, "OTP");
            }
        });
        my_order_holder_odr_now.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent2 = new Intent(OrderDetail.this, amazon_activity.class);

                intent2.putExtra("data", new amz_MODAL(
                        cartList.getYouWillReceive(),
                        cartList.getYouSpend(),
                        cartList.getTotalEarning(),
                        cartList.getAdd().getFlat(),
                        cartList.getAdd().getArea(),
                        cartList.getAdd().getLandmark(),
                        cartList.getAdd().getCity(),
                        cartList.getAdd().getPincode(),
                        cartList.getAdd().getState(),
                        cartList.getAdd().getGstNumber(),
                        cartList.getAdd().getGstName(),
                        cartList.getLink(),
                        cartList.getId(),
                        cartList.getProductName(),
                        cartList.getQty(),
                        "false"
                ));
            }
        });
        cancel_odr_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                cancel_dialog();
            }
        });
        editor_edt.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) {

                if (charSequence.toString().contains(" ")) {
                    editor_edt.setText(charSequence.toString().replace(" ", ""));
                    editor_edt.setSelection(editor_edt.getText().toString().length());


                }
                String core = charSequence.toString();
                int order_size_count = 0;
                if (core.contains("-")) {

                    int size = 0;
                    for (int j = 0; j < core.length(); j++) {

                        if (String.valueOf(core.charAt(j)).equals("-")) {
                            size++;
                        }

                    }
                    order_size_count = 17 + size;
                } else {
                    order_size_count = 17;

                }
                if (TextUtils.isEmpty(shippingID.getText().toString())) {

                    Pattern pattern;
                    Matcher matcher;
                    String EMAIL_PATTERN;
                    Log.d("cscscs", "bbbbb");

                    switch (courier_c_name) {

                        case "E-kart":

                            EMAIL_PATTERN = "^[A-Z]{4}[0-9]{10}$";
                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = matcher.matches();
                            Log.d("cscscs", String.valueOf(patter_flag));
                            break;

                        case "Delhivery":
                            EMAIL_PATTERN = "^[0-9]{13}$";
                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = matcher.matches();
                            break;

                        case "Bluedart":
                            EMAIL_PATTERN = "^[0-9]{11}$";

                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = matcher.matches();
                            break;

                        case "Fedex":
                            EMAIL_PATTERN = "^[0-9]{12}$";

                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = matcher.matches();
                            break;

                        case "Indiapost":
                            EMAIL_PATTERN = "^[A-Z]{2}[0-9]{9}[A-Z]{2}$";
                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = matcher.matches();
                            break;

                        case "ATS(Amazon Transport Services":
                            EMAIL_PATTERN = "^[0-9]{12}$";
                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = matcher.matches();
                            break;

                        case "E-com Express":
                            EMAIL_PATTERN = "^[0-9]{10}$";

                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = matcher.matches();
                            break;

                        case "Other":
                            EMAIL_PATTERN = "^[0-9A-Z]{20}$";

                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            patter_flag = true;
                            break;


                    }

                }

                if (TextUtils.isEmpty(orderID.getText().toString())) {

                    Pattern pattern;
                    Matcher matcher;
                    String EMAIL_PATTERN;
                    Log.d("cscscs", "bbbbb");

                    switch (cartList.getCompnyName()) {

                        case "Amazon":
                            editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(order_size_count)});
                            EMAIL_PATTERN = "^[0-9-]{" + order_size_count + "}$";
                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            order_id_flag = matcher.matches();
                            break;

                        case "Flipkart":
                            editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(20)});

                            EMAIL_PATTERN = "^OD[0-9]{18}$";
                            pattern = Pattern.compile(EMAIL_PATTERN);
                            matcher = pattern.matcher(charSequence.toString());
                            order_id_flag = matcher.matches();
                            break;

                        default:
                            order_id_flag = true;

                            break;


                    }

                }

            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });


        btn_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (selectedImageUri != null) {
                    empUPdateProfile(selectedImageUri);
                    return;
                }
                if (!OTP_order_print.getText().toString().equals("")) {
                    dialog();
                    return;
                }
                if (courier_c_name.equals("") && !orderID.getText().toString().equals("")) {
                    dialog2(false);
                    return;
                }

                if (!TextUtils.isEmpty(editor_edt.getText().toString()) || !editor_edt.getText().toString().contains(" ")) {

                    if (!editor_edt.getText().toString().contains(" ")) {

                        if (TextUtils.isEmpty(orderID.getText().toString())) {
                            if (!order_id_flag) {
                                HideKeyBoard(view);
                                Snackbar snackbar = Snackbar.make(findViewById(R.id.shippingID_courier), "Please enter valid Order ID", Snackbar.LENGTH_LONG);
                                snackbar.show();
                                return;
                            }
                            dialog_order();
                            orderID.setText(editor_edt.getText().toString());
                            edit_order_id.setVisibility(View.VISIBLE);
                            order_id_date.setVisibility(View.VISIBLE);
                            order_id_date.setText(dateTime);
                            checkPoint2.setBackgroundResource(R.drawable.ic_group_tick);
                            editor_edt.setVisibility(View.GONE);
                            editor_edt.setText("");
                            btn_save.setText("select");
                            select.setVisibility(View.VISIBLE);
                            callWeb();
                            odr_ll.setVisibility(View.GONE);
                            Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "Order ID Updated", Snackbar.LENGTH_LONG);
                            snackbar.show();
                            return;
                        }
                        if (TextUtils.isEmpty(shippingID.getText().toString())) {

                            if (!patter_flag) {
                                HideKeyBoard(view);

                                Snackbar snackbar = Snackbar.make(findViewById(R.id.shippingID_courier), "Please enter valid Tracking ID", Snackbar.LENGTH_LONG);
                                snackbar.show();
                                return;
                            }

                            shippingID_courier.setVisibility(View.GONE);
                            shippingID_courier.setText(courier_c_name);
                            shippingID.setVisibility(View.VISIBLE);
                            editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(10)});
                            edit_tracking_id.setVisibility(View.VISIBLE);
                            editor_edt.setHint("+88 8888888888");
                            editor_title.setText("Enter Mobile Number");
                            editor_title2.setText("Provide the mobile number used in the address to verify the details.");


                            shippingID.setText(editor_edt.getText().toString());
                            tracking_id_date.setVisibility(View.VISIBLE);
                            tracking_id_date.setText(dateTime);
                            checkPoint3.setBackgroundResource(R.drawable.ic_group_tick);
                            editor_edt.setText("");
                            callWeb();

                            select.setVisibility(View.GONE);
                            editor_edt.setInputType(InputType.TYPE_CLASS_NUMBER);
//                        animatedView4.setVisibility(View.INVISIBLE);

                            Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "Tracking ID Updated", Snackbar.LENGTH_LONG);
                            snackbar.show();
                            return;
                        }
                        if (TextUtils.isEmpty(mobile_noPrint.getText().toString())) {

                            if (editor_edt.getText().toString().length() != 10) {
                                HideKeyBoard(view);
                                Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "Enter valid mobile number", Snackbar.LENGTH_LONG);
                                snackbar.show();
                                return;
                            }
                            editor_edt.setHint("888888");
                            editor_title.setText("Enter OTP");
                            editor_title2.setText("If no OTP is required, enter 0000. Submit the OTP on the day of delivery only.");
                            checkPoint5.setBackgroundResource(R.drawable.ic_group_tick);
                            mobile_noPrint.setText(editor_edt.getText().toString());
                            mobile_date.setVisibility(View.VISIBLE);
                            mobile_date.setText(dateTime);
                            edit_mobile.setVisibility(View.VISIBLE);

                            select.setVisibility(View.GONE);
                            editor_edt.setText("");
                            editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(10)});

                            callWeb();

                            Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "Mobile Number Updated", Snackbar.LENGTH_LONG);
                            snackbar.show();
                            return;
                        }
                        if (TextUtils.isEmpty(OTP_order_print.getText().toString())) {

                            if (editor_edt.getText().toString().length() < 4 || editor_edt.getText().toString().length() > 10) {
                                HideKeyBoard(view);

                                Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "Enter valid OTP", Snackbar.LENGTH_LONG);
                                snackbar.show();
                                return;
                            }

                            checkPoint6.setBackgroundResource(R.drawable.ic_group_tick);
                            edit_otp.setVisibility(View.VISIBLE);
                            editor_edt.setHint("Upload new invoice");
                            editor_title.setText("Upload invoice");
                            editor_title2.setText("upload the invoice you get from the order’s website when it’s delivered");
                            OTP_order_print.setText(editor_edt.getText().toString());
                            editor_edt.setText("");
                            btn_save.setText("select");
                            otp_date.setText(dateTime);

                            otp_date.setVisibility(View.VISIBLE);
                            editor_edt.setVisibility(View.GONE);
                            select.setVisibility(View.VISIBLE);
                            callWeb();
                            Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "OTP Updated", Snackbar.LENGTH_LONG);
                            snackbar.show();
                            return;
                        }

                    } else {
                        Toast.makeText(OrderDetail.this, "Invalid detail entered", Toast.LENGTH_SHORT).show();
                    }

                } else {
                    Toast.makeText(OrderDetail.this, "Invalid detail entered", Toast.LENGTH_SHORT).show();
                }

            }
        });

        select.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (!OTP_order_print.getText().toString().equals("")) {
                    dialog();
                    return;
                }

                if (courier_c_name.equals("") && !orderID.getText().toString().equals("")) {
                    dialog2(false);
                    return;
                }


            }
        });


//        edit_order_detail.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                showAlertDialogButtonClicked3(view);
//            }
//        });


        img_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });

//        upload_btn.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Intent gal = new Intent(Intent.ACTION_PICK);
//                gal.setType("image/*");
//                startActivityForResult(gal, 2);
//            }
//        });

        detail_address1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                clip = ClipData.newPlainText("label", detail_address1.getText().toString());
                clipboard.setPrimaryClip(clip);
                Toast.makeText(OrderDetail.this, "Copied Line 1", Toast.LENGTH_SHORT).show();
            }
        });
        detail_address2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                clip = ClipData.newPlainText("label", detail_address2.getText().toString());
                clipboard.setPrimaryClip(clip);
                Toast.makeText(OrderDetail.this, "Copied Line 2", Toast.LENGTH_SHORT).show();
            }
        });
        detail_pincode.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                clip = ClipData.newPlainText("label", detail_pincode.getText().toString());
                clipboard.setPrimaryClip(clip);
                Toast.makeText(OrderDetail.this, "Copied pincode", Toast.LENGTH_SHORT).show();
            }
        });
        detail_city.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                clip = ClipData.newPlainText("label", detail_city.getText().toString());
                clipboard.setPrimaryClip(clip);
                Toast.makeText(OrderDetail.this, "Copied city", Toast.LENGTH_SHORT).show();
            }
        });
        detail_state.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                clip = ClipData.newPlainText("label", detail_state.getText().toString());
                clipboard.setPrimaryClip(clip);
                Toast.makeText(OrderDetail.this, "Copied state", Toast.LENGTH_SHORT).show();
            }
        });
    }

    private void CoinSet() {
        earn_text.setText(cartList.getTotalEarning() + " ₹");

        if (!TextUtils.isEmpty(cartList.getCash())) {
            cash_txt.setText(cartList.getCash());
            cash_txt.setVisibility(View.VISIBLE);
        }
        if (!TextUtils.isEmpty(cartList.getFlipcartCoin())) {
            flipkart_coin_txt.setText(cartList.getFlipcartCoin());
            flipkart_coin_txt.setVisibility(View.VISIBLE);
        }
        if (!TextUtils.isEmpty(cartList.getFlashCoin())) {
            flash_coin_txt.setText(cartList.getFlashCoin());
            flash_coin_txt.setVisibility(View.VISIBLE);
        }

        if (!TextUtils.isEmpty(cartList.getOther())) {
            other_txt.setText(cartList.getOther());
            other_txt.setVisibility(View.VISIBLE);
        }
        if (!TextUtils.isEmpty(cartList.getTds())) {
            product_tds_txt.setText(cartList.getTds() + " deal only if you can complete this order within the next 1 hour. The Order ID and Tracking ID");
            product_tds_txt.setVisibility(View.VISIBLE);
        }
    }

    private void HideKeyBoard(View view) {
        InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }


    private void callWeb() {

        SharedPreferences sharedPreferences = this.getSharedPreferences("MySharedPref", Context.MODE_PRIVATE);
        Log.d("user_Id", sharedPreferences.getString("user_Id", ""));
        Log.d("product_id", product_id);
        Log.d("orderID", orderID.getText().toString());
        Log.d("shippingID", shippingID.getText().toString());
        Log.d("status", status);
        Log.d("order_status", order_status);
        Log.d("shipping_status", shipping_status);
        Log.d("delivery_status", delivery_status);
        Log.d("mobile_noPrint", mobile_noPrint.getText().toString());
        Log.d("OTP_order_print", OTP_order_print.getText().toString());

        WebService.getClient().update_product(sharedPreferences.getString("user_Id", ""), product_id, orderID.getText().toString(), order_id_date.getText().toString(), shippingID.getText().toString(), tracking_id_date.getText().toString(), mobile_noPrint.getText().toString(), mobile_date.getText().toString(), OTP_order_print.getText().toString(), otp_date.getText().toString(), image_date.getText().toString(), courier_c_name, "").enqueue(new Callback<Update_product_POJO>() {
            @Override
            public void onResponse(Call<Update_product_POJO> call, Response<Update_product_POJO> response) {

//                Toast.makeText(OrderDetail.this, response.body().getMessage(), Toast.LENGTH_SHORT).show();

                response.body().getMessage();
            }

            @Override
            public void onFailure(Call<Update_product_POJO> call, Throwable t) {

            }
        });

    }

    @Override
    public void onBackPressed() {
        if (!UPLOAD_FLAG) {
            my_order_fragment.load = true;

            super.onBackPressed();
        } else {

            if (allSub) {
                my_order_fragment.load = true;

                super.onBackPressed();

            } else {
                showAlertDialogButtonClicked3();
            }

        }

    }

    public void showAlertDialogButtonClicked3() {

        SharedPreferences sharedPreferences = getSharedPreferences("MySharedPref", Context.MODE_PRIVATE);
        SharedPreferences.Editor myEdit = sharedPreferences.edit();
        AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.CustomAlertDialog);
        final View customLayout = getLayoutInflater().inflate(R.layout.final_kyc_dialog, null);
        builder.setView(customLayout);
        TextView cancel_kyc = customLayout.findViewById(R.id.cancel_kyc);
        TextView conConfirm = customLayout.findViewById(R.id.conConfirm);
        TextView textView18 = customLayout.findViewById(R.id.textView18);

        textView18.setText("You can not edit the details after this confirmation");
        AlertDialog dialog = builder.create();
        dialog.getWindow().setWindowAnimations(R.style.AnimationsDilog);

        Window window = dialog.getWindow();
        WindowManager.LayoutParams wlp = window.getAttributes();

        wlp.gravity = Gravity.CENTER;
        wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
        window.setAttributes(wlp);
        dialog.show();

        conConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                allSub = true;
                dialog.dismiss();
                onBackPressed();
            }
        });

        cancel_kyc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();

            }
        });


    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 2) {
            if (resultCode == RESULT_OK) {
                if (data != null) {
                    selectedImageUri = data.getData();
                    pickiT.getPath(data.getData(), Build.VERSION.SDK_INT);
                    image.setVisibility(View.VISIBLE);

                    if (selectedImageUri != null) {
                        btn_save.setText("upload");
                        select.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_tick_double_dark, 0, 0, 0);
                        select.setCompoundDrawableTintList(ColorStateList.valueOf(Color.parseColor("#00A354")));
                        select.setTextColor(Color.parseColor("#00A354"));
                        select.setText("Image Selected");
                    }
                }
            }
        }
    }

    private void empUPdateProfile(Uri uriPhoto) {

        SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences("MySharedPref", getApplicationContext().MODE_PRIVATE);
        SharedPreferences.Editor myEdit = sharedPreferences.edit();

        MultipartBody.Part imagePartPhoto_book = null;

        try {
            String name = getFileName(uriPhoto);

            final RequestBody requestBody1 = RequestBody.create(MediaType.parse("application/pdf"), getBytes(uriPhoto));
            imagePartPhoto_book = MultipartBody.Part.createFormData("image", name, requestBody1);
            btn_shimmer.showShimmer(true);
            WebService.getClient().update_product2(
                    RequestBody.create(MediaType.parse("text/plain"), sharedPreferences.getString("user_Id", "")),
                    RequestBody.create(MediaType.parse("text/plain"), product_id),
                    RequestBody.create(MediaType.parse("text/plain"), orderID.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), order_id_date.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), shippingID.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), tracking_id_date.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), mobile_noPrint.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), mobile_date.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), OTP_order_print.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), otp_date.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), image_date.getText().toString()),
                    RequestBody.create(MediaType.parse("text/plain"), courier_c_name),
                    imagePartPhoto_book

            ).enqueue(new Callback<Update_product_POJO>() {
                @Override
                public void onResponse(Call<Update_product_POJO> call, Response<Update_product_POJO> response) {
                    btn_shimmer.hideShimmer();
                    if (response.body() != null && response.body().getMessage().equals("Cart Updated successfully")) {
                        UPLOAD_FLAG = true;
                        Toast.makeText(OrderDetail.this, "Recorde Update Successfully", Toast.LENGTH_SHORT).show();
                        checkPoint7.setBackgroundResource(R.drawable.ic_group_tick);
                        image_date.setVisibility(View.VISIBLE);
                        image_date.setText(dateTime);
                        Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "Invoice Updated", Snackbar.LENGTH_LONG);
                        snackbar.show();
                        order_cc.setVisibility(View.GONE);

                    }

                }

                @Override
                public void onFailure(Call<Update_product_POJO> call, Throwable t) {
                    Toast.makeText(OrderDetail.this, t.toString(), Toast.LENGTH_SHORT).show();
                    btn_shimmer.hideShimmer();

                }
            });
        } catch (Exception e) {

            Log.d("Exception", e.getMessage());
        }


    }

    private byte[] getBytes(Uri uri) {
        try {
            InputStream inputStream = getApplicationContext().getContentResolver().openInputStream(uri);
            return readBytes(inputStream);
        } catch (Exception ex) {
            Log.d("could not get byte stream", ex.getMessage());
        }
        return null;
    }

    private byte[] readBytes(InputStream inputStream) throws IOException {
        // this dynamically extends to take the bytes you read
        ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
        // this is storage overwritten on each iteration with bytes
        int bufferSize = 1024;
        byte[] buffer = new byte[bufferSize];
        // we need to know how may bytes were read to write them to the byteBuffer
        int len = 0;
        while ((len = inputStream.read(buffer)) != -1) {
            byteBuffer.write(buffer, 0, len);
        }
        // and then we can return your byte array.
        return byteBuffer.toByteArray();
    }

    String getFileName(Uri uri) {
        String[] projection = {MediaStore.MediaColumns.DISPLAY_NAME};

        ContentResolver cr = getApplicationContext().getContentResolver();
        Cursor metaCursor = cr.query(uri, projection, null, null, null);
        String path = "";
        if (metaCursor != null) {
            try {
                if (metaCursor.moveToFirst()) {
                    path = metaCursor.getString(0);
                }
            } finally {
                metaCursor.close();
            }
        }
        return path;
    }

    public void showAlertDialogButtonClicked3(View view, Uri image2) {

        AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext(), R.style.CustomAlertDialog2);
        final View customLayout = LayoutInflater.from(view.getContext()).inflate(R.layout.image_preview, null);
        builder.setView(customLayout);
        image_preview = customLayout.findViewById(R.id.image_preview);

        image_preview.setImageURI(image2);

        AlertDialog dialog = builder.create();
        dialog.getWindow().setWindowAnimations(R.style.AnimationsDilog);

        Window window = dialog.getWindow();
        WindowManager.LayoutParams wlp = window.getAttributes();

        wlp.gravity = Gravity.CENTER;
        wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
        window.setAttributes(wlp);
        dialog.show();


    }

    private void dialog(String id, TextView txtView, String title) {
        Dialog dialog1 = new Dialog(OrderDetail.this);
        dialog1.requestWindowFeature(dialog1.getWindow().FEATURE_NO_TITLE);
        dialog1.setContentView(R.layout.id_update_popup);

        TextView id_update_btn = dialog1.findViewById(R.id.id_update_btn);
        TextView id_update_text = dialog1.findViewById(R.id.id_update_text);
        TextView textView4 = dialog1.findViewById(R.id.textView4);
        EditText id_update_edt = dialog1.findViewById(R.id.id_update_edt);
        LinearLayout linearLayout12 = dialog1.findViewById(R.id.linearLayout12);

        id_update_text.setText("Edit " + title);
        id_update_edt.setText(id);
        textView4.setText(courier_c_name);
        if (txtView.equals(OTP_order_print)) {
            id_update_edt.setInputType(InputType.TYPE_CLASS_NUMBER);
            id_update_edt.setHint("OTP");
            id_update_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(6)});
        }
        if (txtView.equals(mobile_noPrint)) {
            id_update_edt.setInputType(InputType.TYPE_CLASS_NUMBER);
            id_update_edt.setHint("Mobile number");
            id_update_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(10)});
        }
        if (txtView.equals(shippingID)) {
            id_update_edt.setHint("enter tracking id");
            id_update_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(setEditor_length(courier_c_name))});
            linearLayout12.setVisibility(View.VISIBLE);
        }
        if (txtView.equals(orderID)) {
            id_update_edt.setHint("enter order id");

            linearLayout12.setVisibility(View.VISIBLE);
        }

        id_update_edt.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) {

                if (id_update_edt.getText().toString().contains(" ")) {
                    id_update_edt.setText(id_update_edt.getText().toString().replace(" ", ""));
                    id_update_edt.setSelection(id_update_edt.getText().toString().length());

                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
        id_update_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                if (!TextUtils.isEmpty(id_update_edt.getText().toString())) {
                    if (txtView.equals(mobile_noPrint) && id_update_edt.getText().toString().length() != 10) {
                        Toast.makeText(OrderDetail.this, "Please Enter 10 Digit Mobile Number", Toast.LENGTH_SHORT).show();
                        return;
                    }
                    if (txtView.equals(OTP_order_print) && id_update_edt.getText().toString().length() != 6) {
                        Toast.makeText(OrderDetail.this, "Please Enter 6 Digit OTP", Toast.LENGTH_SHORT).show();
                        return;
                    }
                    if (txtView.equals(shippingID) && id_update_edt.getText().toString().length() != setEditor_length(courier_c_name)) {
                        Toast.makeText(OrderDetail.this, "Please Enter valid Tacking ID", Toast.LENGTH_SHORT).show();
                        return;
                    }
                    txtView.setText(id_update_edt.getText().toString());
                    callWeb();
                    dialog1.dismiss();

                }


            }
        });
        linearLayout12.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                dialog2(true);

                dialog1.dismiss();
            }
        });

        dialog1.show();
        dialog1.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog1.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog1.getWindow().getAttributes().windowAnimations = R.style.Dailoganmiation;
        dialog1.getWindow().setGravity(Gravity.BOTTOM);

    }

    private void dialog2(boolean flag) {
        Dialog dialog1 = new Dialog(OrderDetail.this);
        dialog1.requestWindowFeature(dialog1.getWindow().FEATURE_NO_TITLE);
        dialog1.setContentView(R.layout.tracking_popup);

        ListView listView = dialog1.findViewById(R.id.listview);
        LinearLayout tracking_c_ll = dialog1.findViewById(R.id.tracking_c_ll);


        String tutorials[]
                = {"E-kart", "Delhivery",
                "Bluedart", "Fedex",
                "Indiapost", "ATS(Amazon Transport Services",
                "E-com Express", "Other"};

        ArrayAdapter<String> arr;
        arr = new ArrayAdapter<String>(
                this,
                R.layout.tracking_item,
                tutorials);
        listView.setAdapter(arr);


        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        select.setVisibility(View.GONE);

                        if (flag) {
                            courier_c_name = adapterView.getItemAtPosition(i).toString();
                            edit_tracking_id.setVisibility(View.VISIBLE);
                            dialog1.dismiss();
                            callWeb();
                            dialog(shippingID.getText().toString(), shippingID, "Tracking ID");
                        } else {
                            shippingID.setVisibility(View.GONE);
                            dialog1.dismiss();
                            Toast.makeText(OrderDetail.this, adapterView.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
                            courier_c_name = adapterView.getItemAtPosition(i).toString();
                            shippingID_courier.setText(courier_c_name);
                            shippingID_courier.setVisibility(View.VISIBLE);

                            editor_edt.setHint("88888888888888");
                            editor_title.setText("Enter Tracking ID");
                            editor_title2.setText("Select the courier service used and provide the tracking ID to track the order.");
                            editor_edt.setVisibility(View.VISIBLE);
                            editor_edt.setText("");
                            setEditor_length(courier_c_name);
                            callWeb();
                            btn_save.setText("save");
                            Snackbar snackbar = Snackbar.make(findViewById(R.id.odr_ll), "Courier Company Updated", Snackbar.LENGTH_LONG);
                            snackbar.show();
                        }
                    }
                }, 200);


            }
        });

        dialog1.show();
        dialog1.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog1.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog1.getWindow().getAttributes().windowAnimations = R.style.Dailoganmiation;
        dialog1.getWindow().setGravity(Gravity.CENTER);

    }

    private int setEditor_length(String c_name) {

        int i;
        switch (c_name) {

            case "E-kart":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(14)});
                i = 14;
                break;

            case "Delhivery":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(13)});
                i = 13;
                break;

            case "Bluedart":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(11)});
                i = 11;
                break;

            case "Fedex":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(12)});
                i = 12;
                break;

            case "Indiapost":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(13)});
                Log.d("fdfdfdfd", "fddbdbb");
                i = 13;
                break;

            case "ATS(Amazon Transport Services":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(12)});
                i = 12;
                break;

            case "E-com Express":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(10)});
                i = 10;
                break;

            case "Other":
                editor_edt.setFilters(new InputFilter[]{new InputFilter.LengthFilter(20)});
                i = 20;
                break;

            default:
                i = 100;

        }


        return i;


    }

    public void dialog_order() {
        Dialog dialog1 = new Dialog(OrderDetail.this);
        dialog1.requestWindowFeature(dialog1.getWindow().FEATURE_NO_TITLE);
        dialog1.setContentView(R.layout.dialog_order_place_successfully);

        TextView text = dialog1.findViewById(R.id.text);
        text.setText(Html.fromHtml("<font color='#141414'>Order </font><font color='#00A354'>Successfully\nplaced!</font>"));

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                dialog1.dismiss();
            }
        }, 3000);


        dialog1.show();
        dialog1.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        dialog1.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog1.getWindow().getAttributes().windowAnimations = R.style.Dailoganmiation;
        dialog1.getWindow().setGravity(android.view.Gravity.CENTER);

    }

    private void dialog() {
        Dialog dialog1 = new Dialog(OrderDetail.this);
        dialog1.requestWindowFeature(dialog1.getWindow().FEATURE_NO_TITLE);
        dialog1.setContentView(R.layout.upload_chooser);

        SharedPreferences sharedPreferences = this.getSharedPreferences("MySharedPref", Context.MODE_PRIVATE);
        SharedPreferences.Editor myEdit = sharedPreferences.edit();

        LinearLayout ll_images = dialog1.findViewById(R.id.ll_images);
        LinearLayout ll_pdf = dialog1.findViewById(R.id.ll_pdf);

        ll_images.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (ContextCompat.checkSelfPermission(OrderDetail.this, WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

                    if (sharedPreferences.getInt(Constants.WRITE_EXTERNAL_STORAGE, 0) == 1) {

                        alert_dialog();
                    } else {

                        myEdit.putInt(Constants.WRITE_EXTERNAL_STORAGE, 1);
                        myEdit.apply();
                        ActivityCompat.requestPermissions(OrderDetail.this, new String[]{WRITE_EXTERNAL_STORAGE}, 101);
                    }


                } else {
                    dialog1.dismiss();
                    Intent gal = new Intent(Intent.ACTION_PICK);
                    gal.setType("image/*");
                    startActivityForResult(gal, 2);
                }
            }
        });
        ll_pdf.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (ContextCompat.checkSelfPermission(OrderDetail.this, WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {

                    if (sharedPreferences.getInt(Constants.WRITE_EXTERNAL_STORAGE, 0) == 1) {

                        alert_dialog();
                    } else {

                        myEdit.putInt(Constants.WRITE_EXTERNAL_STORAGE, 1);
                        myEdit.apply();
                        ActivityCompat.requestPermissions(OrderDetail.this, new String[]{WRITE_EXTERNAL_STORAGE}, 101);
                    }


                } else {
                    dialog1.dismiss();
                    Intent gal = new Intent(Intent.ACTION_GET_CONTENT);
                    gal.setType("application/pdf");
                    startActivityForResult(gal, 2);

                }
//                Toast.makeText(OrderDetail.this, "Not available right now", Toast.LENGTH_SHORT).show();
            }
        });

        dialog1.show();
        dialog1.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog1.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog1.getWindow().getAttributes().windowAnimations = R.style.Dailoganmiation;
        dialog1.getWindow().setGravity(Gravity.BOTTOM);

    }

    public void alert_dialog() {
        androidx.appcompat.app.AlertDialog.Builder builder = new androidx.appcompat.app.AlertDialog.Builder(OrderDetail.this);

        // Set Alert Title
        builder.setTitle("Permission required");

        // Set the message show for the Alert time
        builder.setMessage("To share file we need permission of file storage");

        // Set Cancelable false for when the user clicks on the outside the Dialog Box then it will remain show
        builder.setCancelable(false);

        // Set the positive button with yes name Lambda OnClickListener method is use of DialogInterface interface.
        builder.setPositiveButton("Give access", (DialogInterface.OnClickListener) (dialog, which) -> {
            // When the user click yes button then app will close

            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            Uri uri = Uri.fromParts("package", this.getPackageName(), null);
            intent.setData(uri);
            startActivityForResult(intent, 10);
            dialog.cancel();
        });

        // Set the Negative button with No name Lambda OnClickListener method is use of DialogInterface interface.
        builder.setNegativeButton("Denied", (DialogInterface.OnClickListener) (dialog, which) -> {
            // If user click no then dialog box is canceled.
            dialog.cancel();
        });

        // Create the Alert dialog
        androidx.appcompat.app.AlertDialog alertDialog = builder.create();
        // Show the Alert Dialog box
        alertDialog.show();

    }


    @Override
    public void PickiTonUriReturned() {

    }

    @Override
    public void PickiTonStartListener() {

    }

    @Override
    public void PickiTonProgressUpdate(int progress) {

    }

    @Override
    public void PickiTonCompleteListener(String path, boolean wasDriveFile, boolean wasUnknownProvider, boolean wasSuccessful, String Reason) {
        waypathPhoto_book = path;


    }

    public void cancel_dialog() {
        Dialog dialog1 = new Dialog(OrderDetail.this);
        dialog1.requestWindowFeature(dialog1.getWindow().FEATURE_NO_TITLE);
        dialog1.setContentView(R.layout.order_cancel_popup);


        dialog1.show();
        dialog1.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog1.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        dialog1.getWindow().getAttributes().windowAnimations = R.style.Dailoganmiation;
        dialog1.getWindow().setGravity(android.view.Gravity.BOTTOM);

        SharedPreferences sharedPreferences = getSharedPreferences("MySharedPref", Context.MODE_PRIVATE);

        TextView cancel_kyc = dialog1.findViewById(R.id.cancel_kyc);
        TextView conConfirm = dialog1.findViewById(R.id.conConfirm);
        TextView textView18 = dialog1.findViewById(R.id.textView18);

        textView18.setText("This detail will not be change after leave this screen");

        conConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                WebService.getClient().delete_product(cartList.getId(), cartList.getProductId(), sharedPreferences.getString("user_Id", "")).enqueue(new Callback<Delete_product_POJO>() {
                    @Override
                    public void onResponse(Call<Delete_product_POJO> call, Response<Delete_product_POJO> response) {
                        if (response.body() != null) {
                            if (response.body().getSuccess().equals("1")) {
                                Toast.makeText(OrderDetail.this, "Order Deleted Successfully", Toast.LENGTH_SHORT).show();
                                onBackPressed();
                            }
                        }
                    }

                    @Override
                    public void onFailure(Call<Delete_product_POJO> call, Throwable t) {

                    }
                });
                dialog1.dismiss();
            }
        });

        cancel_kyc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog1.dismiss();

            }
        });

    }

}