新增战斗日志
战斗结果未完成
This commit is contained in:
parent
66294e96ef
commit
02da8f3512
@ -16,13 +16,13 @@ android {
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file('/media/yutou/_dde_data/AndroidKeys/yutou.jks')
|
||||
storeFile file('D:\\AndroidKeys\\yutou.jks')
|
||||
storePassword '34864394'
|
||||
keyAlias 'yutou'
|
||||
keyPassword '34864394'
|
||||
}
|
||||
debug {
|
||||
storeFile file('/media/yutou/_dde_data/AndroidKeys/yutou.jks')
|
||||
storeFile file('D:\\AndroidKeys\\yutou.jks')
|
||||
storePassword '34864394'
|
||||
keyAlias 'yutou'
|
||||
keyPassword '34864394'
|
||||
|
@ -105,7 +105,7 @@ public class WarAdapter extends RecyclerAdapter<List<Map<String, JSONObject>>> {
|
||||
@Override
|
||||
public void onItemViewClick(List<Map<String, JSONObject>> data) {
|
||||
super.onItemViewClick(data);
|
||||
Utils.toast(getContext(),"详细内容正在咕,敬请期待:"+ AppData.magicPackageName);
|
||||
// Utils.toast(getContext(),"详细内容正在咕,敬请期待:"+ AppData.magicPackageName);
|
||||
/*JSONArray array=new JSONArray();
|
||||
for (Map<String, JSONObject> datum : data) {
|
||||
try {
|
||||
@ -118,10 +118,20 @@ public class WarAdapter extends RecyclerAdapter<List<Map<String, JSONObject>>> {
|
||||
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();
|
||||
}
|
||||
|
||||
Intent intent=new Intent(getContext(), WarLogActivity.class);
|
||||
intent.putExtra("data", array.toString());
|
||||
getContext().startActivity(intent);*/
|
||||
intent.putExtra("data", json.toString());
|
||||
getContext().startActivity(intent);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -398,12 +398,13 @@ public class JianRDataDataBase extends SQLiteOpenHelper {
|
||||
|
||||
public void removeName(String name) {
|
||||
removeData(name);
|
||||
writeDatabase.delete(TAB_DATA_NAME, "title", new String[]{name});
|
||||
writeDatabase.delete(TAB_DATA_NAME, "title=?", new String[]{name});
|
||||
|
||||
}
|
||||
|
||||
public void removeType(String name) {
|
||||
removeName(name);
|
||||
writeDatabase.delete(TAB_DATA_TYPE, "typeName", new String[]{name});
|
||||
writeDatabase.delete(TAB_DATA_TYPE, "typeName=?", new String[]{name});
|
||||
}
|
||||
public void clearTable(String tabName){
|
||||
writeDatabase.execSQL("delete from "+tabName);
|
||||
|
@ -0,0 +1,81 @@
|
||||
package com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.Adapters;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.WarData;
|
||||
import com.yutou.jianr_mg.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DaytimeListViewAdapter extends BaseAdapter {
|
||||
private Context context;
|
||||
private List<WarData> list;
|
||||
|
||||
public DaytimeListViewAdapter(Context context, List<WarData> list) {
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
ViewHolder holder;
|
||||
if (view == null) {
|
||||
view = LayoutInflater.from(context).inflate(R.layout.item_war, null);
|
||||
holder = new ViewHolder();
|
||||
holder.user = view.findViewById(R.id.user);
|
||||
holder.arrow = view.findViewById(R.id.arrow);
|
||||
holder.enemy = view.findViewById(R.id.enemy);
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
holder = (ViewHolder) view.getTag();
|
||||
}
|
||||
WarData warData = list.get(i);
|
||||
holder.user.setText(warData.getUserName());
|
||||
holder.arrow.setText("--" + warData.getAttackModel() + "-->");
|
||||
String[] enemyName = warData.getEnemy();
|
||||
String name = "";
|
||||
for (int j = 0; j < enemyName.length; j++) {
|
||||
name += enemyName[j] + "(-" + warData.getDamage()[j] + "HP)\n";
|
||||
}
|
||||
holder.enemy.setText(name);
|
||||
System.out.println(i+" "+list.size());
|
||||
return view;
|
||||
}
|
||||
|
||||
public void setData(List<WarData> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
if (list != null)
|
||||
list.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
TextView user, arrow, enemy;
|
||||
}
|
||||
}
|
@ -1,18 +1,103 @@
|
||||
package com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.Adapters.DaytimeListViewAdapter;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DaytimeFragment extends Fragment {
|
||||
private ListView listView;
|
||||
private DaytimeListViewAdapter adapter;
|
||||
private JSONObject warReport, json;
|
||||
private JSONArray shipVO;
|
||||
|
||||
private static DaytimeFragment daytime;
|
||||
|
||||
public static DaytimeFragment init() {
|
||||
if (daytime == null) {
|
||||
daytime = new DaytimeFragment();
|
||||
}
|
||||
return daytime;
|
||||
}
|
||||
|
||||
private DaytimeFragment() {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
if (listView != null) {
|
||||
return listView;
|
||||
}
|
||||
listView = new ListView(getContext());
|
||||
if (adapter == null) {
|
||||
adapter = new DaytimeListViewAdapter(getContext(), new ArrayList<>());
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
initData();
|
||||
return listView;
|
||||
}
|
||||
|
||||
public void setData(JSONObject json) {
|
||||
try {
|
||||
this.json = json;
|
||||
shipVO = json.getJSONArray("shipVO");
|
||||
warReport = json.getJSONObject("warReport");
|
||||
initData();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
List<WarData> list = new ArrayList<>();
|
||||
list.addAll(nextData("openAirAttack", WarData.OPEN_AIR));
|
||||
list.addAll(nextData("openMissileAttack", WarData.OPEN_MISSILE));
|
||||
list.addAll(nextData("openAntiSubAttack", WarData.OPEN_ANTISUB));
|
||||
list.addAll(nextData("openTorpedoAttack", WarData.OPEN_TORPEDO));
|
||||
list.addAll(nextData("normalAttacks", WarData.ATTACK_NORMAL));
|
||||
list.addAll(nextData("normalAttacks2", WarData.ATTACK_NORMAL_2));
|
||||
list.addAll(nextData("closeTorpedoAttack", WarData.CLOSE_TORPEDO));
|
||||
list.addAll(nextData("closeMissileAttack", WarData.CLOSE_MISSILE));
|
||||
if (adapter != null)
|
||||
adapter.setData(list);
|
||||
}
|
||||
|
||||
private List<WarData> nextData(String name, int model) {
|
||||
List<WarData> list = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 0; i < warReport.getJSONArray(name).length(); i++) {
|
||||
WarData warData = WarData.getInstance(model, warReport.getJSONArray(name).getJSONObject(i), warReport);
|
||||
if (warData != null)
|
||||
list.add(warData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
daytime = null;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,143 @@
|
||||
package com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments;
|
||||
|
||||
import com.umeng.commonsdk.debug.W;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class WarData {
|
||||
public final static int OPEN_AIR = 0;
|
||||
public final static int OPEN_MISSILE = 1;
|
||||
public final static int OPEN_ANTISUB = 2;
|
||||
public final static int OPEN_TORPEDO = 3;
|
||||
public final static int ATTACK_NORMAL = 4;
|
||||
public final static int ATTACK_NORMAL_2 = 5;
|
||||
public final static int CLOSE_TORPEDO = 6;
|
||||
public final static int CLOSE_MISSILE = 7;
|
||||
private String title;
|
||||
private String userName;
|
||||
private long cid;
|
||||
private int fromIndex;
|
||||
private String[] enemy;
|
||||
private int[] damage;
|
||||
private boolean userAttack;
|
||||
private int attackModel;
|
||||
|
||||
public String getAttackModel() {
|
||||
String model;
|
||||
switch (attackModel) {
|
||||
case WarData.OPEN_AIR:
|
||||
model = "航空战";
|
||||
break;
|
||||
case WarData.ATTACK_NORMAL:
|
||||
model = "炮击";
|
||||
break;
|
||||
case WarData.ATTACK_NORMAL_2:
|
||||
model = "次轮炮击";
|
||||
break;
|
||||
case WarData.OPEN_MISSILE:
|
||||
model = "导弹战";
|
||||
break;
|
||||
case WarData.OPEN_TORPEDO:
|
||||
model = "开幕雷击";
|
||||
break;
|
||||
case WarData.OPEN_ANTISUB:
|
||||
model = "开幕反潜";
|
||||
break;
|
||||
case WarData.CLOSE_TORPEDO:
|
||||
model = "闭幕雷击";
|
||||
break;
|
||||
case WarData.CLOSE_MISSILE:
|
||||
model = "闭幕导弹";
|
||||
break;
|
||||
default:
|
||||
model = "未知攻击";
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setAttackModel(int attackModel) {
|
||||
this.attackModel = attackModel;
|
||||
}
|
||||
|
||||
public boolean isUserAttack() {
|
||||
return userAttack;
|
||||
}
|
||||
|
||||
public void setUserAttack(boolean userAttack) {
|
||||
this.userAttack = userAttack;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public long getCid() {
|
||||
return cid;
|
||||
}
|
||||
|
||||
public void setCid(long cid) {
|
||||
this.cid = cid;
|
||||
}
|
||||
|
||||
public int getFromIndex() {
|
||||
return fromIndex;
|
||||
}
|
||||
|
||||
public void setFromIndex(int fromIndex) {
|
||||
this.fromIndex = fromIndex;
|
||||
}
|
||||
|
||||
public String[] getEnemy() {
|
||||
return enemy;
|
||||
}
|
||||
|
||||
public void setEnemy(String[] enemy) {
|
||||
this.enemy = enemy;
|
||||
}
|
||||
|
||||
public int[] getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(int[] damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
public static WarData getInstance(int attackModel,JSONObject json,JSONObject warReport){
|
||||
WarData warData=null;
|
||||
try{
|
||||
warData=new WarData();
|
||||
warData.userAttack= json.getInt("attackSide") == 1;
|
||||
JSONArray array=warData.isUserAttack()?warReport.getJSONArray("selfShips"):warReport.getJSONArray("enemyShips");
|
||||
warData.setUserName(array.getJSONObject(json.getInt("fromIndex")).getString("title"));
|
||||
warData.setCid(array.getJSONObject(json.getInt("fromIndex")).getLong("shipCid"));
|
||||
int[] damages=new int[json.getJSONArray("damages").length()];
|
||||
for (int i = 0; i < json.getJSONArray("damage").length(); i++) {
|
||||
damages[i]=json.getJSONArray("damage").getInt(i);
|
||||
}
|
||||
warData.setDamage(damages);
|
||||
String[] enemyNames=new String[json.getJSONArray("targetIndex").length()];
|
||||
array=!warData.isUserAttack()?warReport.getJSONArray("selfShips"):warReport.getJSONArray("enemyShips");
|
||||
for (int i = 0; i < json.getJSONArray("targetIndex").length(); i++) {
|
||||
enemyNames[i]=array.getJSONObject(json.getJSONArray("targetIndex").getInt(i)).getString("title");
|
||||
}
|
||||
warData.setEnemy(enemyNames);
|
||||
warData.setAttackModel(attackModel);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return warData;
|
||||
}
|
||||
}
|
@ -5,11 +5,11 @@ package com.yutou.jianr_mg.Network;
|
||||
*/
|
||||
|
||||
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.240: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.1.84:8088/"; //公司
|
||||
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";
|
||||
|
@ -7,27 +7,24 @@ import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.yutou.jianr_mg.Adapters.ViewPagerAdapter;
|
||||
import com.yutou.jianr_mg.Data.ShipEquipmnt;
|
||||
import com.yutou.jianr_mg.Data.TeamData;
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.DaytimeFragment;
|
||||
import com.yutou.jianr_mg.Fragments.GameDataFragments.WarLogFragments.NightFragment;
|
||||
import com.yutou.jianr_mg.R;
|
||||
import com.yutou.jianr_mg.Tools.JianRUtils;
|
||||
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import me.majiajie.pagerbottomtabstrip.NavigationController;
|
||||
import me.majiajie.pagerbottomtabstrip.PageNavigationView;
|
||||
import me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectedListener;
|
||||
|
||||
public class WarLogActivity extends AppCompatActivity {
|
||||
JSONArray array;
|
||||
JSONObject json;
|
||||
private PageNavigationView tab;
|
||||
private ViewPager pager;
|
||||
private NavigationController navigationController;
|
||||
@ -37,54 +34,43 @@ public class WarLogActivity extends AppCompatActivity {
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_mod_list);
|
||||
initView();
|
||||
|
||||
try {
|
||||
array = new JSONArray(getIntent().getStringExtra("data"));
|
||||
json = new JSONObject(Objects.requireNonNull(getIntent().getStringExtra("data")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (array == null) {
|
||||
array = new JSONArray();
|
||||
}
|
||||
try {
|
||||
JSONObject json = array.getJSONObject(0);
|
||||
JSONObject data = json.getJSONObject("DealNode");
|
||||
JSONObject msg = new JSONObject(data.getString("message"));
|
||||
List<TeamData> list = JianRUtils.getUserTeam(msg);
|
||||
List<TeamData> hm=new ArrayList<>();
|
||||
for (TeamData teamData : list) {
|
||||
// if(teamData.getType()>)
|
||||
String name = teamData.getTitle();
|
||||
List<String> equipment = teamData.getEquipments();
|
||||
for (String s : equipment) {
|
||||
ShipEquipmnt equipmnt = JianRUtils.getEquipmnt(Integer.parseInt(s), -1);
|
||||
System.out.println("舰娘:"+name+"装备名字:"+equipmnt.getTitle()+" 类型:"+equipmnt.getType());
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
if (json == null) {
|
||||
json = new JSONObject();
|
||||
}
|
||||
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tab = (PageNavigationView) findViewById(R.id.tab);
|
||||
pager = (ViewPager) findViewById(R.id.pager);
|
||||
tab = findViewById(R.id.tab);
|
||||
pager = findViewById(R.id.pager);
|
||||
List<Fragment> list = new ArrayList<>();
|
||||
list.add(new DaytimeFragment());
|
||||
list.add(DaytimeFragment.init());
|
||||
list.add(new NightFragment());
|
||||
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_daytime, R.drawable.icon_daytime_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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,6 +80,11 @@ 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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
43
app/src/main/res/layout/item_war.xml
Normal file
43
app/src/main/res/layout/item_war.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/enemy"
|
||||
app:layout_constraintStart_toEndOf="@+id/user"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/enemy"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="TextView"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user