diff --git a/app/build.gradle b/app/build.gradle index ad8325d..7bbd781 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ android { defaultConfig { //applicationId "com.yutou.jianrmg_v2" applicationId "com.yutou.jianr_mg" - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion 29 versionCode 2 versionName "2.3" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index da8051e..640ca9e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -38,6 +38,7 @@ android:value="R" /> @@ -92,6 +93,7 @@ + { + public MapRecyclierAdapter(Context context) { + super(context); + } + + @Override + public BaseViewHolder onCreateBaseViewHolder(ViewGroup parent, int viewType) { + + return new ItemViewHolder(parent,R.layout.item_maptop); + } + class ItemViewHolder extends BaseViewHolder{ + private LinearLayout listLayout,titleLayout; + private TextView name; + + public ItemViewHolder(ViewGroup parent, int layoutId) { + super(parent, layoutId); + listLayout=findViewById(R.id.listLayout); + titleLayout=findViewById(R.id.titleLayout); + name=findViewById(R.id.title); + listLayout.setVisibility(View.GONE); + } + + @Override + public void setData(MapTop data) { + super.setData(data); + MapNode node=data.getNode(); + name.setText(node.getLevel_name()+"("+node.getChapter_name()+"):"+node.getNode_name()); + } + + @Override + public void onItemViewClick(MapTop data) { + super.onItemViewClick(data); + Intent intent=new Intent(getContext(), MapTopActivity.class); + intent.putExtra("map", JSON.toJSONString(data)); + getContext().startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(((FragmentActivity)getContext()),name,"transitionTitle").toBundle()); + } + } +} diff --git a/app/src/main/java/com/yutou/jianr_mg/Data/MapNode.java b/app/src/main/java/com/yutou/jianr_mg/Data/MapNode.java new file mode 100644 index 0000000..fc7b44f --- /dev/null +++ b/app/src/main/java/com/yutou/jianr_mg/Data/MapNode.java @@ -0,0 +1,121 @@ +package com.yutou.jianr_mg.Data; + +public class MapNode { + private int id; + private String flag; + private int chapter; + private int level; + private int level_pve_id; + private int level_type; + private int type; + private String type_desc; + private String node_name; + private String level_name; + private String chapter_name; + private String chapter_sub_name; + private String chapter_tag; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFlag() { + return flag; + } + + public void setFlag(String flag) { + this.flag = flag; + } + + public int getChapter() { + return chapter; + } + + public void setChapter(int chapter) { + this.chapter = chapter; + } + + public int getLevel() { + return level; + } + + public void setLevel(int level) { + this.level = level; + } + + public int getLevel_pve_id() { + return level_pve_id; + } + + public void setLevel_pve_id(int level_pve_id) { + this.level_pve_id = level_pve_id; + } + + public int getLevel_type() { + return level_type; + } + + public void setLevel_type(int level_type) { + this.level_type = level_type; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getType_desc() { + return type_desc; + } + + public void setType_desc(String type_desc) { + this.type_desc = type_desc; + } + + public String getNode_name() { + return node_name; + } + + public void setNode_name(String node_name) { + this.node_name = node_name; + } + + public String getLevel_name() { + return level_name; + } + + public void setLevel_name(String level_name) { + this.level_name = level_name; + } + + public String getChapter_name() { + return chapter_name; + } + + public void setChapter_name(String chapter_name) { + this.chapter_name = chapter_name; + } + + public String getChapter_sub_name() { + return chapter_sub_name; + } + + public void setChapter_sub_name(String chapter_sub_name) { + this.chapter_sub_name = chapter_sub_name; + } + + public String getChapter_tag() { + return chapter_tag; + } + + public void setChapter_tag(String chapter_tag) { + this.chapter_tag = chapter_tag; + } +} 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 new file mode 100644 index 0000000..aea1382 --- /dev/null +++ b/app/src/main/java/com/yutou/jianr_mg/Data/MapTop.java @@ -0,0 +1,69 @@ +package com.yutou.jianr_mg.Data; + + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class MapTop { + private int id; + private int mapId; + private int mapNode; + private String shipTeam; + private MapNode node; + + public MapNode getNode() { + return node; + } + + public void setNode(MapNode node) { + this.node = node; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public int getMapid() { + return mapId; + } + + public void setMapid(int mapid) { + this.mapId = mapid; + } + + + + public String getShipTeam() { + return shipTeam; + } + + 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; + } + + public int getMapNode() { + return mapNode; + } + + public void setMapNode(int mapNode) { + this.mapNode = mapNode; + } +} diff --git a/app/src/main/java/com/yutou/jianr_mg/Data/UserTeam.java b/app/src/main/java/com/yutou/jianr_mg/Data/UserTeam.java new file mode 100644 index 0000000..9f34a0a --- /dev/null +++ b/app/src/main/java/com/yutou/jianr_mg/Data/UserTeam.java @@ -0,0 +1,69 @@ +package com.yutou.jianr_mg.Data; + +import java.util.Date; + +public class UserTeam { + private int id; + private int mid; + private int mapNode; + private String uname; + private String ship; + private String title; + private Date createTime; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getUname() { + return uname; + } + + public void setUname(String uname) { + this.uname = uname; + } + + public String getShip() { + return ship; + } + + public void setShip(String ship) { + this.ship = ship; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public int getMid() { + return mid; + } + + public void setMid(int mid) { + this.mid = mid; + } + + public int getMapNode() { + return mapNode; + } + + public void setMapNode(int mapNode) { + this.mapNode = mapNode; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java b/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java index c9d72da..3a80eb9 100644 --- a/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java +++ b/app/src/main/java/com/yutou/jianr_mg/LoadingActivity.java @@ -45,6 +45,7 @@ import com.yutou.jianr_mg.Tools.AppPermissions; import com.yutou.jianr_mg.Tools.ConfigUtils; import com.yutou.jianr_mg.Tools.Log; import com.yutou.jianr_mg.Tools.Utils; +import com.yutou.jianr_mg.views.MapView; import com.yutou.jianr_mg.views.RegisterActivity; import com.yutou.jianr_mg.views.WebActivity; @@ -80,7 +81,7 @@ public class LoadingActivity extends AppCompatActivity { System.out.println("update"); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - setContentView(R.layout.activity_loading); + //setContentView(R.layout.activity_loading); Utils.setImmersion(this); if (url == null) { clazz = MainActivity.class; @@ -88,9 +89,11 @@ public class LoadingActivity extends AppCompatActivity { clazz = WebActivity.class; } handler = new Handler(); - initViews(); + /* initViews(); initData(); - initAd(); + initAd();*/ + MapView mapView=new MapView(this); + setContentView(mapView.getView()); } private void login(String name, String pass) { 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 93a6dd6..5a02bf1 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"; @@ -54,6 +54,8 @@ public class HttpApi { public static final String AD_GET="ad/ad.do"; public static final String AD_LOG="ad/user.do"; + public static final String MAPTOP_ALL="map/all.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 new file mode 100644 index 0000000..0c6829a --- /dev/null +++ b/app/src/main/java/com/yutou/jianr_mg/views/MapTopActivity.java @@ -0,0 +1,34 @@ +package com.yutou.jianr_mg.views; + +import android.os.Bundle; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import com.alibaba.fastjson.JSON; +import com.yutou.jianr_mg.Data.MapNode; +import com.yutou.jianr_mg.Data.MapTop; +import com.yutou.jianr_mg.R; + +public class MapTopActivity extends AppCompatActivity { + private LinearLayout listLayout,titleLayout; + private TextView name; + private MapTop mapTop; + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.item_maptop); + mapTop= JSON.parseObject(getIntent().getStringExtra("map"),MapTop.class); + initView(); + } + + 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()); + } +} 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 new file mode 100644 index 0000000..33f37b0 --- /dev/null +++ b/app/src/main/java/com/yutou/jianr_mg/views/MapView.java @@ -0,0 +1,132 @@ +package com.yutou.jianr_mg.views; + +import android.content.Context; +import android.os.Handler; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.LinearLayout; + +import androidx.recyclerview.widget.LinearLayoutManager; + +import com.alibaba.fastjson.JSON; +import com.yutou.jianr_mg.Adapters.MapRecyclierAdapter; +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.Tools.Log; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +import cn.lemon.view.RefreshRecyclerView; + +public class MapView { + private LinearLayout mainLayout; + private Context context; + + private Button search; + private RefreshRecyclerView recyclerView; + private MapRecyclierAdapter adapter; + private int limit = 0; + private Handler handler; + + public MapView(Context context) { + this.context = context; + handler=new Handler(); + initView(); + initData(true); + } + + public ViewGroup getView() { + return mainLayout; + } + + private void initView() { + mainLayout = new LinearLayout(context); + mainLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); + mainLayout.setOrientation(LinearLayout.VERTICAL); + + search = new Button(context); + search.setText("查询"); + + adapter = new MapRecyclierAdapter(context); + recyclerView = new RefreshRecyclerView(context); + recyclerView.setSwipeRefreshColors(0xFF437845, 0xFFE44F98, 0xFF2FAC21); + recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); + recyclerView.setAdapter(adapter); + + mainLayout.addView(search); + mainLayout.addView(recyclerView); + + recyclerView.addRefreshAction(() -> { + limit = 0; + initData(true); + }); + recyclerView.setLoadMoreAction(()->{ + limit += 100; + initData(false); + }); + } + + + private void initData(boolean init) { + try { + if (init) + limit = 0; + JSONObject json = new JSONObject(); + json.put("limit", limit); + HttpUtils.post(HttpApi.HOME_URL + HttpApi.MAPTOP_ALL, json, new HttpInterface() { + @Override + public void httpGetData(String string, int code) { + try { + Log.i(string); + JSONObject json = new JSONObject(string); + JSONArray data = json.getJSONArray("data"); + List list = new ArrayList<>(); + for (int i = 0; i < data.length(); i++) { + list.add(JSON.parseObject(data.getJSONObject(i).toString(), MapTop.class)); + } + handler.post(()-> { + try { + showData(list, json.getBoolean("next")); + } catch (JSONException e) { + e.printStackTrace(); + } + }); + + } catch (JSONException e) { + e.printStackTrace(); + } + } + + @Override + public void httpError(Exception e) { + + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void showData(List list, boolean next) { + if(limit==0){ + adapter.clear(); + } + adapter.addAll(list); + adapter.notifyDataSetChanged(); + recyclerView.dismissSwipeRefresh(); + if (!next) { + recyclerView.showNoMore(); + } + if (limit == 0) + recyclerView.getRecyclerView().scrollToPosition(0); + + + } +} diff --git a/app/src/main/res/layout/item_maptop.xml b/app/src/main/res/layout/item_maptop.xml new file mode 100644 index 0000000..7880eab --- /dev/null +++ b/app/src/main/res/layout/item_maptop.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/switch_item.xml b/app/src/main/res/layout/switch_item.xml deleted file mode 100644 index ee492c6..0000000 --- a/app/src/main/res/layout/switch_item.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - -