This commit is contained in:
Yutousama 2020-01-19 18:30:14 +08:00
parent bce9e9e6c5
commit e0c9d89bda
9 changed files with 167 additions and 50 deletions

4
.gitignore vendored
View File

@ -2,9 +2,9 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/
.DS_Store
/build
/captures
.externalNativeBuild
.분綾SDK.zip
.<EFBFBD><EFBFBD><EFBFBD><EFBFBD>SDK.zip

View File

@ -94,6 +94,7 @@
<activity android:name=".views.NativeAdActivity" />
<activity android:name=".views.UserDataActivity" />
<activity android:name=".views.MapTopActivity" />
<activity android:name=".views.MapUserTeamActivity" />
<provider

View File

@ -19,17 +19,17 @@ import com.yutou.jianr_mg.views.MapTopActivity;
import cn.lemon.view.adapter.BaseViewHolder;
import cn.lemon.view.adapter.RecyclerAdapter;
public class MapRecyclierAdapter extends RecyclerAdapter<MapTop> {
public class MapRecyclierAdapter extends RecyclerAdapter<String> {
public MapRecyclierAdapter(Context context) {
super(context);
}
@Override
public BaseViewHolder<MapTop> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
public BaseViewHolder<String> onCreateBaseViewHolder(ViewGroup parent, int viewType) {
return new ItemViewHolder(parent,R.layout.item_maptop);
}
class ItemViewHolder extends BaseViewHolder<MapTop>{
class ItemViewHolder extends BaseViewHolder<String>{
private LinearLayout listLayout,titleLayout;
private TextView name;
@ -42,17 +42,16 @@ public class MapRecyclierAdapter extends RecyclerAdapter<MapTop> {
}
@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());
}
}

View File

@ -43,18 +43,6 @@ public class MapTop {
}
public void setShipTeam(String shipTeam) {
List<Integer> 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;
}

View File

@ -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/";

View File

@ -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<String> adapter;
List<String> 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();
}
}
}

View File

@ -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);
}
}

View File

@ -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<MapTop> list = new ArrayList<>();
List<String> 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<MapTop> list, boolean next) {
private void showData(List<String> list, boolean next) {
if(limit==0){
adapter.clear();
}

View File

@ -1,8 +1,10 @@
<?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:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/main_layut"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/titleLayout"
@ -17,12 +19,12 @@
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:transitionName="transitionTitle"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:text="TextView" />
android:text="TextView"
android:transitionName="transitionTitle" />
</LinearLayout>
<LinearLayout
@ -30,13 +32,14 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleLayout">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:visibility="visible" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>