diff --git a/app/src/main/java/com/muqingbfq/MediaPlayer.java b/app/src/main/java/com/muqingbfq/MediaPlayer.java index 0ebc856..ec4d92d 100644 --- a/app/src/main/java/com/muqingbfq/MediaPlayer.java +++ b/app/src/main/java/com/muqingbfq/MediaPlayer.java @@ -167,7 +167,7 @@ public class MediaPlayer { Media.setProgress(0); Media.setname(name); Media.setzz(zz); - bfq_an.islike(Media.view.getContext()); + bfq_an.islike(); } bfq_db.setname(name); bfq_db.setzz(zz); diff --git a/app/src/main/java/com/muqingbfq/bfq.java b/app/src/main/java/com/muqingbfq/bfq.java index 8904afe..e9437a6 100644 --- a/app/src/main/java/com/muqingbfq/bfq.java +++ b/app/src/main/java/com/muqingbfq/bfq.java @@ -29,7 +29,7 @@ import org.json.JSONObject; public class bfq extends AppCompatActivity { @SuppressLint("StaticFieldLeak") public static AppCompatActivity context; - ActivityBfqBinding inflate; + public ActivityBfqBinding inflate; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -56,15 +56,6 @@ public class bfq extends AppCompatActivity { } return false; }); - if (bfqkz.xm != null) { - Media.setname(bfqkz.xm.name); - Media.setzz(bfqkz.xm.zz); - } -/* inflate.name.setOnLongClickListener(view -> { - gj.fz(bfq.this, inflate.name.getText().toString()); - gj.ts(bfq.this, "倍刢成功"); - return false; - });*/ bfq_an.kz kz = new bfq_an.kz(); inflate.kg.setOnClickListener(kz); inflate.xyq.setOnClickListener(kz); @@ -74,18 +65,17 @@ 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)); + inflate.like + .setImageTintList(ContextCompat.getColorStateList(bfq.this, R.color.text)); com.muqingbfq.fragment.gd.like.remove(String.valueOf(bfqkz.xm.id)); } else { - like.setImageTintList(ContextCompat. + inflate.like.setImageTintList(ContextCompat. getColorStateList(bfq.this, android.R.color.holo_red_dark)); JSONObject json = new JSONObject(); json.put("name", bfqkz.xm.name); @@ -100,7 +90,11 @@ public class bfq extends AppCompatActivity { e.printStackTrace(); } }); - + if (bfqkz.xm != null) { + Media.setname(bfqkz.xm.name); + Media.setzz(bfqkz.xm.zz); + bfq_an.islike(); + } } public static Bitmap bitmap; diff --git a/app/src/main/java/com/muqingbfq/bfq_an.java b/app/src/main/java/com/muqingbfq/bfq_an.java index db8d64c..45def3a 100644 --- a/app/src/main/java/com/muqingbfq/bfq_an.java +++ b/app/src/main/java/com/muqingbfq/bfq_an.java @@ -95,7 +95,7 @@ public class bfq_an { public static String getTime(long time) { return simpleDateFormat.format(new Date(time)); } - public static void islike(Context context) { + public static void islike() { try { gd.like.getJSONObject(String.valueOf(bfqkz.xm.id)); bfqkz.like_bool = true; diff --git a/app/src/main/java/com/muqingbfq/fragment/Media.java b/app/src/main/java/com/muqingbfq/fragment/Media.java index 049ec4d..c1d8ccc 100644 --- a/app/src/main/java/com/muqingbfq/fragment/Media.java +++ b/app/src/main/java/com/muqingbfq/fragment/Media.java @@ -25,6 +25,7 @@ import com.muqingbfq.bfqkz; import com.muqingbfq.databinding.FragmentBfqBinding; import com.muqingbfq.home; import com.muqingbfq.main; +import com.muqingbfq.mq.gj; import org.json.JSONObject; @@ -171,13 +172,16 @@ public class Media extends Fragment { } public static void setlike(boolean bool) { - ImageView imageView = bfq.findViewById(R.id.like); + if (bfq == null || bfq.inflate == null) { + return; + } int color = R.color.text; if (bool) { color = android.R.color.holo_red_dark; } - imageView.setImageTintList(ContextCompat. - getColorStateList(view.getContext(), color)); + gj.sc(color); + bfq.inflate.like.setImageTintList(ContextCompat. + getColorStateList(com.muqingbfq.bfq.context, color)); } public static void setImageBitmap() {