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" /> + + + + + - - - -