战斗数据完成
This commit is contained in:
parent
02da8f3512
commit
89e337ddf1
@ -98,40 +98,33 @@ public class WarAdapter extends RecyclerAdapter<List<Map<String, JSONObject>>> {
|
||||
name.setText("("+data.get(0).get("data").get("mapId")+")"+item.getJSONObject("warReport").getString("enemyName")+"("+lev+")");
|
||||
time.setText(SimpleDateFormat.getDateTimeInstance(DateFormat.YEAR_FIELD,DateFormat.SHORT).format(new Date(Long.valueOf(data.get(0).get("DealNode").getString("time")))));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
name.setText("蹭了一下就溜了(无记录)");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemViewClick(List<Map<String, JSONObject>> data) {
|
||||
super.onItemViewClick(data);
|
||||
// Utils.toast(getContext(),"详细内容正在咕,敬请期待:"+ AppData.magicPackageName);
|
||||
/*JSONArray array=new JSONArray();
|
||||
for (Map<String, JSONObject> datum : data) {
|
||||
try {
|
||||
JSONObject json=new JSONObject();
|
||||
json.put("data",datum.get("data"));
|
||||
json.put("DealNode",datum.get("DealNode"));
|
||||
json.put("WarReport",datum.get("GetWarResult"));
|
||||
array.put(json);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}*/
|
||||
Map<String,JSONObject> map=data.get(0);
|
||||
JSONObject json=new JSONObject();
|
||||
try {
|
||||
json.put("data",map.get("data"));
|
||||
json.put("DealNode",map.get("DealNode"));
|
||||
json.put("WarReport",map.get("GetWarResult"));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
if(map.get("GetWarResult")==null){
|
||||
Utils.toast(getContext(),"没有战斗数据");
|
||||
return;
|
||||
}
|
||||
|
||||
Intent intent=new Intent(getContext(), WarLogActivity.class);
|
||||
intent.putExtra("data", json.toString());
|
||||
getContext().startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class JianRDataDataBase extends SQLiteOpenHelper {
|
||||
public List<Map<String,JSONObject>> getDataList(int id){
|
||||
List<Map<String,JSONObject>> list=new ArrayList<>();
|
||||
try{
|
||||
Cursor cursor=readDatabase.rawQuery("select * from t_data_GAME game,t_data_name name,t_data_type type where name._id=? and type._id=name.typeId and game.nameId=name._id",new String[]{id+""});
|
||||
Cursor cursor=readDatabase.rawQuery("select * from t_data_GAME game,t_data_name name,t_data_type type where name._id=? and type._id=name.typeId and game.nameId=name._id order by _id desc",new String[]{id+""});
|
||||
while (cursor.moveToNext()){
|
||||
Map<String,JSONObject> map=new HashMap<>();
|
||||
String m=cursor.getString(cursor.getColumnIndex("m"));
|
||||
|
@ -60,7 +60,6 @@ public class WarFragment extends Fragment {
|
||||
if(srcList==null){
|
||||
srcList = new ArrayList<>();
|
||||
}
|
||||
System.out.println("当前模式下的战斗数据:" + srcList.size());
|
||||
initView();
|
||||
return view;
|
||||
}
|
||||
@ -153,21 +152,16 @@ public class WarFragment extends Fragment {
|
||||
for (int i = 0; i < srcList.size(); i++) {
|
||||
Map<String, JSONObject> maps = srcList.get(i);
|
||||
JSONObject item = maps.get("data");
|
||||
if(maps.get("DealNode").getString("time").contains("2430")){
|
||||
System.out.println("此时正是430");
|
||||
}
|
||||
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
if(item.getInt("mapId")==999202){
|
||||
System.out.println("找到活动地图");
|
||||
}
|
||||
|
||||
System.out.println(">>>>>>"+item.getInt("mapId"));
|
||||
if(Objects.requireNonNull(maps.get("DealNode")).getString("type").equals("DealNode")) {
|
||||
if (item.getInt("mapId") % 10 == 2) {
|
||||
getItem(i, srcList);
|
||||
}
|
||||
}
|
||||
}
|
||||
AppData.handler.post(() -> {
|
||||
adapter.clear();
|
||||
adapter.addAll(data);
|
||||
|
@ -52,6 +52,11 @@ public class DaytimeListViewAdapter extends BaseAdapter {
|
||||
holder = (ViewHolder) view.getTag();
|
||||
}
|
||||
WarData warData = list.get(i);
|
||||
if(warData.getAttackModel().equals("夜战")&&warData.getUserName()==null){
|
||||
holder.user.setText("");
|
||||
holder.arrow.setText("----进入夜战----");
|
||||
holder.enemy.setText("");
|
||||
}else {
|
||||
holder.user.setText(warData.getUserName());
|
||||
holder.arrow.setText("--" + warData.getAttackModel() + "-->");
|
||||
String[] enemyName = warData.getEnemy();
|
||||
@ -59,8 +64,9 @@ public class DaytimeListViewAdapter extends BaseAdapter {
|
||||
for (int j = 0; j < enemyName.length; j++) {
|
||||
name += enemyName[j] + "(-" + warData.getDamage()[j] + "HP)\n";
|
||||
}
|
||||
name=name.substring(0,name.length()-1);
|
||||
holder.enemy.setText(name);
|
||||
System.out.println(i+" "+list.size());
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.umeng.commonsdk.debug.W;
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.Adapters.DaytimeListViewAdapter;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@ -19,9 +20,10 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class DaytimeFragment extends Fragment {
|
||||
public class DaytimeFragment extends Fragment implements WarLogInterface{
|
||||
private ListView listView;
|
||||
private DaytimeListViewAdapter adapter;
|
||||
private JSONObject warReport, json;
|
||||
@ -29,7 +31,7 @@ public class DaytimeFragment extends Fragment {
|
||||
|
||||
private static DaytimeFragment daytime;
|
||||
|
||||
public static DaytimeFragment init() {
|
||||
public static DaytimeFragment getInstance() {
|
||||
if (daytime == null) {
|
||||
daytime = new DaytimeFragment();
|
||||
}
|
||||
@ -58,16 +60,16 @@ public class DaytimeFragment extends Fragment {
|
||||
public void setData(JSONObject json) {
|
||||
try {
|
||||
this.json = json;
|
||||
shipVO = json.getJSONArray("shipVO");
|
||||
warReport = json.getJSONObject("warReport");
|
||||
initData();
|
||||
shipVO = new JSONObject(json.getJSONObject("DealNode").getString("message")).getJSONArray("shipVO");
|
||||
warReport = new JSONObject(json.getJSONObject("DealNode").getString("message")).getJSONObject("warReport");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
if(adapter!=null)
|
||||
adapter.clear();
|
||||
List<WarData> list = new ArrayList<>();
|
||||
list.addAll(nextData("openAirAttack", WarData.OPEN_AIR));
|
||||
list.addAll(nextData("openMissileAttack", WarData.OPEN_MISSILE));
|
||||
@ -77,10 +79,37 @@ public class DaytimeFragment extends Fragment {
|
||||
list.addAll(nextData("normalAttacks2", WarData.ATTACK_NORMAL_2));
|
||||
list.addAll(nextData("closeTorpedoAttack", WarData.CLOSE_TORPEDO));
|
||||
list.addAll(nextData("closeMissileAttack", WarData.CLOSE_MISSILE));
|
||||
try {
|
||||
if (warReport.getInt("canDoNightWar") == 1) {
|
||||
WarData data = new WarData();
|
||||
data.setAttackModel(WarData.NIGHT_WAR);
|
||||
list.add(data);
|
||||
list.addAll(nightWar());
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (adapter != null)
|
||||
adapter.setData(list);
|
||||
}
|
||||
|
||||
private List<WarData> nightWar() {
|
||||
List<WarData> list = new ArrayList<>();
|
||||
try {
|
||||
JSONArray nightAttacks = new JSONObject(json.getJSONObject("WarReport").getString("message")).getJSONObject("extraProgress").getJSONArray("nightAttacks");
|
||||
System.out.println("--------->夜战数量:"+nightAttacks.length());
|
||||
for (int i = 0; i < nightAttacks.length(); i++) {
|
||||
System.out.println(nightAttacks.getJSONObject(i));
|
||||
WarData warData=WarData.getInstance(WarData.NIGHT_WAR,nightAttacks.getJSONObject(i),warReport);
|
||||
System.out.println(warData.toString());
|
||||
list.add(warData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<WarData> nextData(String name, int model) {
|
||||
List<WarData> list = new ArrayList<>();
|
||||
try {
|
||||
|
@ -1,6 +1,148 @@
|
||||
package com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.umeng.commonsdk.debug.W;
|
||||
import com.yutou.jianr_mg.Tools.Utils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class NightFragment extends Fragment {
|
||||
public class NightFragment extends Fragment implements WarLogInterface {
|
||||
private static NightFragment nightFragment;
|
||||
private JSONObject json;
|
||||
private JSONArray shipOV;
|
||||
private ListView list;
|
||||
|
||||
private NightFragment() {
|
||||
|
||||
}
|
||||
|
||||
public static NightFragment getInstance() {
|
||||
if (nightFragment == null) {
|
||||
nightFragment = new NightFragment();
|
||||
}
|
||||
return nightFragment;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
list = new ListView(getContext());
|
||||
list.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
list.setAdapter(new ListAdapter(new ArrayList<>()));
|
||||
return list;
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
|
||||
try {
|
||||
List<ViewGroup> list=new ArrayList<>();
|
||||
list.add(nextItem("提督名字", json.getJSONObject("detailInfo").getString("username")));
|
||||
list.add(nextItem("提督等级", json.getJSONObject("detailInfo").getInt("level") + ""));
|
||||
list.add(nextItem("下一级需要经验", json.getJSONObject("detailInfo").getInt("exp") + ""));
|
||||
list.add(nextItem("拥有舰娘数", json.getJSONObject("detailInfo").getInt("shipNum") + ""));
|
||||
try {
|
||||
list.add(nextItem("打捞", json.getJSONArray("newShipVO").getJSONObject(0).getString("title")));
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
for (int i = 0; i < shipOV.length(); i++) {
|
||||
JSONObject selfShipResults = json.getJSONObject("warResult").getJSONArray("selfShipResults").getJSONObject(i);
|
||||
String mvp = selfShipResults.getInt("isMvp") == 1 ? "(MVP)" : "";
|
||||
try {
|
||||
String levelUp="";
|
||||
if(selfShipResults.getInt("isLevelUp")==1){
|
||||
levelUp=" UP!!";
|
||||
}
|
||||
list.add(nextItem(mvp+shipOV.getJSONObject(i).getString("title") ,
|
||||
selfShipResults.getInt("exp") + "EXP (+" + selfShipResults.getInt("expAdd") + "exp)"+levelUp));
|
||||
}catch (Exception e){
|
||||
list.add(nextItem(shipOV.getJSONObject(i).getString("title") + mvp, "MAX(+" + selfShipResults.getInt("expAdd") + "exp)"));
|
||||
}
|
||||
|
||||
}
|
||||
((ListAdapter)this.list.getAdapter()).setData(list);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private LinearLayout nextItem(String title, String massage) {
|
||||
TextView titleView = new TextView(getContext());
|
||||
TextView messageView = new TextView(getContext());
|
||||
titleView.setText(title + ":");
|
||||
messageView.setText(massage);
|
||||
LinearLayout layout = new LinearLayout(getContext());
|
||||
LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Utils.getPixelsFromDp(getActivity(),50));
|
||||
params.gravity= Gravity.CENTER;
|
||||
layout.setLayoutParams(params);
|
||||
layout.setGravity(Gravity.CENTER);
|
||||
layout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
layout.addView(titleView);
|
||||
layout.addView(messageView);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(JSONObject json) {
|
||||
try {
|
||||
this.json = new JSONObject(json.getJSONObject("WarReport").getString("message"));
|
||||
shipOV= new JSONObject(json.getJSONObject("DealNode").getString("message")).getJSONObject("warReport").getJSONArray("selfShips");
|
||||
initData();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseAdapter {
|
||||
private List<ViewGroup> list;
|
||||
|
||||
public ListAdapter(List<ViewGroup> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
public void setData(List<ViewGroup> list) {
|
||||
this.list=list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.umeng.commonsdk.debug.W;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class WarData {
|
||||
public final static int OPEN_AIR = 0;
|
||||
public final static int OPEN_MISSILE = 1;
|
||||
@ -14,6 +16,7 @@ public class WarData {
|
||||
public final static int ATTACK_NORMAL_2 = 5;
|
||||
public final static int CLOSE_TORPEDO = 6;
|
||||
public final static int CLOSE_MISSILE = 7;
|
||||
public final static int NIGHT_WAR = 8;
|
||||
private String title;
|
||||
private String userName;
|
||||
private long cid;
|
||||
@ -50,6 +53,9 @@ public class WarData {
|
||||
case WarData.CLOSE_MISSILE:
|
||||
model = "闭幕导弹";
|
||||
break;
|
||||
case WarData.NIGHT_WAR:
|
||||
model = "夜战";
|
||||
break;
|
||||
default:
|
||||
model = "未知攻击";
|
||||
}
|
||||
@ -115,6 +121,7 @@ public class WarData {
|
||||
public void setDamage(int[] damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public static WarData getInstance(int attackModel, JSONObject json, JSONObject warReport) {
|
||||
WarData warData = null;
|
||||
try {
|
||||
@ -140,4 +147,18 @@ public class WarData {
|
||||
}
|
||||
return warData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WarData{" +
|
||||
"title='" + title + '\'' +
|
||||
", userName='" + userName + '\'' +
|
||||
", cid=" + cid +
|
||||
", fromIndex=" + fromIndex +
|
||||
", enemy=" + Arrays.toString(enemy) +
|
||||
", damage=" + Arrays.toString(damage) +
|
||||
", userAttack=" + userAttack +
|
||||
", attackModel=" + attackModel +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public interface WarLogInterface {
|
||||
void setData(JSONObject json);
|
||||
}
|
@ -6,10 +6,10 @@ package com.yutou.jianr_mg.Network;
|
||||
|
||||
public class HttpApi {
|
||||
//public static final String HOME="http://jianr.jianrmod.cn/";
|
||||
//public static final String HOME = "http://192.168.31.240:8088/"; //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.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 MOD_ALL = "mod/all.do";
|
||||
|
@ -9,10 +9,10 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.yutou.jianr_mg.Adapters.ViewPagerAdapter;
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.DaytimeFragment;
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.NightFragment;
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.WarLogInterface;
|
||||
import com.yutou.jianr_mg.R;
|
||||
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -51,26 +51,20 @@ public class WarLogActivity extends AppCompatActivity {
|
||||
tab = findViewById(R.id.tab);
|
||||
pager = findViewById(R.id.pager);
|
||||
List<Fragment> list = new ArrayList<>();
|
||||
list.add(DaytimeFragment.init());
|
||||
list.add(new NightFragment());
|
||||
list.add(DaytimeFragment.getInstance());
|
||||
list.add(NightFragment.getInstance());
|
||||
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), list);
|
||||
pager.setAdapter(adapter);
|
||||
pager.setCurrentItem(0);
|
||||
navigationController = tab.material()
|
||||
.addItem(R.drawable.icon_daytime, R.drawable.icon_daytime_select, "战斗过程")
|
||||
.addItem(R.drawable.icon_night, R.drawable.icon_night_select, "战斗结束")
|
||||
.addItem(R.drawable.icon_night, R.drawable.icon_night_select, "战斗报告")
|
||||
.build();
|
||||
navigationController.addTabItemSelectedListener(new OnTabItemSelectedListener() {
|
||||
@Override
|
||||
public void onSelected(int index, int old) {
|
||||
pager.setCurrentItem(index);
|
||||
if(index==0){
|
||||
try {
|
||||
((DaytimeFragment)list.get(index)).setData(new JSONObject(json.getJSONObject("DealNode").getString("message")));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
((WarLogInterface)list.get(index)).setData(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,11 +74,8 @@ public class WarLogActivity extends AppCompatActivity {
|
||||
});
|
||||
navigationController.setupWithViewPager(pager);
|
||||
navigationController.setSelect(0);
|
||||
try {//message
|
||||
((DaytimeFragment)list.get(0)).setData(new JSONObject(json.getJSONObject("DealNode").getString("message")));
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//message
|
||||
((WarLogInterface)list.get(0)).setData(json);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user