package com.danding.yang800.Presenter;

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

import com.danding.yang800.General.HttpCallBack;
import com.danding.yang800.SetActivity;
import com.danding.yang800.TakeOutActivity;
import com.danding.yang800.Util.VolleyUtil;

import org.json.JSONObject;

import java.util.HashMap;

/**
 * Created by Administrator on 2017/1/12.
 */
public class TakeOutActivityPresenter {
    private TakeOutActivity context;
    SharedPreferences sp;

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


    public void getInfo(final String userId) {
        HashMap<String, String> map = new HashMap<>();
        map.put("userId", userId);
//        new VolleyUtil(context).request(context, "http://" + BuildConfig.HOSTURL + "/xhr/user/setting/toUpdateUserInfo",true, map, new HttpCallBack() {
        new VolleyUtil(context).request(context, "user.setting.toUpdateUserInfo", true, map, new HttpCallBack() {
            @Override
            public void onSuccess(JSONObject json) {
                try {
                    JSONObject jsonObject = json.getJSONObject("result");
                    boolean realNameSet = false;
                    String realname = "";
                    try {
                        realNameSet = jsonObject.getBoolean("realNameSet");
                        realname = jsonObject.getString("realname");
                    } catch (Exception e) {

                    }

                    context.initData(realNameSet,realname);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }


            @Override
            public void onerrSuccess() {

            }

            @Override
            public void onCatch() {

            }

            @Override
            public void onFail() {

            }
        });
    }




}
