package com.danding.yang800.Presenter;

import android.content.Context;
import android.content.SharedPreferences;

import com.danding.yang800.Adapter.TicketNotUseAdapter;
import com.danding.yang800.Entity.TicketNotUseInfo;
import com.danding.yang800.Fragment.MyTicketNotUseFrag;
import com.danding.yang800.General.HttpCallBack;
import com.danding.yang800.MyTicketActivity;
import com.danding.yang800.Util.VolleyUtil;
import com.danding.yang800.Vo.MyTicketVO;
import com.danding.yang800.Vo.NotUseTicketVO;
import com.google.gson.Gson;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.List;

public class MyTicketActivityPresenter {
    private MyTicketActivity context;
    SharedPreferences sp;

    public MyTicketActivityPresenter(MyTicketActivity context) {
        sp = context.getSharedPreferences("variable", Context.MODE_PRIVATE);
        this.context = context;
    }

    public void getInfo() {
        HashMap<String, String> map = new HashMap<>();
        new VolleyUtil(context).request(context, "coupon.countInfo", true, map, new HttpCallBack() {
            @Override
            public void onSuccess(JSONObject json) {
                try {
                    Gson gson = new Gson();
                    MyTicketVO bean = gson.fromJson(json.toString(), MyTicketVO.class);
                    MyTicketVO.ResultBean result = bean.getResult();
                    int unusedCount=result.getUnusedCount();
                    int expireCount=result.getExpireCount();
                    context.initData(unusedCount,expireCount);
                } catch (Exception e) {

                }

            }

            @Override
            public void onerrSuccess() {

            }

            @Override
            public void onCatch() {

            }

            @Override
            public void onFail() {

            }
        });
    }


}
