package com.danding.yang800.Fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;

import com.danding.yang800.Adapter.MarketShopAdapter;
import com.danding.yang800.MaketShopInfoActivity;
import com.danding.yang800.MarketActivity;
import com.danding.yang800.Presenter.MarketShopFragPresenter;
import com.danding.yang800.R;
import com.danding.yang800.View.XListView;
/**
 * 店铺自定义优惠券，一开始打算做目前没用
 * */
@SuppressLint({"ValidFragment", "NewApi"})
public class MarketShopFrag extends MyBaseFragment implements XListView.IXListViewListener {
    private MarketActivity context;
    XListView shop_frag_list;
    MarketShopAdapter adapter;
    MarketShopFragPresenter presenter;

    public MarketShopFrag(MarketActivity context) {
        this.context = context;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.shop_frag, container, false);
    }


    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        initData();
        super.onActivityCreated(savedInstanceState);
    }

    private void initData() {
        shop_frag_list = (XListView) getView().findViewById(R.id.shop_frag_list);
        shop_frag_list.setPullRefreshEnable(false);
        shop_frag_list.setPullLoadEnable(true);
        shop_frag_list.setAutoLoadEnable(true);
        shop_frag_list.setXListViewListener(this);
        shop_frag_list.setOnItemClickListener(listener);
//        adapter = new MarketShopAdapter(context);
//        adapter.addData(new MarketInfo("", 0, 0, 0, 0));
//        adapter.addData(new MarketInfo("", 0, 0, 0, 1));
//        adapter.addData(new MarketInfo("", 0, 0, 0, 1));
//        adapter.addData(new MarketInfo("", 0, 0, 0, 0));
//        adapter.addData(new MarketInfo("", 0, 0, 0, 2));
//        adapter.addData(new MarketInfo("", 0, 0, 0, 2));
//        adapter.addData(new MarketInfo("", 0, 0, 0, 0));
//        shop_frag_list.setAdapter(adapter);
//        presenter = new MarketShopFragPresenter(this);

    }

    android.widget.AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                                long id) {
            Intent intent = new Intent(getActivity(), MaketShopInfoActivity.class);
            getActivity().startActivity(intent);
        }
    };

    @Override
    public void onRefresh() {

    }

    @Override
    public void onLoadMore() {

    }
}
