From e0c9d89bda62db1e6423a8a6637647139a3ef4b2 Mon Sep 17 00:00:00 2001
From: Yutousama <583819556@qq.com>
Date: Sun, 19 Jan 2020 18:30:14 +0800
Subject: [PATCH] update
---
.gitignore | 4 +-
app/src/main/AndroidManifest.xml | 1 +
.../Adapters/MapRecyclierAdapter.java | 15 +-
.../java/com/yutou/jianr_mg/Data/MapTop.java | 12 --
.../com/yutou/jianr_mg/Network/HttpApi.java | 7 +-
.../yutou/jianr_mg/views/MapTopActivity.java | 133 ++++++++++++++++--
.../jianr_mg/views/MapUserTeamActivity.java | 14 ++
.../com/yutou/jianr_mg/views/MapView.java | 16 +--
app/src/main/res/layout/item_maptop.xml | 15 +-
9 files changed, 167 insertions(+), 50 deletions(-)
create mode 100644 app/src/main/java/com/yutou/jianr_mg/views/MapUserTeamActivity.java
diff --git a/.gitignore b/.gitignore
index 100f097..8461eb2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,9 +2,9 @@
.gradle
/local.properties
/.idea/workspace.xml
-/.idea/libraries
+/.idea/
.DS_Store
/build
/captures
.externalNativeBuild
-.SDK.zip
+.����SDK.zip
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 640ca9e..5424797 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -94,6 +94,7 @@
+
{
+public class MapRecyclierAdapter extends RecyclerAdapter {
public MapRecyclierAdapter(Context context) {
super(context);
}
@Override
- public BaseViewHolder onCreateBaseViewHolder(ViewGroup parent, int viewType) {
+ public BaseViewHolder onCreateBaseViewHolder(ViewGroup parent, int viewType) {
return new ItemViewHolder(parent,R.layout.item_maptop);
}
- class ItemViewHolder extends BaseViewHolder{
+ class ItemViewHolder extends BaseViewHolder{
private LinearLayout listLayout,titleLayout;
private TextView name;
@@ -42,17 +42,16 @@ public class MapRecyclierAdapter extends RecyclerAdapter {
}
@Override
- public void setData(MapTop data) {
+ public void setData(String data) {
super.setData(data);
- MapNode node=data.getNode();
- name.setText(node.getLevel_name()+"("+node.getChapter_name()+"):"+node.getNode_name());
+ name.setText(data);
}
@Override
- public void onItemViewClick(MapTop data) {
+ public void onItemViewClick(String data) {
super.onItemViewClick(data);
Intent intent=new Intent(getContext(), MapTopActivity.class);
- intent.putExtra("map", JSON.toJSONString(data));
+ intent.putExtra("level_name", data);
getContext().startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(((FragmentActivity)getContext()),name,"transitionTitle").toBundle());
}
}
diff --git a/app/src/main/java/com/yutou/jianr_mg/Data/MapTop.java b/app/src/main/java/com/yutou/jianr_mg/Data/MapTop.java
index aea1382..7fe1f87 100644
--- a/app/src/main/java/com/yutou/jianr_mg/Data/MapTop.java
+++ b/app/src/main/java/com/yutou/jianr_mg/Data/MapTop.java
@@ -43,18 +43,6 @@ public class MapTop {
}
public void setShipTeam(String shipTeam) {
- List list=new ArrayList<>();
- shipTeam=shipTeam.replace("[","");
- shipTeam=shipTeam.replace("]","");
- for (String ship : shipTeam.split(",")) {
- list.add(Integer.parseInt(ship));
- }
- Collections.sort(list);
- shipTeam="[";
- for (Integer integer : list) {
- shipTeam+=integer+",";
- }
- shipTeam = shipTeam.substring(0, shipTeam.length() - 1) + "]";
this.shipTeam = shipTeam;
}
diff --git a/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java b/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java
index 5a02bf1..37196f4 100644
--- a/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java
+++ b/app/src/main/java/com/yutou/jianr_mg/Network/HttpApi.java
@@ -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.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.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";
@@ -55,6 +55,9 @@ public class HttpApi {
public static final String AD_LOG="ad/user.do";
public static final String MAPTOP_ALL="map/all.do";
+ public static final String MAPTOP_MAP_NODE="map/node.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 HITOKOTO_API = "https://v1.hitokoto.cn/";
diff --git a/app/src/main/java/com/yutou/jianr_mg/views/MapTopActivity.java b/app/src/main/java/com/yutou/jianr_mg/views/MapTopActivity.java
index 0c6829a..74d3e84 100644
--- a/app/src/main/java/com/yutou/jianr_mg/views/MapTopActivity.java
+++ b/app/src/main/java/com/yutou/jianr_mg/views/MapTopActivity.java
@@ -1,34 +1,151 @@
package com.yutou.jianr_mg.views;
+import android.app.ActivityOptions;
+import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.FrameLayout;
import android.widget.LinearLayout;
+import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
+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.Interfaces.HttpInterface;
+import com.yutou.jianr_mg.Network.HttpApi;
+import com.yutou.jianr_mg.Network.HttpUtils;
import com.yutou.jianr_mg.R;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
public class MapTopActivity extends AppCompatActivity {
- private LinearLayout listLayout,titleLayout;
+ private LinearLayout listLayout, titleLayout;
+ private ConstraintLayout main_layut;
private TextView name;
- private MapTop mapTop;
+ private String level_name;
+ private String chapterName;
+ private int limit = -1;
+ private ListView listView;
+ private Handler handler;
+ private ArrayAdapter adapter;
+ List nodes;
+ private boolean isData = false;
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.item_maptop);
- mapTop= JSON.parseObject(getIntent().getStringExtra("map"),MapTop.class);
+ level_name = getIntent().getStringExtra("level_name");
+ chapterName = getIntent().getStringExtra("chapterName");
+ isData = getIntent().getBooleanExtra("data", false);
+ handler = new Handler();
initView();
+
+ initData();
}
private void initView() {
- listLayout=findViewById(R.id.listLayout);
- titleLayout=findViewById(R.id.titleLayout);
- name=findViewById(R.id.title);
- MapNode node=mapTop.getNode();
- name.setText(node.getLevel_name()+"("+node.getChapter_name()+"):"+node.getNode_name()+" 配置:"+mapTop.getShipTeam());
+ listLayout = findViewById(R.id.listLayout);
+ main_layut = findViewById(R.id.main_layut);
+ titleLayout = findViewById(R.id.titleLayout);
+ listView = findViewById(R.id.listView);
+ name = findViewById(R.id.title);
+ main_layut.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ if (chapterName != null) {
+ name.setText(chapterName);
+ } else {
+ name.setText(level_name);
+ }
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ Intent intent = new Intent(MapTopActivity.this, MapTopActivity.class);
+ if(isData){
+
+ }else {
+ intent = new Intent(MapTopActivity.this, MapTopActivity.class);
+ intent.putExtra("level_name", level_name);
+ intent.putExtra("chapterName", nodes.get(position));
+ intent.putExtra("data", true);
+ }
+ startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(MapTopActivity.this, name, "transitionTitle").toBundle());
+
+ }
+ });
+ }
+
+ private void initData() {
+ try {
+ JSONObject json = new JSONObject();
+ json.put("levelName", level_name);
+ json.put("limit", limit);
+ String url = HttpApi.MAPTOP_MAP_NODE;
+ if (chapterName != null) {
+ url = HttpApi.MAPTOP_MAP_DATA;
+ json.put("chapterName", chapterName);
+ }
+ HttpUtils.post(HttpApi.HOME_URL + url, json, new HttpInterface() {
+ @Override
+ public void httpGetData(String string, int code) {
+ try {
+ System.out.println(string);
+ nodes = new ArrayList<>();
+ JSONObject json = new JSONObject(string);
+ JSONArray data = json.getJSONArray("data");
+ for (int i = 0; i < data.length(); i++) {
+ nodes.add(data.getString(i));
+ }
+ handler.post(() -> {
+ adapter = new ArrayAdapter<>(MapTopActivity.this, android.R.layout.simple_list_item_1, nodes);
+ listView.setAdapter(adapter);
+ });
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void httpError(Exception e) {
+
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ private void getData(){
+ try{
+ JSONObject json=new JSONObject();
+ json.put("levelName",level_name);
+
+ 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();
+ }
}
}
diff --git a/app/src/main/java/com/yutou/jianr_mg/views/MapUserTeamActivity.java b/app/src/main/java/com/yutou/jianr_mg/views/MapUserTeamActivity.java
new file mode 100644
index 0000000..c4e5797
--- /dev/null
+++ b/app/src/main/java/com/yutou/jianr_mg/views/MapUserTeamActivity.java
@@ -0,0 +1,14 @@
+package com.yutou.jianr_mg.views;
+
+import android.os.Bundle;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
+public class MapUserTeamActivity extends AppCompatActivity {
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ }
+}
diff --git a/app/src/main/java/com/yutou/jianr_mg/views/MapView.java b/app/src/main/java/com/yutou/jianr_mg/views/MapView.java
index 33f37b0..2a44db8 100644
--- a/app/src/main/java/com/yutou/jianr_mg/views/MapView.java
+++ b/app/src/main/java/com/yutou/jianr_mg/views/MapView.java
@@ -67,10 +67,6 @@ public class MapView {
limit = 0;
initData(true);
});
- recyclerView.setLoadMoreAction(()->{
- limit += 100;
- initData(false);
- });
}
@@ -87,16 +83,12 @@ public class MapView {
Log.i(string);
JSONObject json = new JSONObject(string);
JSONArray data = json.getJSONArray("data");
- List list = new ArrayList<>();
+ List list = new ArrayList<>();
for (int i = 0; i < data.length(); i++) {
- list.add(JSON.parseObject(data.getJSONObject(i).toString(), MapTop.class));
+ list.add(data.getString(i));
}
handler.post(()-> {
- try {
- showData(list, json.getBoolean("next"));
- } catch (JSONException e) {
- e.printStackTrace();
- }
+ showData(list, false);
});
} catch (JSONException e) {
@@ -114,7 +106,7 @@ public class MapView {
}
}
- private void showData(List list, boolean next) {
+ private void showData(List list, boolean next) {
if(limit==0){
adapter.clear();
}
diff --git a/app/src/main/res/layout/item_maptop.xml b/app/src/main/res/layout/item_maptop.xml
index 7880eab..8114177 100644
--- a/app/src/main/res/layout/item_maptop.xml
+++ b/app/src/main/res/layout/item_maptop.xml
@@ -1,8 +1,10 @@
+ android:id="@+id/main_layut"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+ android:text="TextView"
+ android:transitionName="transitionTitle" />
+ android:layout_height="match_parent"
+ android:visibility="visible" />
\ No newline at end of file