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 .gradle
/local.properties /local.properties
/.idea/workspace.xml /.idea/workspace.xml
/.idea/libraries /.idea/
.DS_Store .DS_Store
/build /build
/captures /captures
.externalNativeBuild .externalNativeBuild
.분綾SDK.zip .<EFBFBD><EFBFBD><EFBFBD><EFBFBD>SDK.zip

View File

@ -94,6 +94,7 @@
<activity android:name=".views.NativeAdActivity" /> <activity android:name=".views.NativeAdActivity" />
<activity android:name=".views.UserDataActivity" /> <activity android:name=".views.UserDataActivity" />
<activity android:name=".views.MapTopActivity" /> <activity android:name=".views.MapTopActivity" />
<activity android:name=".views.MapUserTeamActivity" />
<provider <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.BaseViewHolder;
import cn.lemon.view.adapter.RecyclerAdapter; import cn.lemon.view.adapter.RecyclerAdapter;
public class MapRecyclierAdapter extends RecyclerAdapter<MapTop> { public class MapRecyclierAdapter extends RecyclerAdapter<String> {
public MapRecyclierAdapter(Context context) { public MapRecyclierAdapter(Context context) {
super(context); super(context);
} }
@Override @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); return new ItemViewHolder(parent,R.layout.item_maptop);
} }
class ItemViewHolder extends BaseViewHolder<MapTop>{ class ItemViewHolder extends BaseViewHolder<String>{
private LinearLayout listLayout,titleLayout; private LinearLayout listLayout,titleLayout;
private TextView name; private TextView name;
@ -42,17 +42,16 @@ public class MapRecyclierAdapter extends RecyclerAdapter<MapTop> {
} }
@Override @Override
public void setData(MapTop data) { public void setData(String data) {
super.setData(data); super.setData(data);
MapNode node=data.getNode(); name.setText(data);
name.setText(node.getLevel_name()+"("+node.getChapter_name()+"):"+node.getNode_name());
} }
@Override @Override
public void onItemViewClick(MapTop data) { public void onItemViewClick(String data) {
super.onItemViewClick(data); super.onItemViewClick(data);
Intent intent=new Intent(getContext(), MapTopActivity.class); 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()); getContext().startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(((FragmentActivity)getContext()),name,"transitionTitle").toBundle());
} }
} }

View File

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

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";
@ -55,6 +55,9 @@ public class HttpApi {
public static final String AD_LOG="ad/user.do"; public static final String AD_LOG="ad/user.do";
public static final String MAPTOP_ALL="map/all.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/"; public static final String HITOKOTO_API = "https://v1.hitokoto.cn/";

View File

@ -1,34 +1,151 @@
package com.yutou.jianr_mg.views; package com.yutou.jianr_mg.views;
import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle; 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.LinearLayout;
import android.widget.ListView;
import android.widget.TextView; 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.fragment.app.FragmentActivity;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
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.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 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 { public class MapTopActivity extends AppCompatActivity {
private LinearLayout listLayout,titleLayout; private LinearLayout listLayout, titleLayout;
private ConstraintLayout main_layut;
private TextView name; 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 @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.item_maptop); 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(); initView();
initData();
} }
private void initView() { private void initView() {
listLayout=findViewById(R.id.listLayout); listLayout = findViewById(R.id.listLayout);
titleLayout=findViewById(R.id.titleLayout); main_layut = findViewById(R.id.main_layut);
name=findViewById(R.id.title); titleLayout = findViewById(R.id.titleLayout);
MapNode node=mapTop.getNode(); listView = findViewById(R.id.listView);
name.setText(node.getLevel_name()+"("+node.getChapter_name()+"):"+node.getNode_name()+" 配置:"+mapTop.getShipTeam()); 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; limit = 0;
initData(true); initData(true);
}); });
recyclerView.setLoadMoreAction(()->{
limit += 100;
initData(false);
});
} }
@ -87,16 +83,12 @@ public class MapView {
Log.i(string); Log.i(string);
JSONObject json = new JSONObject(string); JSONObject json = new JSONObject(string);
JSONArray data = json.getJSONArray("data"); JSONArray data = json.getJSONArray("data");
List<MapTop> list = new ArrayList<>(); List<String> list = new ArrayList<>();
for (int i = 0; i < data.length(); i++) { 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(()-> { handler.post(()-> {
try { showData(list, false);
showData(list, json.getBoolean("next"));
} catch (JSONException e) {
e.printStackTrace();
}
}); });
} catch (JSONException e) { } 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){ if(limit==0){
adapter.clear(); adapter.clear();
} }

View File

@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent" android:id="@+id/main_layut"
android:layout_height="wrap_content"> android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/titleLayout" android:id="@+id/titleLayout"
@ -17,12 +19,12 @@
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:transitionName="transitionTitle"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_weight="1" android:layout_weight="1"
android:text="TextView" /> android:text="TextView"
android:transitionName="transitionTitle" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -30,13 +32,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleLayout"> app:layout_constraintTop_toBottomOf="@+id/titleLayout">
<ListView <ListView
android:id="@+id/listView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent"
android:visibility="visible" />
</LinearLayout> </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>