Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ProgressDialog在android活动中保持打开状态_Android_Android Asynctask_Progressdialog - Fatal编程技术网

ProgressDialog在android活动中保持打开状态

ProgressDialog在android活动中保持打开状态,android,android-asynctask,progressdialog,Android,Android Asynctask,Progressdialog,我做了一个活动,我正在使用AsyncTak进行api调用,我在DoBackground方法中显示了一个progressDialog,并希望在postExecute中取消该progressDialog。我这样做了,但它不起作用,我的progressDialog仍然存在,在操作后也打开。我的代码如下,有人能帮我解除它吗 main.java package com.epe.yehki.ui; import java.util.ArrayList; import java.util.HashMa

我做了一个活动,我正在使用AsyncTak进行api调用,我在DoBackground方法中显示了一个progressDialog,并希望在postExecute中取消该progressDialog。我这样做了,但它不起作用,我的progressDialog仍然存在,在操作后也打开。我的代码如下,有人能帮我解除它吗

main.java

   package com.epe.yehki.ui;

import java.util.ArrayList;
import java.util.HashMap;

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

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Paint.Join;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewDebug.FlagToString;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.epe.yehki.backend.BackendAPIService;
import com.epe.yehki.backend.FavoriteAPI;
import com.epe.yehki.backend.ResponseListener;
import com.epe.yehki.uc.Menu;
import com.epe.yehki.util.Const;
import com.epe.yehki.util.Const.API_RESULT;
import com.epe.yehki.util.Pref;
import com.epe.yehki.util.Utils;
import com.example.yehki.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

public class WholesaleProductDetailActivity extends Activity {
    public ImageView productImage;
    private ImageLoader imageLoader;
    private DisplayImageOptions options;
    private ProgressDialog pDialog;
    JSONArray proDetails = null;
    private Menu menu;
    Intent i1;
    private FavoriteAPI favApi;
    private int isFavourite;
    private ProgressDialog progressDialog;

    // CONTROLLS FOR WHOLESALE RETAILS.........!!!

    TextView retailPrice;
    TextView tv_moqW;
    TextView tv_moqR;
    TextView tv_shipping_cost;
    TextView EscrowPayment;
    TextView ProcessigPeriod;
    LinearLayout llQuantity;
    EditText quantity;
    LinearLayout llbotm;
    TextView tv_escrow_payment;
    TextView tv_procesiing_period;
    Button contactSuplier, addToCart, buyNOw;
    LinearLayout ll_botom1;

    // ************************

    // strings.......!!!
    String pro_id;
    String name;
    String retail_price;
    String price_wholesale;
    String keywords;
    String supplier_id;
    String supplier_name;
    String listing_description;
    String image;
    String Specifications;
    String date_added;
    String status;
    int flag = 0;
    String port;
    String customer_name;
    String customer_id;
    String cId;
    String min_order_qty_retail;
    String min_order_qty_wholesale;
    String countyId;
    String supply_amount;
    String msg;
    String supply_unit_id;
    String supply_unit_name;
    String supply_time;
    String payment_terms;
    String min_order_qty;
    String min_order_qty_unit;
    String min_order_qty_unit_name;
    String delivery_time;
    String company_name;
    String country_id;
    String state_id;
    String procesPeriod;

    // COMPANY DETAILS....
    String companyDetail;
    String companyDetailName;
    String companyDetailAddress;
    String companyDetailPhoto;
    String companyDetailMainProduct;
    String companyDetailotherProduct;
    String cartNo;

    // PRODUCT QUICK DETAILS...

    // TextViews.............!!!
    public TextView productName;
    public TextView wholeSalePrice;
    public TextView minOrder;
    public TextView shippingCost;
    public TextView escrowPayment;
    public TextView processingPeriod;
    public TextView compnyName;
    public TextView countryName;
    public TextView bussinessType;
    public TextView mainProduct;
    public TextView productDetails;
    public String pid;

    // Buttons of placeOrder and contact supplier..

    private Button contactSupplier;

    private ImageView iv_back;
    private TextView cart;
    private ImageView iv_fav;
    public Intent i;

    //

    // Hashmap for ListView
    ArrayList<HashMap<String, String>> ProductDetailList;

    // URL to get contacts JSON
    // API_PRODUCT?product_id=29
    private static String productUrl;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_product_detail);
        initializeViews();
        cId = Pref.getValue(WholesaleProductDetailActivity.this, Const.PREF_CUSTOMER_ID, "");
        ll_botom1 = (LinearLayout) findViewById(R.id.ll_botom1);
        ll_botom1.setVisibility(View.VISIBLE);
        imageLoader = ImageLoader.getInstance();
        imageLoader.init(ImageLoaderConfiguration.createDefault(WholesaleProductDetailActivity.this));

        options = new DisplayImageOptions.Builder().cacheOnDisc(true).showImageOnFail(R.drawable.logo).build();
        new AddToCart().execute();

        // get extras..............!!!!
        i = getIntent();

        i.getStringExtra(Const.TAG_PRODUCT_NAME);
        i.getStringExtra(Const.TAG_PRODUCT_IMG);
        pid = i.getStringExtra(Const.TAG_PRODUCT_ID);

        favApi = new FavoriteAPI(WholesaleProductDetailActivity.this, responseListener, pid, Pref.getValue(WholesaleProductDetailActivity.this, Const.PREF_CUSTOMER_ID, ""));
        favApi.callApi();

        // bACK BUTTON.......!
        iv_back.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                finish();
            }
        });

        // DO FAVOURITE YOUR PRODUCT..........!!!
        iv_fav.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {

                // CHECKING IS USER lOGIN...!
                if (Pref.getValue(WholesaleProductDetailActivity.this, Const.PREF_CUSTOMER_ID, "") != null
                        && !Pref.getValue(WholesaleProductDetailActivity.this, Const.PREF_CUSTOMER_ID, "").equals("")) {
                    // FAVOURITE API CALL..........!!!

                    if (iv_fav.isSelected()) {
                        isFavourite = 0;
                        iv_fav.setImageResource(R.drawable.star);
                        iv_fav.setSelected(false);

                    } else {
                        isFavourite = 1;
                        iv_fav.setImageResource(R.drawable.star_filled);
                        iv_fav.setSelected(true);
                    }
                    if (Utils.isOnline(WholesaleProductDetailActivity.this)) {

                        progressDialog = new ProgressDialog(WholesaleProductDetailActivity.this);
                        progressDialog.setMessage(getString(R.string.process_progress_msg));
                        progressDialog.setIndeterminate(true);
                        progressDialog.setCancelable(false);
                        progressDialog.show();

                        favApi = new FavoriteAPI(WholesaleProductDetailActivity.this, responseListener, pid, Pref.getValue(WholesaleProductDetailActivity.this, Const.PREF_CUSTOMER_ID, ""));
                        favApi.callApi();

                    } else {
                        Toast.makeText(WholesaleProductDetailActivity.this, "Please check your interenet connection", Toast.LENGTH_SHORT).show();
                    }

                } else {
                    i = new Intent(WholesaleProductDetailActivity.this, LoginActivity.class);
                    startActivity(i);
                }

            }
        });

        productUrl = Const.API_WHOLESALE_PRODUCT_DETAIL + "?" + Const.TAG_PRODUCT_ID + "=" + pid;
        System.out.println(":::::::::::PRODUCT URL:::::::::::::::" + productUrl);
        productName.setText(i.getStringExtra(Const.TAG_PRODUCT_NAME));
        try {
            imageLoader.displayImage(i.getStringExtra(Const.TAG_PRODUCT_IMG), productImage, options);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            productImage.setBackgroundResource(R.drawable.logo);
        }
        new GetProductDetails().execute();
        buyNOw.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                if (quantity.getText().toString() != null && !quantity.getText().toString().equals("")) {

                    if (Double.parseDouble(quantity.getText().toString()) < (Double.parseDouble(min_order_qty_retail))) {
                        Utils.showCustomeAlertValidation(WholesaleProductDetailActivity.this, "Please Enter Quantity greater than min. retail quamtity", "Yehki", "Ok");
                    } else {

                        i1 = new Intent(WholesaleProductDetailActivity.this, WholesalePlaceOrderActivity.class);

                        i1.putExtra(Const.TAG_PRODUCT_NAME, name);
                        i1.putExtra(Const.TAG_PRODUCT_ID, pid);
                        i1.putExtra("QTY_RETAIL", min_order_qty_retail);
                        i1.putExtra("QTY_WHOLESALE", min_order_qty_wholesale);
                        i1.putExtra(Const.TAG_PRODUCT_SUPPLEY_UNIT_ID, supply_unit_id);
                        i1.putExtra(Const.TAG_PRODUCT_SUPPLY_UNIT_NAME, supply_unit_name);
                        i1.putExtra(Const.TAG_PRODUCT_MAX_PRICE, price_wholesale);
                        i1.putExtra(Const.TAG_PRODUCT_MIN_PRICE, retail_price);
                        i1.putExtra("takenQTY", quantity.getText().toString());

                        if (Double.parseDouble(quantity.getText().toString()) > (Double.parseDouble(min_order_qty_retail))
                                && Double.parseDouble(quantity.getText().toString()) < (Double.parseDouble(min_order_qty_wholesale))) {
                            i1.putExtra("price", retail_price);
                            startActivity(i1);
                        } else if (Double.parseDouble(quantity.getText().toString()) > (Double.parseDouble(min_order_qty_wholesale))) {
                            i1.putExtra("price", price_wholesale);
                            startActivity(i1);
                        }

                    }

                } else {
                    Utils.showCustomeAlertValidation(WholesaleProductDetailActivity.this, "Please Enter Quantity", "Yehki", "Ok");
                }

            }
        });
        contactSuplier.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                i = new Intent(WholesaleProductDetailActivity.this, ContactSupplierActivity.class);
                i.putExtra(Const.TAG_SUPPLIER_ID, supplier_id);
                System.out.println("::::::::::::::::;my supplier id>>>>>>>>>>>>>>+++++++++++++++++" + supplier_id);
                i.putExtra(Const.TAG_PRODUCT_ID, pid);
                startActivity(i);

            }
        });
        addToCart.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (!quantity.getText().toString().equals("") && quantity.getText().toString() != null) {
                    new AddToCart().execute();
                } else {
                    Utils.showCustomeAlertValidation(WholesaleProductDetailActivity.this, "Please enter quanitity", "Yehki", "Ok");
                }
            }
        });

    }

    // ****INITIALIZING THE VIEWS.....!!!!!!!!!!!!!!!
    private void initializeViews() {
        productImage = (ImageView) findViewById(R.id.iv_product);
        productName = (TextView) findViewById(R.id.tv_product_name);
        buyNOw = (Button) findViewById(R.id.tv_place_order);
        contactSupplier = (Button) findViewById(R.id.tv_contact_suplier);
        wholeSalePrice = (TextView) findViewById(R.id.tv_price_range);
        minOrder = (TextView) findViewById(R.id.tv_min_order);
        shippingCost = (TextView) findViewById(R.id.tv_sply);
        escrowPayment = (TextView) findViewById(R.id.tv_payment_terms);
        processingPeriod = (TextView) findViewById(R.id.tv_port);
        compnyName = (TextView) findViewById(R.id.tv_company_name);
        countryName = (TextView) findViewById(R.id.tv_contry);
        bussinessType = (TextView) findViewById(R.id.tv_bussiness_type);
        mainProduct = (TextView) findViewById(R.id.tv_main_products);
        productDetails = (TextView) findViewById(R.id.tv_pro_detail);
        menu = (Menu) findViewById(R.id.menuProduct);
        iv_back = (ImageView) findViewById(R.id.iv_back);
        iv_fav = (ImageView) findViewById(R.id.iv_fvrt);
        cart = (TextView) findViewById(R.id.tv_cart);
        retailPrice = (TextView) findViewById(R.id.tv_retail_price);
        tv_moqW = (TextView) findViewById(R.id.tv_moqw);
        tv_moqR = (TextView) findViewById(R.id.tv_min_order);
        tv_shipping_cost = (TextView) findViewById(R.id.tv_shipping_cost);
        tv_escrow_payment = (TextView) findViewById(R.id.tv_escrow_payment);
        tv_procesiing_period = (TextView) findViewById(R.id.tv_procesiing_period);
        quantity = (EditText) findViewById(R.id.et_qty);
        llQuantity = (LinearLayout) findViewById(R.id.ll_btm);
        llQuantity.setVisibility(View.VISIBLE);
        llbotm = (LinearLayout) findViewById(R.id.ll_botom1);
        llbotm.setVisibility(View.VISIBLE);
        tv_shipping_cost.setText("Shipping Cost:");
        tv_escrow_payment.setText("Escrow Payment:");
        tv_procesiing_period.setText("Processing Period:");
        contactSuplier = (Button) findViewById(R.id.tv_contc_sup);
        addToCart = (Button) findViewById(R.id.btn_add_cart);
        buyNOw = (Button) findViewById(R.id.btn_buy);
        retailPrice.setVisibility(View.VISIBLE);
        menu.setSelectedTab(1);
    }

    private class GetProductDetails extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // Showing progress dialog
            pDialog = new ProgressDialog(WholesaleProductDetailActivity.this);
            pDialog.setMessage("Please wait...");
            pDialog.setCancelable(false);
            pDialog.show();
            System.out.println("==========inside preexecute===================");

        }

        @Override
        protected Void doInBackground(Void... arg0) {
            // Creating service handler class instance
            BackendAPIService sh = new BackendAPIService();

            // Making a request to url and getting response
            String jsonStr = sh.makeServiceCall(productUrl, BackendAPIService.GET);

            Log.d("Response: ", "> " + jsonStr);
            System.out.println("=============MY RESPONSE==========" + jsonStr);

            if (jsonStr != null) {
                try {
                    JSONObject jsonObj = new JSONObject(jsonStr);

                    // Getting JSON Array node
                    if (jsonObj.has(Const.TAG_PRODUCT_DETAIL)) {
                        // yes
                        proDetails = jsonObj.getJSONArray(Const.TAG_PRODUCT_DETAIL);

                        System.out.println("==========inside doIn background===================");
                        // looping through All Contacts
                        for (int i = 0; i < proDetails.length(); i++) {
                            JSONObject c = proDetails.getJSONObject(i);

                            name = c.getString(Const.TAG_PRODUCT_NAME);
                            keywords = c.getString(Const.TAG_PRODUCT_KEYWORDS);
                            supplier_id = c.getString(Const.TAG_PRODUCT_SUPPLIER_ID);
                            supplier_name = c.getString(Const.TAG_PRODUCT_SUPPLIER_NAME);
                            listing_description = c.getString(Const.TAG_PRODUCT_LISTING_DESCRIPTION);
                            image = c.getString(Const.TAG_PRODUCT_IMG);
                            Specifications = c.getString(Const.TAG_PRODUCT_SPECIFICATION);
                            date_added = c.getString(Const.TAG_PRODUCT_DATE_ADDED);

                            customer_name = c.getString(Const.TAG_PRODUCT_CUSTMER_NAME);
                            customer_id = c.getString(Const.TAG_PRODUCT_CUSTOMER_ID);

                            retail_price = c.getString(Const.TAG_PRICE_RETAIL);
                            price_wholesale = c.getString(Const.TAG_PRICE_WHOLESALE);
                            System.out.println(":::::::::::::My wholesale price:::::::::>>>>>>>" + price_wholesale);
                            min_order_qty_retail = c.getString(Const.TAG_MIN_ORDER_QTY_RETAIL);
                            System.out.println(":::::::::::::My wholesale price:::::::::>>>>>>>" + min_order_qty_retail);
                            min_order_qty_wholesale = c.getString(Const.TAG_MIN_ORDER_QTY_WHOLESALE);
                            System.out.println(":::::::::::::My wholesale price:::::::::>>>>>>>" + min_order_qty_wholesale);
                            countyId = c.getString(Const.TAG_COUNTRY_ID);
                            state_id = c.getString(Const.TAG_STATE_WHOLESALE_ID);

                            supply_unit_id = c.getString(Const.TAG_PRODUCT_SUPPLEY_UNIT_ID);
                            supply_unit_name = c.getString(Const.TAG_PRODUCT_SUPPLY_UNIT_NAME);
                            System.out.println("::::::::::::::::mY supply unit name::::::::::::::");
                            supply_time = c.getString(Const.TAG_PRODUCT_SUPPLY_TIME);
                            delivery_time = c.getString(Const.TAG_DELIVERY_TIME_WHOLESALE);

                            System.out.println(":::::::::::::::supply unit name:::::::::::::::::::" + delivery_time);

                            company_name = c.getString(Const.TAG_PRODUCT_COMPANY_NAME);
                            System.out.println(":::::::::::::::supply unit name:::::::::::::::::::" + company_name);

                            // GETTING COMPANY DETAILS..........!!!
                            JSONObject companyDetails = c.getJSONObject(Const.TAG_PRODUCT_COMPANY_DETAILS);
                            companyDetailName = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_NAME);
                            companyDetailAddress = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_ADDRESS);
                            companyDetailMainProduct = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_MAIN_PRODUCT);
                            companyDetailotherProduct = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_OTHER_PRODUCT);
                            companyDetailPhoto = companyDetails.getString(Const.TAG_PRODUCTDETAIL_PHOTO);
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                Log.e("ServiceHandler", "Couldn't get any data from the url");
            }

            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            // Dismiss the progress dialog
            if (pDialog != null) {
                pDialog.dismiss();
            }
            productName.setText(name);
            wholeSalePrice.setText("WholeSale Price:" + " " + price_wholesale);
            retailPrice.setText("Retail Price:" + " " + retail_price);
            tv_moqW.setText("MoqW:" + min_order_qty_wholesale);
            minOrder.setText("MoqR:" + min_order_qty_retail);
            shippingCost.setText("");
            escrowPayment.setText(payment_terms);
            compnyName.setText(company_name);
            countryName.setText(country_id);
            mainProduct.setText(companyDetailMainProduct);
            processingPeriod.setText(delivery_time);
        }
    }

    // RESPONSE lISTENER FOR THE FAVOURITE......!!
    ResponseListener responseListener = new ResponseListener() {

        @Override
        public void onResponce(String api, API_RESULT result, Object obj) {

            if (progressDialog != null) {
                progressDialog.dismiss();
            }
            if (api.equals(Const.API_DO_FAVOURITE)) {
                if (result == Const.API_RESULT.SUCCESS) {
                    System.out.println("::::::::::::::::;INSIDE SUCCESS ACTIVITY OF FAVORITE:::::::::;");
                }
            }

        }
    };

    // *********************ADD TO CART CALL...

    // *******************

    private class AddToCart extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // Showing progress dialog
            pDialog = new ProgressDialog(WholesaleProductDetailActivity.this);
            pDialog.setMessage("Please wait...");
            pDialog.setCancelable(false);
            pDialog.show();
            System.out.println("==========inside preexecute===================");

        }

        @Override
        protected Void doInBackground(Void... arg0) {
            String addToCArt = Const.API_ADD_TO_CART + "?customer_id=" + cId + "&product_id=" + pid + "&quantity=" + quantity.getText().toString() + "&unit_id=" + supply_unit_id; // Creating
                                                                                                                                                                                    // service
            // handler
            // class
            // instance
            BackendAPIService sh = new BackendAPIService();
            System.out.println(":::::::::::::MY add to cart url:::::::::::;" + addToCArt);
            // Making a request to url and getting response
            String jsonStr = sh.makeServiceCall(addToCArt, BackendAPIService.GET);

            Log.d("Response: ", "> " + jsonStr);
            System.out.println("=============MY RESPONSE==========" + jsonStr);

            if (jsonStr != null) {
                try {
                    JSONObject jsonObj = new JSONObject(jsonStr);

                    if (jsonObj.has(Const.TAG_STATUS)) {
                        status = jsonObj.getString(Const.TAG_STATUS);

                        if (status.equalsIgnoreCase("success")) {
                            flag = 1;
                            msg = jsonObj.getString(Const.TAG_MESSAGE);
                            cartNo = jsonObj.getString(Const.TAG_TOTAL_CART_PRODUCTS);
                        } else {
                            flag = 2;
                            msg = jsonObj.getString(Const.TAG_MESSAGE);
                        }

                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                Log.e("ServiceHandler", "Couldn't get any data from the url");
            }

            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            // Dismiss the progress dialog
            if (pDialog != null) {
                pDialog.dismiss();
            }
            if (flag == 1) {
                Toast.makeText(WholesaleProductDetailActivity.this, msg, Toast.LENGTH_SHORT).show();
                quantity.setText("");
                cart.setText(cartNo);
                Pref.setValue(WholesaleProductDetailActivity.this, Const.PREF_CART_NO, cartNo);
            } else {
                Toast.makeText(WholesaleProductDetailActivity.this, msg, Toast.LENGTH_SHORT).show();
            }

        }
    }

}
package com.epe.yehki.ui;
导入java.util.ArrayList;
导入java.util.HashMap;
导入org.json.JSONArray;
导入org.json.JSONException;
导入org.json.JSONObject;
导入android.app.Activity;
导入android.app.ProgressDialog;
导入android.content.Intent;
导入android.graphics.Paint.Join;
导入android.os.AsyncTask;
导入android.os.Bundle;
导入android.os.Message;
导入android.util.Log;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.view.ViewDebug.FlagToString;
导入android.widget.Button;
导入android.widget.EditText;
导入android.widget.ImageView;
导入android.widget.LinearLayout;
导入android.widget.TextView;
导入android.widget.Toast;
导入com.epe.yehki.backend.BackendAPIService;
导入com.epe.yehki.backend.FavoriteAPI;
导入com.epe.yehki.backend.ResponseListener;
导入com.epe.yehki.uc.Menu;
导入com.epe.yehki.util.Const;
导入com.epe.yehki.util.Const.API_结果;
导入com.epe.yehki.util.Pref;
导入com.epe.yehki.util.Utils;
导入com.example.yehki.R;
导入com.nostra13.universalimageloader.core.DisplayImageOptions;
导入com.nostra13.universalimageloader.core.ImageLoader;
导入com.nostra13.universialimageloader.core.imageloader配置;
公共类批发商ProductDetailActivity扩展活动{
公众形象;产品形象;
私有图像加载器;
私有显示图像选项;
私人对话;
JSONArray proDetails=null;
私人菜单;
意图i1;
私人收藏;
私家侦探是我的最爱;
私有进程对话;
//批发零售控制。。。。。。。。。!!!
TextView零售价格;
TextView电视;
TextView tv_moqR;
TextView tv\u运输成本;
TextView托管支付;
文本视图处理周期;
线性布局和数量;
编辑文本数量;
线性布局llbotm;
TextView电视托管支付;
TextView电视节目处理时段;
按钮联系人供应商,addToCart,buyNOw;
线性布局图1;
// ************************
//字符串。。。。。。。!!!
字符串pro_id;
字符串名;
字符串零售价格;
串价批发;
字符串关键字;
字符串供应商id;
字符串供应商名称;
字符串列表描述;
字符串图像;
串规格;
添加字符串日期;
字符串状态;
int标志=0;
字符串端口;
字符串客户名称;
字符串customer\u id;
字符串cId;
字符串最小订单数量零售;
字符串最小订单数量批发;
字符串countyId;
字符串供应量;
串味精;
字符串供应单元id;
字符串供应单位名称;
串供电时间;
字符串付款条件;
字符串最小订单数量;
字符串最小订单数量单位;
字符串最小订单数量单位名称;
字符串传递时间;
字符串公司名称;
字符串国家/地区id;
字符串状态标识;
弦前隔;
//公司详情。。。。
串尾;
字符串companyDetailName;
字符串companyDetailAddress;
弦乐伴奏;
字符串公司的主要产品;
字符串公司开发其他产品;
字符串cartNo;
//产品快速详细信息。。。
//文本视图。。。。。。。。。。。。。!!!
公共文本视图产品名称;
公共文本查看批发商价格;
公共文本视图minOrder;
公共文本视图发货成本;
公共文本视图托管支付;
公共文本视图处理周期;
公共文本视图compnyName;
公共文本视图国家名称;
公共文本视图业务类型;
公共文本视图主产品;
公共文本视图产品详细信息;
公共字符串pid;
//placeOrder和contact supplier按钮。。
私人按钮供应商;
私人影像视图iv_back;
私用文本浏览车;
私人ImageView iv_fav;
公众意向一;
//
//ListView的Hashmap
ArrayList ProductDetailList;
//获取联系人JSON的URL
//API_产品?产品id=29
私有静态字符串productUrl;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u product\u detail);
初始化视图();
cId=Pref.getValue(批发商ProductDetailActivity.this,Const.Pref\u CUSTOMER\u ID,“”);
ll_botom1=(线性布局)findViewById(R.id.ll_botom1);
ll_botom1.setVisibility(View.VISIBLE);
imageLoader=imageLoader.getInstance();
init(ImageLoaderConfiguration.createDefault(批发商ProductDetailActivity.this));
options=newdisplayImageOptions.Builder().cacheOnDisc(true).showImageOnFail(R.drawable.logo).build();
新建AddToCart().execute();
//获取额外信息。。。。。。。。。。。。。。!!!!
i=getIntent();
i、 getStringExtra(常量标签\产品\名称);
i、 getStringExtra(Const.TAG\u PRODUCT\u IMG);
pid=i.getStringExtra(常数标签\产品\ ID);
favApi=新的FavoriteAPI(批发商ProductDetailActivity.this,responseListener,pid,Pref.getValue(批发商ProductDetailActivity.this,Const.Pref\u CUSTOMER\u ID,”);
favApi.callApi();
//后退按钮。。。。。。。!
iv_back.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图arg0){
完成();
}
});
//你喜欢你的产品吗。。。。。。。。。。!!!
iv_fav.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图arg0){
//正在检查用户登录
 if (pDialog.isShowing())
use  if (pDialog != null)
   // My AsyncTask start...
class GetProductDetails extends AsyncTask<Void, Void, Void> {
    private ProgressDialog pDialog;
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(WholesaleProductDetailActivity.this);
        pDialog.setMessage("Please wait...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }

    @Override
    protected Void doInBackground(Void... arg0) {
         // Creating service handler class instance
        BackendAPIService sh = new BackendAPIService();
        // Making a request to url and getting response
        String jsonStr = sh.makeServiceCall(productUrl, BackendAPIService.GET);
        Log.d("Response: ", "> " + jsonStr);
        System.out.println("=============MY RESPONSE==========" + jsonStr);
        if (jsonStr != null) {
            try {
                JSONObject jsonObj = new JSONObject(jsonStr);
                // Getting JSON Array node
                if (jsonObj.has(Const.TAG_PRODUCT_DETAIL)) {
                    // yes
                    proDetails = jsonObj.getJSONArray(Const.TAG_PRODUCT_DETAIL);
                    System.out.println("==========inside doIn background===================");
                    // looping through All Contacts
                    for (int i = 0; i < proDetails.length(); i++) {
                        JSONObject c = proDetails.getJSONObject(i);
                        name = c.getString(Const.TAG_PRODUCT_NAME);
                        keywords = c.getString(Const.TAG_PRODUCT_KEYWORDS);
                        supplier_id = c.getString(Const.TAG_PRODUCT_SUPPLIER_ID);
                        supplier_name = c.getString(Const.TAG_PRODUCT_SUPPLIER_NAME);
                        listing_description = c.getString(Const.TAG_PRODUCT_LISTING_DESCRIPTION);
                        image = c.getString(Const.TAG_PRODUCT_IMG);
                        Specifications = c.getString(Const.TAG_PRODUCT_SPECIFICATION);
                        date_added = c.getString(Const.TAG_PRODUCT_DATE_ADDED);
                        customer_name = c.getString(Const.TAG_PRODUCT_CUSTMER_NAME);
                        customer_id = c.getString(Const.TAG_PRODUCT_CUSTOMER_ID);
                        retail_price = c.getString(Const.TAG_PRICE_RETAIL);
                        price_wholesale = c.getString(Const.TAG_PRICE_WHOLESALE);
                        System.out.println(":::::::::::::My wholesale price:::::::::>>>>>>>" + price_wholesale);
                        min_order_qty_retail = c.getString(Const.TAG_MIN_ORDER_QTY_RETAIL);
                        System.out.println(":::::::::::::My wholesale price:::::::::>>>>>>>" + min_order_qty_retail);
                        min_order_qty_wholesale = c.getString(Const.TAG_MIN_ORDER_QTY_WHOLESALE);
                        System.out.println(":::::::::::::My wholesale price:::::::::>>>>>>>" + min_order_qty_wholesale);
                        countyId = c.getString(Const.TAG_COUNTRY_ID);
                        state_id = c.getString(Const.TAG_STATE_WHOLESALE_ID);

                        supply_unit_id = c.getString(Const.TAG_PRODUCT_SUPPLEY_UNIT_ID);
                        supply_unit_name = c.getString(Const.TAG_PRODUCT_SUPPLY_UNIT_NAME);
                        System.out.println("::::::::::::::::mY supply unit name::::::::::::::");
                        supply_time = c.getString(Const.TAG_PRODUCT_SUPPLY_TIME);
                        delivery_time = c.getString(Const.TAG_DELIVERY_TIME_WHOLESALE);
                        System.out.println(":::::::::::::::supply unit name:::::::::::::::::::" + delivery_time);
                        company_name = c.getString(Const.TAG_PRODUCT_COMPANY_NAME);
                        System.out.println(":::::::::::::::supply unit name:::::::::::::::::::" + company_name);
                        // GETTING COMPANY DETAILS..........!!!
                        JSONObject companyDetails = c.getJSONObject(Const.TAG_PRODUCT_COMPANY_DETAILS);
                        companyDetailName = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_NAME);
                        companyDetailAddress = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_ADDRESS);
                        companyDetailMainProduct = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_MAIN_PRODUCT);
                        companyDetailotherProduct = companyDetails.getString(Const.TAG_PRODUCTDETAIL_COMPANY_OTHER_PRODUCT);
                        companyDetailPhoto = companyDetails.getString(Const.TAG_PRODUCTDETAIL_PHOTO);
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        } else {
            Log.e("ServiceHandler", "Couldn't get any data from the url");
        }
        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        super.onPostExecute(result);

        productName.setText(name);
        wholeSalePrice.setText("WholeSale Price:" + " " + price_wholesale);
        retailPrice.setText("Retail Price:" + " " + retail_price);
        tv_moqW.setText("MoqW:" + min_order_qty_wholesale);
        minOrder.setText("MoqR:" + min_order_qty_retail);
        shippingCost.setText("");
        escrowPayment.setText(payment_terms);
        compnyName.setText(company_name);
        countryName.setText(country_id);
        mainProduct.setText(companyDetailMainProduct);
        processingPeriod.setText(delivery_time);

        // Dismiss the progress dialog
        pDialog.dismiss();

    }
}
}
  @Override
  protected void onPostExecute(Void result) {
       super.onPostExecute(result);
            // Your code
  }
@SuppressWarnings({"UnusedDeclaration"})
protected void onPostExecute(Result result) {

}