This commit is contained in:
Yutousama 2020-01-20 18:02:36 +08:00
parent e0c9d89bda
commit e56dec3b9d
11 changed files with 561 additions and 36 deletions

View File

@ -10,9 +10,6 @@ import android.widget.TextView;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import com.alibaba.fastjson.JSON;
import com.yutou.jianr_mg.Data.MapNode;
import com.yutou.jianr_mg.Data.MapTop;
import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.R;
import com.yutou.jianr_mg.views.MapTopActivity; import com.yutou.jianr_mg.views.MapTopActivity;
@ -20,6 +17,7 @@ import cn.lemon.view.adapter.BaseViewHolder;
import cn.lemon.view.adapter.RecyclerAdapter; import cn.lemon.view.adapter.RecyclerAdapter;
public class MapRecyclierAdapter extends RecyclerAdapter<String> { public class MapRecyclierAdapter extends RecyclerAdapter<String> {
public MapRecyclierAdapter(Context context) { public MapRecyclierAdapter(Context context) {
super(context); super(context);
} }

View File

@ -0,0 +1,107 @@
package com.yutou.jianr_mg.Adapters;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.yutou.jianr_mg.Data.JianNiang;
import com.yutou.jianr_mg.Data.ShipEquipmnt;
import com.yutou.jianr_mg.R;
import com.yutou.jianr_mg.Tools.JianRUtils;
import com.yutou.jianr_mg.Tools.Utils;
import cn.lemon.view.adapter.BaseViewHolder;
import cn.lemon.view.adapter.RecyclerAdapter;
public class MapUserTeamRecyclierAdapter extends RecyclerAdapter<JSONObject> {
ImageLoader loader;
public MapUserTeamRecyclierAdapter(Context context) {
super(context);
loader = Utils.initImageLoader(context);
}
@Override
public BaseViewHolder<JSONObject> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(parent, R.layout.item_team);
}
private class ViewHolder extends BaseViewHolder<JSONObject> {
TextView title, hp, hpMax;
ImageView icon, icon_, item1, item2, item3, item4;
ProgressBar hpBar;
LinearLayout hpLayout;
public ViewHolder(ViewGroup parent, int layoutId) {
super(parent, layoutId);
hp = findViewById(R.id.hp);
hpMax = findViewById(R.id.hpMax);
hpBar = findViewById(R.id.itemHp);
title = findViewById(R.id.title);
icon = findViewById(R.id.icon);
icon_ = findViewById(R.id.icon_);
item1 = findViewById(R.id.item1);
item2 = findViewById(R.id.item2);
item3 = findViewById(R.id.item3);
item4 = findViewById(R.id.item4);
hpLayout = findViewById(R.id.hpLayout);
hpBar.setVisibility(View.GONE);
hpLayout.setVisibility(View.GONE);
}
@SuppressLint("SetTextI18n")
@Override
public void setData(JSONObject data) {
super.setData(data);
JianNiang jianNiang = JianRUtils.getJianNiangByCId(data.getInteger("cid"));
if (jianNiang == null)
return;
title.setText(jianNiang.getTitle() + " Level:" + data.getInteger("level"));
loader.displayImage(JianRUtils.getShipImageByCid(data.getInteger("cid"), true), icon);
JSONArray equipment = data.getJSONArray("equipment");
if (equipment.getString(0) != null) {
loader.displayImage(JianRUtils.getShipImageByCid(Integer.parseInt(equipment.getString(0)), false), item1);
item1.setOnClickListener(view -> {
ShipEquipmnt shipEquipmnt = JianRUtils.getEquipmnt(Integer.parseInt(equipment.getString(0)), -2);
if (shipEquipmnt != null)
Utils.toast(getContext(), shipEquipmnt.getTitle());
});
}
if (equipment.getString(1) != null) {
loader.displayImage(JianRUtils.getShipImageByCid(Integer.parseInt(equipment.getString(1)), false), item2);
item2.setOnClickListener(view -> {
ShipEquipmnt shipEquipmnt = JianRUtils.getEquipmnt(Integer.parseInt(equipment.getString(1)), -2);
if (shipEquipmnt != null)
Utils.toast(getContext(), shipEquipmnt.getTitle());
});
}
if (equipment.getString(2) != null) {
loader.displayImage(JianRUtils.getShipImageByCid(Integer.parseInt(equipment.getString(2)), false), item3);
item3.setOnClickListener(view -> {
ShipEquipmnt shipEquipmnt = JianRUtils.getEquipmnt(Integer.parseInt(equipment.getString(2)), -2);
if (shipEquipmnt != null)
Utils.toast(getContext(), shipEquipmnt.getTitle());
});
}
if (equipment.getString(3) != null) {
loader.displayImage(JianRUtils.getShipImageByCid(Integer.parseInt(equipment.getString(3)), false), item4);
item4.setOnClickListener(view -> {
ShipEquipmnt shipEquipmnt = JianRUtils.getEquipmnt(Integer.parseInt(equipment.getString(3)), -2);
if (shipEquipmnt != null)
Utils.toast(getContext(), shipEquipmnt.getTitle());
});
}
}
}
}

View File

@ -0,0 +1,195 @@
package com.yutou.jianr_mg.Data;
import java.util.Date;
public class GameInfoLog {
private int id;
private String ip;
private String uid;
private Date server_time;
private Date client_time;
private String sdk_ver;
private String sdk_int;
private String model;
private String type;
private String url;
private String message;
private String device_id;
private String stub_ver;
private String binder_ver;
private String game_ver;
private String username;
private String server;
private int retry;
private String ext;
private int server_id;
private long client_mid;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public Date getServer_time() {
return server_time;
}
public void setServer_time(Date server_time) {
this.server_time = server_time;
}
public Date getClient_time() {
return client_time;
}
public void setClient_time(Date client_time) {
this.client_time = client_time;
}
public String getSdk_ver() {
return sdk_ver;
}
public void setSdk_ver(String sdk_ver) {
this.sdk_ver = sdk_ver;
}
public String getSdk_int() {
return sdk_int;
}
public void setSdk_int(String sdk_int) {
this.sdk_int = sdk_int;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getDevice_id() {
return device_id;
}
public void setDevice_id(String device_id) {
this.device_id = device_id;
}
public String getStub_ver() {
return stub_ver;
}
public void setStub_ver(String stub_ver) {
this.stub_ver = stub_ver;
}
public String getBinder_ver() {
return binder_ver;
}
public void setBinder_ver(String binder_ver) {
this.binder_ver = binder_ver;
}
public String getGame_ver() {
return game_ver;
}
public void setGame_ver(String game_ver) {
this.game_ver = game_ver;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public int getRetry() {
return retry;
}
public void setRetry(int retry) {
this.retry = retry;
}
public String getExt() {
return ext;
}
public void setExt(String ext) {
this.ext = ext;
}
public int getServer_id() {
return server_id;
}
public void setServer_id(int server_id) {
this.server_id = server_id;
}
public long getClient_mid() {
return client_mid;
}
public void setClient_mid(long client_mid) {
this.client_mid = client_mid;
}
}

View File

@ -118,4 +118,23 @@ public class MapNode {
public void setChapter_tag(String chapter_tag) { public void setChapter_tag(String chapter_tag) {
this.chapter_tag = chapter_tag; this.chapter_tag = chapter_tag;
} }
@Override
public String toString() {
return "MapNode{" +
"id=" + id +
", flag='" + flag + '\'' +
", chapter=" + chapter +
", level=" + level +
", level_pve_id=" + level_pve_id +
", level_type=" + level_type +
", type=" + type +
", type_desc='" + type_desc + '\'' +
", node_name='" + node_name + '\'' +
", level_name='" + level_name + '\'' +
", chapter_name='" + chapter_name + '\'' +
", chapter_sub_name='" + chapter_sub_name + '\'' +
", chapter_tag='" + chapter_tag + '\'' +
'}';
}
} }

View File

@ -10,6 +10,7 @@ public class TeamData {
private int id; private int id;
private int jid; private int jid;
private int type; private int type;
private int level;
private String title; private String title;
private String hp; private String hp;
private String hpMax; private String hpMax;
@ -43,6 +44,7 @@ public class TeamData {
createTime = System.currentTimeMillis(); createTime = System.currentTimeMillis();
} }
@Override @Override
public String toString() { public String toString() {
final StringBuilder sb = new StringBuilder("{"); final StringBuilder sb = new StringBuilder("{");
@ -52,6 +54,8 @@ public class TeamData {
.append(jid); .append(jid);
sb.append(",\"title\":\"") sb.append(",\"title\":\"")
.append(title).append('\"'); .append(title).append('\"');
sb.append(",\"level\":")
.append(level).append("\"");
sb.append(",\"hp\":\"") sb.append(",\"hp\":\"")
.append(hp).append('\"'); .append(hp).append('\"');
sb.append(",\"hpMax\":\"") sb.append(",\"hpMax\":\"")
@ -168,6 +172,14 @@ public class TeamData {
this.equipments = equipments; this.equipments = equipments;
} }
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public JSONObject getSrc() { public JSONObject getSrc() {
try { try {
if (src != null) if (src != null)

View File

@ -43,6 +43,7 @@ import com.yutou.jianr_mg.Tools.ActivitysManager;
import com.yutou.jianr_mg.Tools.AdTools; import com.yutou.jianr_mg.Tools.AdTools;
import com.yutou.jianr_mg.Tools.AppPermissions; import com.yutou.jianr_mg.Tools.AppPermissions;
import com.yutou.jianr_mg.Tools.ConfigUtils; import com.yutou.jianr_mg.Tools.ConfigUtils;
import com.yutou.jianr_mg.Tools.JianRUtils;
import com.yutou.jianr_mg.Tools.Log; import com.yutou.jianr_mg.Tools.Log;
import com.yutou.jianr_mg.Tools.Utils; import com.yutou.jianr_mg.Tools.Utils;
import com.yutou.jianr_mg.views.MapView; import com.yutou.jianr_mg.views.MapView;
@ -92,6 +93,7 @@ public class LoadingActivity extends AppCompatActivity {
/* initViews(); /* initViews();
initData(); initData();
initAd();*/ initAd();*/
JianRUtils.reloadShipType();
MapView mapView=new MapView(this); MapView mapView=new MapView(this);
setContentView(mapView.getView()); setContentView(mapView.getView());
} }

View File

@ -45,6 +45,7 @@ public class MainActivity extends AppCompatActivity {
new Thread(()->{ new Thread(()->{
JianRUtils.reloadJianNiang(); JianRUtils.reloadJianNiang();
JianRUtils.reloadEquipmnts(); JianRUtils.reloadEquipmnts();
JianRUtils.reloadShipType();
}).start(); }).start();
} }

View File

@ -6,10 +6,10 @@ package com.yutou.jianr_mg.Network;
public class HttpApi { public class HttpApi {
//public static final String HOME="http://jianr.jianrmod.cn/"; //public static final String HOME="http://jianr.jianrmod.cn/";
public static final String HOME = "http://192.168.31.92:8080/"; //zzz_gz wifi // public static final String HOME = "http://192.168.31.92:8080/"; //zzz_gz wifi
// public static final String HOME = "http://192.168.43.68:8088/"; //zzz_gz wifi // public static final String HOME = "http://192.168.43.68:8088/"; //zzz_gz wifi
//public static final String HOME = "http://192.168.137.1:8088/"; //笔记本本身WIFI //public static final String HOME = "http://192.168.137.1:8088/"; //笔记本本身WIFI
//public static final String HOME = "http://192.168.1.151:8080/"; //公司 public static final String HOME = "http://192.168.1.151:8080/"; //公司
public static final String HOME_URL=HOME+"android/"; //服务器 public static final String HOME_URL=HOME+"android/"; //服务器
public static final String MOD_ALL = "mod/all.do"; public static final String MOD_ALL = "mod/all.do";
@ -59,6 +59,8 @@ public class HttpApi {
public static final String MAPTOP_MAP_DATA="map/data.do"; public static final String MAPTOP_MAP_DATA="map/data.do";
public static final String MAPTOP_USER_TEAM="map/team/data.do"; public static final String MAPTOP_USER_TEAM="map/team/data.do";
public static final String SHIP_TYPE="ship/type.do";
public static final String HITOKOTO_API = "https://v1.hitokoto.cn/"; public static final String HITOKOTO_API = "https://v1.hitokoto.cn/";
} }

View File

@ -9,10 +9,14 @@ import com.yutou.jianr_mg.Data.AppData;
import com.yutou.jianr_mg.Data.JianNiang; import com.yutou.jianr_mg.Data.JianNiang;
import com.yutou.jianr_mg.Data.ShipEquipmnt; import com.yutou.jianr_mg.Data.ShipEquipmnt;
import com.yutou.jianr_mg.Data.TeamData; import com.yutou.jianr_mg.Data.TeamData;
import com.yutou.jianr_mg.Data.ZsShipType;
import com.yutou.jianr_mg.Interfaces.DownloadFileInerface; import com.yutou.jianr_mg.Interfaces.DownloadFileInerface;
import com.yutou.jianr_mg.Interfaces.HttpInterface;
import com.yutou.jianr_mg.Network.HttpApi;
import com.yutou.jianr_mg.Network.HttpUtils; import com.yutou.jianr_mg.Network.HttpUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -27,6 +31,7 @@ import java.util.List;
public class JianRUtils { public class JianRUtils {
private static JSONArray shipCardId; private static JSONArray shipCardId;
private static List<ZsShipType> types;
public static int jianCidToid(String cid) { public static int jianCidToid(String cid) {
if (cid.substring(1, 2).equals("1")) { if (cid.substring(1, 2).equals("1")) {
@ -115,6 +120,7 @@ public class JianRUtils {
return data; return data;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.err.println("!!!!!--->"+json.toString());
} }
return data; return data;
} }
@ -181,12 +187,20 @@ public class JianRUtils {
return data; return data;
} }
private static List<JianNiang> jianNiangs; public static String getShipImageByCid(int cid,boolean ship){
private static List<ShipEquipmnt> equipmnts; if(ship)
return "http://jianr.jianrmod.cn/jianr/ship/S_NORMAL_"+jianCidToid(cid+"")+".png";
else{
return "http://jianr.jianrmod.cn/jianr/equipment/equip_L_"+equipCidToid(cid+"")+".png";
}
}
private static List<JianNiang> jianNiangs=new ArrayList<>();
private static List<ShipEquipmnt> equipmnts=new ArrayList<>();
public static void reloadJianNiang() { public static void reloadJianNiang() {
try { try {
if (jianNiangs == null) { if (jianNiangs == null||jianNiangs.size()==0) {
jianNiangs = new ArrayList<>(); jianNiangs = new ArrayList<>();
JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipCardWu.json")); JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipCardWu.json"));
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {
@ -201,10 +215,54 @@ public class JianRUtils {
getInit(); getInit();
} }
} }
public static void reloadShipType(){
if(types==null){
types=new ArrayList<>();
}else{
types.clear();
}
HttpUtils.get(HttpApi.HOME_URL + HttpApi.SHIP_TYPE, new HttpInterface() {
@Override
public void httpGetData(String string, int code) {
try {
JSONObject json=new JSONObject(string);
JSONArray data=json.getJSONArray("data");
for (int i = 0; i < data.length(); i++) {
types.add(JSON.parseObject(data.getJSONObject(i).toString(),ZsShipType.class));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void httpError(Exception e) {
e.printStackTrace();
}
});
}
public static ZsShipType getShipTypeById(int id){
for (ZsShipType type : types) {
if(type.getId()==id){
return type;
}
}
return null;
}
public static JianNiang getJianNiangByCId(int cid){
for (JianNiang jianNiang : jianNiangs) {
if(jianNiang.getCid()==cid){
return jianNiang;
}
}
return null;
}
public static List<ShipEquipmnt> reloadEquipmnts() { public static List<ShipEquipmnt> reloadEquipmnts() {
try { try {
if (equipmnts == null) { if (equipmnts == null||equipmnts.size()==0) {
equipmnts = new ArrayList<>(); equipmnts = new ArrayList<>();
JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipEquipmnt.json")); JSONArray array = new JSONArray(Utils.readFile(Utils.getAppPath() + "/jdata/shipEquipmnt.json"));
for (int i = 0; i < array.length(); i++) { for (int i = 0; i < array.length(); i++) {

View File

@ -4,9 +4,7 @@ import android.app.ActivityOptions;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -16,22 +14,26 @@ import android.widget.TextView;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentActivity;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.yutou.jianr_mg.Data.GameInfoLog;
import com.yutou.jianr_mg.Data.MapNode; import com.yutou.jianr_mg.Data.MapNode;
import com.yutou.jianr_mg.Data.MapTop; import com.yutou.jianr_mg.Data.TeamData;
import com.yutou.jianr_mg.Data.UserTeam;
import com.yutou.jianr_mg.Interfaces.HttpInterface; import com.yutou.jianr_mg.Interfaces.HttpInterface;
import com.yutou.jianr_mg.Network.HttpApi; import com.yutou.jianr_mg.Network.HttpApi;
import com.yutou.jianr_mg.Network.HttpUtils; import com.yutou.jianr_mg.Network.HttpUtils;
import com.yutou.jianr_mg.R; import com.yutou.jianr_mg.R;
import com.yutou.jianr_mg.Tools.JianRUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class MapTopActivity extends AppCompatActivity { public class MapTopActivity extends AppCompatActivity {
private LinearLayout listLayout, titleLayout; private LinearLayout listLayout, titleLayout;
@ -42,9 +44,13 @@ public class MapTopActivity extends AppCompatActivity {
private int limit = -1; private int limit = -1;
private ListView listView; private ListView listView;
private Handler handler; private Handler handler;
private String teamData = null;
private ArrayAdapter<String> adapter; private ArrayAdapter<String> adapter;
List<String> nodes; private List<String> nodes;
private boolean isData = false; private List<MapNode> mapNodes;
private List<GameInfoLog> logs;
private int model = -1;
private MapNode mapNode;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -52,11 +58,25 @@ public class MapTopActivity extends AppCompatActivity {
setContentView(R.layout.item_maptop); setContentView(R.layout.item_maptop);
level_name = getIntent().getStringExtra("level_name"); level_name = getIntent().getStringExtra("level_name");
chapterName = getIntent().getStringExtra("chapterName"); chapterName = getIntent().getStringExtra("chapterName");
isData = getIntent().getBooleanExtra("data", false); model = getIntent().getIntExtra("data", -1);
handler = new Handler();
initView(); initView();
switch (model) {
case 0:
mapNodes = new ArrayList<>();
initData(); initData();
break;
case 1:
mapNode = com.alibaba.fastjson.JSONObject.parseObject(getIntent().getStringExtra("mapNode"), MapNode.class);
limit = 0;
getData();
break;
default:
initData();
}
handler = new Handler();
} }
private void initView() { private void initView() {
@ -71,21 +91,28 @@ public class MapTopActivity extends AppCompatActivity {
} else { } else {
name.setText(level_name); name.setText(level_name);
} }
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener((parent, view, position, id) -> {
@Override Intent intent = null;
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (model == 0) {
Intent intent = new Intent(MapTopActivity.this, MapTopActivity.class); if (mapNode == null) {
if(isData){
}else {
intent = new Intent(MapTopActivity.this, MapTopActivity.class); intent = new Intent(MapTopActivity.this, MapTopActivity.class);
intent.putExtra("level_name", level_name); intent.putExtra("level_name", level_name);
intent.putExtra("chapterName", nodes.get(position)); intent.putExtra("chapterName", nodes.get(position));
intent.putExtra("data", true); intent.putExtra("mapNode", com.alibaba.fastjson.JSONObject.toJSONString(mapNodes.get(position)));
intent.putExtra("data", 1);
} else {
intent = new Intent(MapTopActivity.this, MapUserTeamActivity.class);
intent.putExtra("data", teamData);
} }
} else if (model == -1) {
intent = new Intent(MapTopActivity.this, MapTopActivity.class);
intent.putExtra("level_name", level_name);
intent.putExtra("chapterName", nodes.get(position));
intent.putExtra("data", 0);
}
if (intent != null)
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(MapTopActivity.this, name, "transitionTitle").toBundle()); startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(MapTopActivity.this, name, "transitionTitle").toBundle());
}
}); });
} }
@ -103,13 +130,22 @@ public class MapTopActivity extends AppCompatActivity {
@Override @Override
public void httpGetData(String string, int code) { public void httpGetData(String string, int code) {
try { try {
System.out.println(string);
nodes = new ArrayList<>();
JSONObject json = new JSONObject(string); JSONObject json = new JSONObject(string);
JSONArray data = json.getJSONArray("data"); JSONArray data = json.getJSONArray("data");
nodes = new ArrayList<>();
if (model == 0) {
for (int i = 0; i < data.length(); i++) {
teamData = data.getJSONObject(i).toString();
MapNode mapNode = JSON.parseObject(data.getJSONObject(i).toString(), MapNode.class);
mapNodes.add(mapNode);
nodes.add(mapNode.getNode_name());
}
} else {
for (int i = 0; i < data.length(); i++) { for (int i = 0; i < data.length(); i++) {
nodes.add(data.getString(i)); nodes.add(data.getString(i));
} }
}
handler.post(() -> { handler.post(() -> {
adapter = new ArrayAdapter<>(MapTopActivity.this, android.R.layout.simple_list_item_1, nodes); adapter = new ArrayAdapter<>(MapTopActivity.this, android.R.layout.simple_list_item_1, nodes);
listView.setAdapter(adapter); listView.setAdapter(adapter);
@ -128,23 +164,60 @@ public class MapTopActivity extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
} }
private void getData(){
try{
JSONObject json=new JSONObject();
json.put("levelName",level_name);
private void getData() {
try {
logs = new ArrayList<>();
nodes = new ArrayList<>();
JSONObject json = new JSONObject();
json.put("node", mapNode.getId());
json.put("limit", limit);
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MAPTOP_USER_TEAM, json, new HttpInterface() { HttpUtils.post(HttpApi.HOME_URL + HttpApi.MAPTOP_USER_TEAM, json, new HttpInterface() {
@Override @Override
public void httpGetData(String string, int code) { public void httpGetData(String string, int code) {
try {
JSONObject json = new JSONObject(string);
JSONArray data = json.getJSONArray("data");
for (int i = 0; i < data.length(); i++) {
GameInfoLog log = JSON.parseObject(data.getJSONObject(i).toString(), GameInfoLog.class);
logs.add(log);
List<TeamData> teamData = JianRUtils.getUserTeam(new JSONObject(log.getMessage()));
Map<Integer, Integer> types = new HashMap<>();
String stype = "";
for (TeamData datum : teamData) {
if (types.containsKey(datum.getType())) {
types.put(datum.getType(), types.get(datum.getType()) + 1);
} else {
types.put(datum.getType(), 1);
}
}
for (Integer key : types.keySet()) {
try {
stype += types.get(key) + JianRUtils.getShipTypeById(key).getShortname() + ",";
} catch (Exception e) {
e.printStackTrace();
}
} }
nodes.add(stype);
}
handler.post(() -> {
adapter = new ArrayAdapter<>(MapTopActivity.this, android.R.layout.simple_list_item_1, nodes);
listView.setAdapter(adapter);
});
} catch (JSONException e) {
e.printStackTrace();
System.out.println(string);
}
}
@Override @Override
public void httpError(Exception e) { public void httpError(Exception e) {
} }
}); });
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -1,14 +1,72 @@
package com.yutou.jianr_mg.views; package com.yutou.jianr_mg.views;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.fastjson.JSON;
import com.yutou.jianr_mg.Adapters.MapUserTeamRecyclierAdapter;
import com.yutou.jianr_mg.Data.MapNode;
import com.yutou.jianr_mg.Interfaces.HttpInterface;
import com.yutou.jianr_mg.Network.HttpApi;
import com.yutou.jianr_mg.Network.HttpUtils;
import com.yutou.jianr_mg.R;
import com.yutou.jianr_mg.Tools.Utils;
import org.json.JSONObject;
import cn.lemon.view.RefreshRecyclerView;
public class MapUserTeamActivity extends AppCompatActivity { public class MapUserTeamActivity extends AppCompatActivity {
private RefreshRecyclerView recyclerView;
private MapUserTeamRecyclierAdapter adapter;
private MapNode mapNode;
private int limit=0;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_favorite);
recyclerView = findViewById(R.id.recyclerView);
try {
mapNode= JSON.parseObject(getIntent().getStringExtra("data"),MapNode.class);
}catch (Exception e){
e.printStackTrace();
Utils.toast(this,"数据异常");
finish();
return;
}
System.out.println(mapNode.toString());
} }
void initView() {
adapter=new MapUserTeamRecyclierAdapter(this);
recyclerView.setSwipeRefreshColors(0xFF437845, 0xFFE44F98, 0xFF2FAC21);
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
recyclerView.setAdapter(adapter);
}
void initData(){
try{
JSONObject json=new JSONObject();
json.put("node",mapNode.getId());
json.put("limit",limit);
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MAPTOP_USER_TEAM, json, new HttpInterface() {
@Override
public void httpGetData(String string, int code) {
}
@Override
public void httpError(Exception e) {
}
});
}catch (Exception e){
e.printStackTrace();
}
}
} }