更新了歌词组件支持更多操作

This commit is contained in:
muqing 2024-02-03 16:28:35 +08:00
parent 64e7336a71
commit 8a2bf60e93
7 changed files with 43 additions and 31 deletions

View File

@ -1,8 +1,6 @@
package com.muqingbfq.api;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import com.google.gson.Gson;
@ -112,8 +110,7 @@ public class playlist extends Thread {
String id = value.getName();
String name = mp3File.getTitle();
String zz = mp3File.getArtist();
String picUrl = mp3File.getUrl();
list.add(new MP3(id, name, zz, picUrl));
list.add(new MP3(id, name, zz, value.toString()));
}
return true;
} catch (Exception e) {
@ -175,11 +172,11 @@ public class playlist extends Thread {
e.printStackTrace();
}
} else if (a.isDirectory()) {
/* String string = a.getName();
String string = a.getName();
if (string.startsWith(".") || string.equals("Android") || string.equals("data")) {
continue;
}
CD(a, list);*/
CD(a, list);
}
}
}

View File

@ -11,6 +11,8 @@ import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@ -37,7 +39,6 @@ import java.util.List;
import java.util.Objects;
public class bfq extends AppCompatActivity<ActivityBfqBinding> {
public String lrc;
public MP3 mp3;
public boolean isplay = true;
@ -52,7 +53,7 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
layoutParams.width = main.k - 100;
binding.cardview.setLayoutParams(layoutParams);
binding.cardview.setOnClickListener((view) -> {
binding.fragmentBfq.setOnClickListener((view) -> {
if (binding.cardview.getVisibility() == View.VISIBLE) {
binding.cardview.setVisibility(View.GONE);
binding.lrcView.setVisibility(View.VISIBLE);
@ -61,7 +62,6 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
binding.lrcView.setVisibility(View.GONE);
}
});
binding.lrcView.setOnTapListener((view, x, y) -> {
if (binding.cardview.getVisibility() == View.VISIBLE) {
binding.cardview.setVisibility(View.GONE);
@ -108,16 +108,8 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
protected void UI(@Nullable Bundle savedInstanceState) {
// getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
setLrc();
binding.toolbar.setNavigationOnClickListener(view1 -> finish());
binding.toolbar.setOnMenuItemClickListener(item -> {
if (item.getItemId() == R.id.fx && bfqkz.xm != null) {
com.muqingbfq.mq.gj.fx(this,
"音乐名称:" + bfqkz.xm.name +
"\n 作者:" + bfqkz.xm.zz +
"\n 链接https://music.163.com/#/song?id=" + bfqkz.xm.id);
}
return false;
});
setSupportActionBar(binding.toolbar);
binding.kg.setOnClickListener(v -> {
if (bfqkz.mt.isPlaying()) {
bfqkz.mt.pause();
@ -173,6 +165,24 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
new thread().start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.bfq,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId()== R.id.fx && bfqkz.xm != null) {
com.muqingbfq.mq.gj.fx(this,
"音乐名称:" + bfqkz.xm.name +
"\n 作者:" + bfqkz.xm.zz +
"\n 链接https://music.163.com/#/song?id=" + bfqkz.xm.id);
} else if (item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
class thread extends Thread {
@Override
public void run() {
@ -235,8 +245,6 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
protected ActivityBfqBinding getViewBindingObject(LayoutInflater layoutInflater) {
return ActivityBfqBinding.inflate(layoutInflater);
}
public class Touch implements View.OnTouchListener {
private float downY;

View File

@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
@ -21,7 +20,6 @@ import androidx.media.MediaBrowserServiceCompat;
import com.muqingbfq.api.url;
import com.muqingbfq.mq.BluetoothMusicController;
import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
import java.util.ArrayList;
import java.util.List;
@ -60,13 +58,13 @@ public class bfqkz extends MediaBrowserServiceCompat {
return;
}
if (xm.picurl instanceof String) {
if (TextUtils.isEmpty(xm.picurl.toString())) {
if (TextUtils.isEmpty(xm.picurl)) {
xm.picurl = url.picurl(xm.id);
}
}
mt.setDataSource(mp3);
} catch (Exception e) {
yc.start(home.appCompatActivity, "bfqkz mp3(" + mp3.toString() + ") :" + e);
yc.start(home.appCompatActivity, "bfqkz mp3(" + mp3 + ") :" + e);
}
}

View File

@ -224,9 +224,10 @@ public class home extends com.muqingbfq.mq.AppCompatActivity<ActivityHomeBinding
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.home,menu);
getMenuInflater().inflate(R.menu.home, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_search) {

View File

@ -12,7 +12,6 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bfq"
app:navigationIcon="@drawable/end">
<LinearLayout
@ -64,6 +63,11 @@
android:id="@+id/lrcView"
android:layout_width="0dp"
android:layout_height="match_parent"
app:lrcTextSize="20sp"
app:lrcNormalTextSize="16sp"
app:lrcCurrentTextColor="@color/text"
app:lrcNormalTextColor="@color/text_tm"
app:lrcTimelineTextColor="@color/text"
app:layout_constraintStart_toEndOf="@id/cardview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"

View File

@ -12,7 +12,6 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bfq"
app:navigationIcon="@drawable/end">
<LinearLayout
@ -62,10 +61,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:lrcTextSize="20sp"
app:lrcNormalTextSize="16sp"
app:lrcCurrentTextColor="@color/text"
app:lrcNormalTextColor="@color/text_tm"
app:lrcTimelineTextColor="@color/text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout

View File

@ -33,8 +33,8 @@
<ImageView
android:id="@+id/img_logo"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="@drawable/icon" />