From 137a7135e7a53c28b1e269e0afa69846233dde4e Mon Sep 17 00:00:00 2001 From: MUQING <1966944300@qq.com> Date: Sun, 3 Dec 2023 13:00:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AD=8C=E5=8D=95=E6=90=9C?= =?UTF-8?q?=E7=B4=A2BUG=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=B9=B3=E6=9D=BF?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=92=AD=E6=94=BE=E5=99=A8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?BUG=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=B6=B2=E5=B7=B2=E7=9F=A5?= =?UTF-8?q?=E7=9A=84=E6=AD=8C=E5=8D=95=E6=93=8D=E4=BD=9CBUG=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=92=AD=E6=94=BE=E5=99=A8UI=E6=89=8B=E5=8A=BF?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E5=96=84=E6=92=AD=E6=94=BE=E5=99=A8=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=86=85=E9=83=A8=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/muqingbfq/bfq.java | 29 +++++++++++++++++++ .../java/com/muqingbfq/fragment/Media.java | 28 +++--------------- app/src/main/res/layout/activity_bfq.xml | 17 +++++++++++ app/src/main/res/layout/fragment_bfq.xml | 16 ---------- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/muqingbfq/bfq.java b/app/src/main/java/com/muqingbfq/bfq.java index 3488090..8904afe 100644 --- a/app/src/main/java/com/muqingbfq/bfq.java +++ b/app/src/main/java/com/muqingbfq/bfq.java @@ -12,16 +12,20 @@ import android.os.Bundle; import android.util.TypedValue; import android.view.MotionEvent; import android.view.WindowManager; +import android.widget.ImageView; import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; import com.muqingbfq.databinding.ActivityBfqBinding; import com.muqingbfq.fragment.Media; +import org.json.JSONObject; + public class bfq extends AppCompatActivity { @SuppressLint("StaticFieldLeak") public static AppCompatActivity context; @@ -70,8 +74,33 @@ public class bfq extends AppCompatActivity { inflate.control.setOnClickListener(new bfq_an.control(inflate.control)); if (bfqkz.mt != null && bfqkz.mt.build.isPlaying()) { inflate.kg.setImageResource(R.drawable.bf); + bfq_an.islike(this); } text(); + + inflate.like.setOnClickListener(view1 -> { + ImageView like = (ImageView) view1; + try { + if (bfqkz.like_bool) { + like.setImageTintList(ContextCompat.getColorStateList(bfq.this, R.color.text)); + com.muqingbfq.fragment.gd.like.remove(String.valueOf(bfqkz.xm.id)); + } else { + like.setImageTintList(ContextCompat. + getColorStateList(bfq.this, android.R.color.holo_red_dark)); + JSONObject json = new JSONObject(); + json.put("name", bfqkz.xm.name); + json.put("zz", bfqkz.xm.zz); + json.put("picUrl", bfqkz.xm.picurl); + com.muqingbfq.fragment.gd.like.put(String.valueOf(bfqkz.xm.id), json); + } + com.muqingbfq.mq.wj.xrwb(com.muqingbfq.mq.wj.mp3_like, + com.muqingbfq.fragment.gd.like.toString()); + bfqkz.like_bool = !bfqkz.like_bool; + } catch (Exception e) { + e.printStackTrace(); + } + }); + } public static Bitmap bitmap; diff --git a/app/src/main/java/com/muqingbfq/fragment/Media.java b/app/src/main/java/com/muqingbfq/fragment/Media.java index 1db5363..049ec4d 100644 --- a/app/src/main/java/com/muqingbfq/fragment/Media.java +++ b/app/src/main/java/com/muqingbfq/fragment/Media.java @@ -133,28 +133,6 @@ public class Media extends Fragment { }); } //初始化播放器列表 - bfq.findViewById(R.id.like).setOnClickListener(view1 -> { - ImageView like = (ImageView) view1; - try { - if (bfqkz.like_bool) { - like.setImageTintList(ContextCompat.getColorStateList(view.getContext(), R.color.text)); - com.muqingbfq.fragment.gd.like.remove(String.valueOf(bfqkz.xm.id)); - } else { - like.setImageTintList(ContextCompat. - getColorStateList(view.getContext(), android.R.color.holo_red_dark)); - JSONObject json = new JSONObject(); - json.put("name", bfqkz.xm.name); - json.put("zz", bfqkz.xm.zz); - json.put("picUrl", bfqkz.xm.picurl); - com.muqingbfq.fragment.gd.like.put(String.valueOf(bfqkz.xm.id), json); - } - com.muqingbfq.mq.wj.xrwb(com.muqingbfq.mq.wj.mp3_like, - com.muqingbfq.fragment.gd.like.toString()); - bfqkz.like_bool = !bfqkz.like_bool; - } catch (Exception e) { - e.printStackTrace(); - } - }); if (bfqkz.xm != null) { main.handler.removeCallbacks(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度 long duration = bfqkz.mt.build.getDuration(); @@ -163,7 +141,7 @@ public class Media extends Fragment { long position = bfqkz.mt.build.getCurrentPosition(); setProgress((int) position); main.handler.post(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度 - bfq_an.islike(com.muqingbfq.bfq.context); + new Thread() { @Override public void run() { @@ -176,7 +154,9 @@ public class Media extends Fragment { } private boolean isTablet(Context context) { - return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; + return (context.getResources(). + getConfiguration().screenLayout & + Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; } public static LrcView getlrcView() { diff --git a/app/src/main/res/layout/activity_bfq.xml b/app/src/main/res/layout/activity_bfq.xml index 3c9b3fa..cb4a0ed 100644 --- a/app/src/main/res/layout/activity_bfq.xml +++ b/app/src/main/res/layout/activity_bfq.xml @@ -46,6 +46,23 @@ android:layout_weight="1" tools:layout="@layout/fragment_bfq" /> + + + + + - - - -