package com.usai.redant.CommonEditor.CommonEditor;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;


import com.usai.redant.CommonEditor.BundleModelActivity;
import com.usai.redant.redantmobile.R;

import org.json.JSONObject;

/**
 * Created by macmini1 on 2017/8/16.
 */

public class CommonEditorModelCellHolder extends CommonEditorCellHolder {

    public ImageButton model_img_btn;
    public TextView desc_lb;
    public TextView master_pack_lb;
    public TextView old_price_lb;
    public TextView discount_lb;
    public TextView unit_price_lb;
    public TextView count_lb;
    public TextView bundle_btn;
    public TextView total_price_lb;

    public JSONObject bundle_item;

    public CommonEditorModelCellHolder(Context context, View view) {
        super(context, view);
        model_img_btn = (ImageButton) view.findViewById(R.id.model_img_view);
        desc_lb = (TextView) view.findViewById(R.id.model_desc_lb);
        master_pack_lb = (TextView) view.findViewById(R.id.model_master_pack_lb);
        old_price_lb = (TextView) view.findViewById(R.id.model_old_price_lb);
        discount_lb = (TextView) view.findViewById(R.id.model_discount_lb);
        unit_price_lb = (TextView) view.findViewById(R.id.model_unit_price_lb);
        count_lb = (TextView) view.findViewById(R.id.model_count_lb);
        bundle_btn = (TextView) view.findViewById(R.id.model_bundle_btn);
        total_price_lb = (TextView) view.findViewById(R.id.model_total_price_lb);

        bundle_btn.setOnClickListener(bundleClickListener);

    }

    @Override
    public void setItem(JSONObject item_json, boolean readonly, View view) {
        super.setItem(item_json, readonly, view);
    }

    private View.OnClickListener bundleClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (bundle_item != null) {
                Intent intent = new Intent(mCtx,BundleModelActivity.class);
                intent.putExtra("bundle_items",bundle_item.toString());
                ((Activity)mCtx).startActivity(intent);

//                BundleItemDialog dialog = new BundleItemDialog.Builder().build(mCtx);
//                dialog.setItems(bundle_item.toString());
//                dialog.show();
            }
        }
    };
}
