From 9b7de6544d34ddf3f1d9683e8b989c3ca83385f4 Mon Sep 17 00:00:00 2001 From: MUQING <1966944300@qq.com> Date: Tue, 26 Dec 2023 20:55:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AA=E9=80=80BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/muqingbfq/api/resource.java | 29 +++++++++-------- app/src/main/java/com/muqingbfq/bfqkz.java | 32 +++++++++++-------- .../com/muqingbfq/fragment/gd_adapter.java | 4 +-- .../java/com/muqingbfq/list/MyViewHoder.java | 1 - 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/muqingbfq/api/resource.java b/app/src/main/java/com/muqingbfq/api/resource.java index dd7c238..b9907a8 100644 --- a/app/src/main/java/com/muqingbfq/api/resource.java +++ b/app/src/main/java/com/muqingbfq/api/resource.java @@ -19,25 +19,26 @@ public class resource { public static void recommend(List list) { try { - String hq = wj.dqwb(wj.gd_json); + list.clear(); + String hq; JSONObject json; - if (hq != null) { - json = new JSONObject(hq); - if (json.getInt("code") == 200) { - wj.xrwb(wj.gd_json, hq); - JSONArray recommend = json.getJSONArray("recommend"); - int length = recommend.length(); - for (int i = 0; i < length; i++) { - JSONObject jsonObject = recommend.getJSONObject(i); - add(jsonObject, list); - } - } - } hq = wl.hq("/recommend/resource?cookie=" + wl.Cookie); if (hq == null) { + hq = wj.dqwb(wj.gd_json); + if (hq != null) { + json = new JSONObject(hq); + if (json.getInt("code") == 200) { + wj.xrwb(wj.gd_json, hq); + JSONArray recommend = json.getJSONArray("recommend"); + int length = recommend.length(); + for (int i = 0; i < length; i++) { + JSONObject jsonObject = recommend.getJSONObject(i); + add(jsonObject, list); + } + } + } return; } - list.clear(); json = new JSONObject(hq); if (json.getInt("code") == 200) { wj.xrwb(wj.gd_json, hq); diff --git a/app/src/main/java/com/muqingbfq/bfqkz.java b/app/src/main/java/com/muqingbfq/bfqkz.java index ad7c040..319c518 100644 --- a/app/src/main/java/com/muqingbfq/bfqkz.java +++ b/app/src/main/java/com/muqingbfq/bfqkz.java @@ -58,14 +58,7 @@ public class bfqkz extends Service { } bfqkz.list.remove(bfqkz.xm); bfqkz.xm = bfqkz.list.get(bfqkz.getmti(bfqkz.ms)); - new Thread() { - @Override - public void run() { - super.run(); - bfqkz.mp3(com.muqingbfq.api. - url.hq(bfqkz.xm)); - } - }.start(); + new mp3(id); return; } if (TextUtils.isEmpty(xm.picurl)) { @@ -74,17 +67,28 @@ public class bfqkz extends Service { if (bfqkz.lishi_list.size() >= 100) { bfqkz.lishi_list.remove(0); } - bfqkz.lishi_list.remove(bfqkz.xm); - bfqkz.lishi_list.add(0, bfqkz.xm); - wj.xrwb(wj.gd + "mp3_hc.json", new com.google.gson.Gson().toJson(bfqkz.lishi_list)); + if (bfqkz.lishi_list.size() > 0) { + bfqkz.lishi_list.remove(bfqkz.xm); + bfqkz.lishi_list.add(0, bfqkz.xm); + wj.xrwb(wj.gd + "mp3_hc.json", new com.google.gson.Gson().toJson(bfqkz.lishi_list)); + } mt.setDataSource(id); } catch (Exception e) { yc.start(home.appCompatActivity, "bfqkz mp3(" + id + ") :" + e); } } - public static void mp3(Uri id) { - mp3(id.toString()); + public static class mp3 extends Thread { + String id; + public mp3(String id) { + this.id = id; + start(); + } + @Override + public void run() { + super.run(); + mp3(id); + } } @@ -147,7 +151,7 @@ public class bfqkz extends Service { case PlaybackStateCompat.STATE_PLAYING: case PlaybackStateCompat.STATE_PAUSED: case PlaybackStateCompat.STATE_NONE: - mp3(uri); +// mp3(uri);/ playback = new PlaybackStateCompat.Builder() .setState(PlaybackStateCompat.STATE_CONNECTING, 0, 1.0f) .build(); diff --git a/app/src/main/java/com/muqingbfq/fragment/gd_adapter.java b/app/src/main/java/com/muqingbfq/fragment/gd_adapter.java index 4022bb2..c6e3a60 100644 --- a/app/src/main/java/com/muqingbfq/fragment/gd_adapter.java +++ b/app/src/main/java/com/muqingbfq/fragment/gd_adapter.java @@ -47,12 +47,12 @@ public class gd_adapter extends Fragment { public void run() { super.run(); resource.recommend(list); - main.handler.postDelayed(new sx(baseadapter),500); + main.handler.post(new sx(baseadapter)); } }.start(); return layout; } - private static class sx implements Runnable { + private class sx implements Runnable { gd.baseadapter baseadapter; public sx(gd.baseadapter baseadapter) { diff --git a/app/src/main/java/com/muqingbfq/list/MyViewHoder.java b/app/src/main/java/com/muqingbfq/list/MyViewHoder.java index dd66c4e..fbbf279 100644 --- a/app/src/main/java/com/muqingbfq/list/MyViewHoder.java +++ b/app/src/main/java/com/muqingbfq/list/MyViewHoder.java @@ -16,7 +16,6 @@ public class MyViewHoder extends RecyclerView.ViewHolder { name = itemView.findViewById(R.id.wb1); zz = itemView.findViewById(R.id.zz); } - public Context getContext() { return itemView.getContext(); }