package com.yutou.jianr_mg.views;

import android.os.Bundle;
import android.widget.ListView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.alibaba.fastjson.JSON;
import com.yutou.jianr_mg.Adapters.MagicTeamDataAdapter;
import com.yutou.jianr_mg.Data.GameInfoLog;
import com.yutou.jianr_mg.Data.TeamData;
import com.yutou.jianr_mg.Tools.JianRUtils;
import com.yutou.jianr_mg.Tools.Utils;

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

import java.util.List;


public class MapUserTeamActivity extends AppCompatActivity {
    private GameInfoLog mapNode;
    private ListView listView;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       // setContentView(R.layout.activity_favorite);
        listView=new ListView(this);
        setContentView(listView);
        try {
            mapNode= JSON.parseObject(getIntent().getStringExtra("data"), GameInfoLog.class);
        }catch (Exception e){
            e.printStackTrace();
            Utils.toast(this,"数据异常");
            finish();
            return;
        }
        initData();
    }
    void initData(){
        try {
            JSONObject message=new JSONObject(mapNode.getMessage());
            List<TeamData> list=JianRUtils.getUserTeam(message);
            MagicTeamDataAdapter adapter=new MagicTeamDataAdapter(list,this,true);
            listView.setAdapter(adapter);
        } catch (JSONException e) {
            e.printStackTrace();
        }

    }
}
