修复BUG优化UI

This commit is contained in:
muqing 2023-12-30 20:11:50 +08:00
parent 973157c1a8
commit 69c7cd15b9
23 changed files with 335 additions and 279 deletions

View File

@ -18,7 +18,7 @@ android {
//noinspection OldTargetApi
targetSdk 31
versionCode 1
versionName "1.7.8"
versionName "1.8.0"
}
compileOptions {

View File

@ -149,7 +149,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
BitmapFactory.decodeByteArray(albumImage, 0, albumImage.length);
}
} catch (Exception a) {
gj.sc(a);
gj.sc("yc:"+a);
}
bfqkz.notify.setBitmap();
return false;

View File

@ -90,10 +90,7 @@ public class MyButtonClickReceiver extends BroadcastReceiver {
return;
}
FloatingLyricsService lei = FloatingLyricsService.lei;
gj.sc(lei.setup.i);
if (lei.setup.i == 0) {
lei.show();
} else if (lei.setup.i == 1) {
if (lei.setup.i == 1) {
lei.setyc();
} else {
lei.setup.i = 0;
@ -102,6 +99,8 @@ public class MyButtonClickReceiver extends BroadcastReceiver {
new Intent(home.appCompatActivity, FloatingLyricsService.class));
}
break;
case "like":
break;
}
// 处理按钮点击事件的逻辑
}

View File

@ -2,19 +2,18 @@ package com.muqingbfq.api;
import android.text.TextUtils;
import com.muqingbfq.R;
import com.muqingbfq.main;
import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
import com.muqingbfq.mq.wl;
import com.muqingbfq.xm;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Iterator;
import java.util.List;
import com.muqingbfq.xm;
public class resource {
public static void recommend(List<xm> list) {
@ -54,6 +53,16 @@ public class resource {
}
}
public static xm Playlist_content(String UID) throws JSONException {
String hq = wl.get(main.api + "/playlist/detail?id=" + UID);
JSONObject js = new JSONObject(hq).getJSONObject("playlist");
String id = js.getString("id");
String name = js.getString("name");
String coverImgUrl = js.getString("coverImgUrl");
return new xm(id, name, coverImgUrl);
}
public static void 排行榜(List<xm> list) {
String hq;
try {
@ -78,9 +87,8 @@ public class resource {
if (!TextUtils.isEmpty(description) && !description.equals("null")) {
name += description;
}
boolean cz = wj.cz(wj.gd + id);
String coverImgUrl = get.getString("coverImgUrl");
list.add(new xm(id, name, coverImgUrl, cz));
list.add(new xm(id, name, coverImgUrl));
}
}
} catch (Exception e) {
@ -90,9 +98,8 @@ public class resource {
private static void add(JSONObject jsonObject, List<xm> list) throws Exception {
String id = jsonObject.getString("id");
boolean cz = wj.cz(wj.gd + id);
String name = jsonObject.getString("name");
String picUrl = jsonObject.getString("picUrl");
list.add(new xm(id, name, picUrl, cz));
list.add(new xm(id, name, picUrl));
}
}

View File

@ -12,6 +12,7 @@ import android.os.Bundle;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.LinearLayout;
@ -46,19 +47,13 @@ public class bfq extends AppCompatActivity {
public static String lrc;
public static com.muqingbfq.view.LrcView lrcView;
private void setLrc(){
lrcView = binding.lrcView;/*
lrcview.setCurrentColor(ContextCompat.getColor(this,R.color.text));
lrcview.setLabel(getString(R.string.app_name));
lrcview.setCurrentTextSize(TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics()));
// lrcView.setLrcPadding(16);
lrcview.setCurrentTextSize(TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()));
lrcview.setTimelineTextColor(ContextCompat.getColor(this,R.color.text_tm));
lrcview.setDraggable(true, (view, time) -> {
lrcView = binding.lrcView;
ViewGroup.LayoutParams layoutParams = binding.cardview.getLayoutParams();
layoutParams.height = main.k;
layoutParams.width = main.k;
binding.cardview.setLayoutParams(layoutParams);/*
bfqkz.mt.seekTo(Math.toIntExact(time));
return false;
});
if (!gj.isTablet(this)) {
lrcview.setOnTapListener((view, x, y) -> {
View kp = binding.kp1;

View File

@ -100,7 +100,7 @@ public class Media {
a = jsonObject.getJSONObject("lrc").getString("lyric");
b = jsonObject.getJSONObject("tlyric").getString("lyric");
} catch (Exception e) {
gj.sc(e);
gj.sc("Media loadLyric "+e);
}
LrcView.setLrc(a, b);
// bfq.lrcView.getLrc();

View File

@ -1,6 +1,8 @@
package com.muqingbfq.fragment;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@ -11,38 +13,47 @@ import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.muqingbfq.MP3;
import com.muqingbfq.R;
import com.muqingbfq.api.url;
import com.muqingbfq.bfqkz;
import com.muqingbfq.databinding.FragmentBflbDbBinding;
import com.muqingbfq.list.MyViewHoder;
import com.muqingbfq.main;
import com.muqingbfq.mq.gj;
import com.muqingbfq.xm;
import com.muqingbfq.yc;
public class bflb_db extends BottomSheetDialog {
public static RecyclerView.Adapter<MyViewHoder> adapter;
@SuppressLint("NotifyDataSetChanged")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_bflb_db);
FragmentBflbDbBinding binding = FragmentBflbDbBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
int height = main.g - main.g / 2 / 2;
getBehavior().setPeekHeight(height);
getBehavior().setMaxHeight(height);
try {
RecyclerView lb = findViewById(R.id.lb);
lb.setAdapter(new spq());
binding.lb.setAdapter(new spq());
if (bfqkz.xm != null) {
lb.smoothScrollToPosition(getI());
binding.lb.smoothScrollToPosition(getI());
}
findViewById(R.id.xxbj).
setOnClickListener(v -> {
binding.xxbj.setOnClickListener(v -> {
if (bfqkz.xm != null) {
lb.smoothScrollToPosition(getI());
binding.lb.smoothScrollToPosition(getI());
}
});
binding.sc.setOnClickListener(view -> {
new MaterialAlertDialogBuilder(getContext())
.setTitle("清空播放列表")
.setPositiveButton("确定", (dialogInterface, i) -> {
bfqkz.list.clear();
adapter.notifyDataSetChanged();
})
.setNegativeButton("取消", null)
.show();
});
} catch (Exception e) {
yc.start(getContext(), e);
}

View File

@ -14,31 +14,21 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.muqingbfq.MP3;
import com.muqingbfq.R;
import com.muqingbfq.api.playlist;
import com.muqingbfq.api.resource;
import com.muqingbfq.bfq_an;
import com.muqingbfq.bfqkz;
import com.muqingbfq.databinding.FragmentGdBinding;
import com.muqingbfq.databinding.FragmentMp3Binding;
import com.muqingbfq.list.MyViewHoder;
import com.muqingbfq.main;
import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
import com.muqingbfq.mq.wl;
import com.muqingbfq.view.CardImage;
import com.muqingbfq.xm;
import org.json.JSONArray;
@ -100,7 +90,7 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
String id = jsonObject.getString("id");
String name = jsonObject.getString("name");
String coverImgUrl = jsonObject.getString("coverImgUrl");
list.add(new xm(id, name, coverImgUrl, false));
list.add(new xm(id, name, coverImgUrl));
}
} catch (Exception e) {
gj.sc(e);
@ -110,7 +100,7 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
}
}
public static class baseadapter extends RecyclerView.Adapter<VH> {
public static class baseadapter extends RecyclerView.Adapter<VH>{
Context context;
List<xm> list;
@ -144,63 +134,14 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
@Override
public void onBindViewHolder(@NonNull VH holder, int position) {
xm xm = list.get(position);
holder.cardView.setOnClickListener(view -> {
Context context = view.getContext();
Intent intent = new Intent(context, mp3.class);
intent.putExtra("id", xm.id);
intent.putExtra("name", xm.name);
context.startActivity(intent);
});
holder.cardView.setOnLongClickListener(view -> {
String[] stringArray = view.getResources()
.getStringArray(R.array.gd_list);
new MaterialAlertDialogBuilder(view.getContext()).setItems(stringArray, (dialog, id) -> {
new Thread() {
@Override
public void run() {
if (id == 0) {
String hq = wl.hq(playlist.api + xm.id + "&limit=30");
if (hq != null) {
wj.xrwb(wj.gd + xm.id, hq);
xm.cz = true;
try {
JSONObject jsonObject = new JSONObject();
if (wj.cz(wj.gd_xz)) {
jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
CARD card = new CARD(xm);
if (bool) {
holder.itemView.setOnClickListener(card);
holder.itemView.setOnLongClickListener(card);
} else {
holder.image.setOnClickListener(card);
holder.image.setOnLongClickListener(card);
}
JSONObject json = new JSONObject();
json.put("name", xm.name);
json.put("picUrl", xm.picurl);
jsonObject.put(xm.id, json);
wj.xrwb(wj.gd_xz, jsonObject.toString());
} catch (JSONException e) {
gj.sc("list gd onclick thear " + e);
}
}
} else if (id == 2) {
wj.sc(wj.gd + xm.id);
if (xm.id.equals("mp3_xz.json")) {
wj.sc(new File(wj.mp3));
}
xm.cz = false;
try {
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
jsonObject.remove(xm.id);
list.remove(xm);
wj.xrwb(wj.gd_xz, jsonObject.toString());
} catch (JSONException e) {
gj.sc(e);
}
}
main.handler.post(() -> notifyDataSetChanged());
}
}.start();
// 在这里处理菜单项的点击事件
dialog.dismiss();
}).show();
return false;
});
holder.textView.setText(xm.name);
holder.kg.setOnClickListener(view1 -> {
ImageView tx = (ImageView) view1;
@ -228,8 +169,8 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
color_kg = ContextCompat.getDrawable(context, R.drawable.bf);
}
holder.kg.setImageDrawable(color_kg);
Glide.with(context).load(xm.picurl).apply(new RequestOptions().placeholder(R.drawable.icon))
.into(holder.imageView);
// xm.picurl
holder.image.setImageapply(xm.picurl);
}
@Override
@ -237,22 +178,99 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
return list.size();
}
class CARD implements View.OnClickListener
, View.OnLongClickListener {
xm xm;
public CARD(xm xm) {
this.xm = xm;
}
@Override
public void onClick(View view) {
Context context = view.getContext();
Intent intent = new Intent(context, mp3.class);
intent.putExtra("id", xm.id);
intent.putExtra("name", xm.name);
context.startActivity(intent);
}
@Override
public boolean onLongClick(View view) {
String[] stringArray = view.getResources()
.getStringArray(R.array.gd_list);
new MaterialAlertDialogBuilder(view.getContext()).setItems(stringArray, (dialog, id) -> {
new Thread() {
@Override
public void run() {
if (id == 0) {
String hq = wl.hq(playlist.api + xm.id + "&limit=100");
if (hq != null) {
wj.xrwb(wj.gd + xm.id, hq);
try {
JSONObject jsonObject = new JSONObject();
if (wj.cz(wj.gd_xz)) {
jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
}
xm fh=resource.Playlist_content(xm.id);
JSONObject json = new JSONObject();
json.put("name", fh.name);
json.put("picUrl", fh.picurl);
jsonObject.put(fh.id, json);
wj.xrwb(wj.gd_xz, jsonObject.toString());
main.handler.post(new sx());
} catch (JSONException e) {
gj.sc("list gd onclick thear " + e);
}
}
} else if (id == 2) {
wj.sc(wj.gd + xm.id);
if (xm.id.equals("mp3_xz.json")) {
wj.sc(new File(wj.mp3));
}
try {
JSONObject jsonObject = new JSONObject(Objects.requireNonNull(wj.dqwb(wj.gd_xz)));
jsonObject.remove(xm.id);
list.remove(xm);
wj.xrwb(wj.gd_xz, jsonObject.toString());
} catch (JSONException e) {
gj.sc(e);
}
}
main.handler.post(new sx());
}
}.start();
// 在这里处理菜单项的点击事件
dialog.dismiss();
}).show();
return false;
}
}
class sx implements Runnable {
@SuppressLint("NotifyDataSetChanged")
@Override
public void run() {
notifyDataSetChanged();
}
}
}
static class VH extends RecyclerView.ViewHolder {
TextView textView;
ImageView imageView, kg;
MaterialCardView cardView;
ImageView kg;
CardImage image;
public VH(@NonNull View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.wb1);
imageView = itemView.findViewById(R.id.fh);
cardView = itemView.findViewById(R.id.cardview);
image = itemView.findViewById(R.id.image);
kg = itemView.findViewById(R.id.kg);
}
}
private class lbspq_sx implements Runnable {
@SuppressLint("NotifyDataSetChanged")
@Override

View File

@ -125,6 +125,13 @@ public class search extends Fragment {
}
private void mp3() {
try {
Long.parseLong(name);
com.muqingbfq.api.playlist.hq(list, name);
return;
} catch (NumberFormatException e) {
gj.sc(e);
}
String hq = wl.hq("/search?keywords=" + name + "&type=1");
try {
JSONArray jsonArray = new JSONObject(hq).getJSONObject("result")
@ -154,8 +161,21 @@ public class search extends Fragment {
}
private void gd() {
String hq = wl.hq("/search?keywords=" + name + "&limit=" + (k * 3) + "&type=1000");
try {
Long.parseLong(name);
String hq = wl.hq("/playlist/detail?id=" + name);
JSONObject js = new JSONObject(hq).getJSONObject("playlist");
String id = js.getString("id");
String name = js.getString("name");
String coverImgUrl = js.getString("coverImgUrl");
// gj.sc(name);
xmList.add(new xm(id, name, coverImgUrl));
return;
} catch (Exception e) {
gj.sc(e);
}
try {
String hq = wl.hq("/search?keywords=" + name + "&limit=" + (k * 3) + "&type=1000");
JSONArray jsonArray = new JSONObject(hq).getJSONObject("result")
.getJSONArray("playlists");
int length = jsonArray.length();
@ -165,8 +185,7 @@ public class search extends Fragment {
String name = jsonObject.getString("name");
String coverImgUrl = jsonObject.getString("coverImgUrl");
// gj.sc(name);
xmList.add(new xm(id, name, coverImgUrl, false));
xmList.add(new xm(id, name, coverImgUrl));
}
} catch (Exception e) {
gj.sc(e);

View File

@ -148,11 +148,10 @@ public class wode extends Fragment {
JSONObject date = new JSONObject(wj.dqwb(wj.gd_xz));
for (Iterator<String> it = date.keys(); it.hasNext(); ) {
String id = it.next();
boolean cz = wj.cz(wj.gd + id);
JSONObject jsonObject = date.getJSONObject(id);
String name = jsonObject.getString("name");
String picUrl = jsonObject.getString("picUrl");
list.add(new xm(id, name, picUrl, cz));
list.add(new xm(id, name, picUrl));
}
main.handler.post(() -> binding.recyclerview2.getAdapter().notifyDataSetChanged());
} catch (Exception e) {

View File

@ -12,11 +12,13 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.muqingbfq.R;
import com.muqingbfq.bfq_an;
import com.muqingbfq.bfqkz;
import com.muqingbfq.databinding.FloatLrcviewBinding;
@ -52,9 +54,10 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
SETUP setup = gson.fromJson(dqwb, type);
return setup.i != 0;
} else {
return true;
return false;
}
}
Handler handler = new Handler();
LrcView lrcView;
WindowManager.LayoutParams params;
@ -67,8 +70,6 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
}
public SETUP setup = new SETUP();
File file;
public int lock() {
if (setup != null && setup.i == 2) {
return WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
@ -77,13 +78,12 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
return WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
}
@Override
public void onCreate() {
super.onCreate();
lei = this;
File file = new File(wj.filesdri + "FloatingLyricsService.json");
try {
file = new File(wj.filesdri + "FloatingLyricsService.json");
if (file.exists() && file.isFile()) {
String dqwb = wj.dqwb(file.toString());
Gson gson = new Gson();
@ -95,20 +95,15 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
setup.TOP = 0;
setup.Y = -main.g;
}
} catch (Exception e) {
wj.sc(file.toString());
gj.sc(e);
gj.sc(getClass() + ":" + e);
}
// 创建悬浮窗歌词的 View
// FloatLrcviewBinding
FloatLrcviewBinding binding = FloatLrcviewBinding.inflate(LayoutInflater.from(this));
layout = binding.getRoot();
layout.setOnTouchListener(this);
// ViewGroup.LayoutParams layoutParams = layout.getLayoutParams();
// layout.setLayoutParams(layoutParams);
// int i = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;FLAG_NOT_TOUCH_MODAL
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
@ -124,7 +119,7 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
lrcView = binding.lrcView;
bfq_an.kz bfqAn = new bfq_an.kz();
binding.kg.setOnClickListener(bfqAn);
binding.kg.setOnClickListener(this);
binding.syq.setOnClickListener(bfqAn);
binding.xyq.setOnClickListener(bfqAn);
binding.lock.setOnClickListener(this);
@ -140,7 +135,10 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
layout.findViewById(com.muqingbfq.R.id.controlLayout).setVisibility(View.GONE);
}
windowManager.addView(layout, params);
gj.sc("添加成功");
if (setup.i == 0) {
setup.i = 1;
}
baocun();
handler.post(updateSeekBar); // 在播放开始时启动更新进度
}
@ -163,8 +161,8 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
}
public void baocun() {
String s = new Gson().toJson(setup);
wj.xrwb(new File(wj.filesdri + "FloatingLyricsService.json").toString(), s);
wj.xrwb(new File(wj.filesdri + "FloatingLyricsService.json").toString(),
new Gson().toJson(setup));
}
private int initialY;
@ -196,7 +194,24 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.kg) {
ImageView kg = (ImageView) view;
if (bfqkz.mt == null) {
return;
}
if (bfqkz.mt.isPlaying()) {
bfqkz.mt.pause();
kg.setImageResource(R.drawable.zt);
} else {
bfqkz.mt.start();
kg.setImageResource(R.drawable.bf);
}
} else if (id==R.id.lock) {
setyc();
} else if (id == R.id.like) {
// bfq
}
}
public void setyc() {

View File

@ -1,11 +1,11 @@
package com.muqingbfq.view;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.card.MaterialCardView;
import com.muqingbfq.R;
@ -37,6 +37,15 @@ public class CardImage extends MaterialCardView {
public void setImage(Object bitmap) {
Glide.with(getContext())
.load(bitmap)
// .apply(new RequestOptions().placeholder(R.drawable.icon))
.into(imageView);
}
public void setImageapply(Object bitmap) {
Glide.with(getContext())
.load(bitmap)
.apply(new RequestOptions().placeholder(R.drawable.icon))
// .error(R.drawable.app_warning)
.into(imageView);
}
}

View File

@ -3,21 +3,15 @@ package com.muqingbfq.view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.view.ViewTreeObserver;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -28,17 +22,12 @@ import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import com.muqingbfq.R;
import com.muqingbfq.main;
import com.muqingbfq.mq.gj;
import com.muqingbfq.yc;
import java.util.ArrayList;
import java.util.List;
public class LrcView extends RecyclerView {
private void sc(Object obj) {
gj.sc("LRC " + obj);
}
static List<lrc> lrclist = new ArrayList<>();
@ -91,10 +80,11 @@ public class LrcView extends RecyclerView {
TextColor = ta.getColor(R.styleable.LrcView_TextColor,
ContextCompat.getColor(getContext(), R.color.text));
Lrcline = ta.getBoolean(R.styleable.LrcView_Lrcline, true);
addOnGlobalLayoutListener = ta.
getBoolean(R.styleable.LrcView_addOnGlobalLayoutListener, false);
ta.recycle();
}
linearLayoutManager = new LinearLayoutManager(getContext()) {
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
RecyclerView.SmoothScroller smoothScroller = new CenterSmoothScroller(recyclerView.getContext());
@ -108,9 +98,9 @@ public class LrcView extends RecyclerView {
setForeground(null);
setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
if (!Lrcline) {
addItemDecoration( new RecyclerView.ItemDecoration() {
addItemDecoration(new RecyclerView.ItemDecoration() {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
super.getItemOffsets(outRect, view, parent, state);
int parentHeight = parent.getHeight();
@ -166,7 +156,6 @@ public class LrcView extends RecyclerView {
long time = (long) minute * 60 * 1000 + second * 1000L + millisecond;
int currentLineIndex = getCurrentLineIndex(time);
lrclist.set(currentLineIndex, lrclist.get(currentLineIndex).setTlyric(lyric));
// gj.sc(lyric);
}
}
}
@ -195,13 +184,15 @@ public class LrcView extends RecyclerView {
int millisecond = Integer.parseInt(secondParts[1]);
long time = (long) minute * 60 * 1000 + second * 1000L + millisecond;
lrclist.add(new lrc(lyric, time));
// gj.sc(lyric);
}
}
}
}
}
int index = -1;
boolean addOnGlobalLayoutListener;
class adaper extends RecyclerView.Adapter<VH> {
@NonNull
@ -218,11 +209,26 @@ public class LrcView extends RecyclerView {
@Override
public void onBindViewHolder(@NonNull VH holder, int position) {
if (Lrcline) {
if (addOnGlobalLayoutListener) {
// 注册布局监听器
holder.textView.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int height = holder.textView.getHeight();
ViewGroup.LayoutParams layoutParams = LrcView.this.getLayoutParams();
layoutParams.height = height * 5;
LrcView.this.setLayoutParams(layoutParams);
// 移除布局监听器
holder.textView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}
if (lrclist.isEmpty()) {
holder.textView.setText("纯音乐,请欣赏");
return;
}
if (Lrcline) {
int currentLineIndex = getCurrentLineIndex();
if (currentLineIndex >= 0 && currentLineIndex < lrclist.size()) {
@ -244,6 +250,10 @@ public class LrcView extends RecyclerView {
holder.textView.setText(text);
}
} else {
if (lrclist.isEmpty()) {
holder.textView.setText("纯音乐,请欣赏");
return;
}
try {
lrc lrc = lrclist.get(position);
StringBuilder stringBuffer = new StringBuilder();
@ -265,7 +275,6 @@ public class LrcView extends RecyclerView {
@Override
public int getItemCount() {
gj.sc(lrclist.size());
if (lrclist.size() < 3) {
for (lrc a : lrclist) {
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
@ -291,14 +300,9 @@ public class LrcView extends RecyclerView {
textView = itemView.findViewById(R.id.text);
}
}
/* @Override
public void onDraw(@NonNull Canvas canvas) {
super.onDraw(canvas);
setTimeLrc(canvas);
}*/
private int getCurrentLineIndex() {
int index = -1;
index = -1;
for (int i = 0; i < lrclist.size(); i++) {
lrc lineLrc = lrclist.get(i);
if (lineLrc.time <= time) {
@ -311,7 +315,7 @@ public class LrcView extends RecyclerView {
}
private static int getCurrentLineIndex(long time) {
int index = -1;
int index = 0;
for (int i = 0; i < lrclist.size(); i++) {
lrc lineLrc = lrclist.get(i);
if (lineLrc.time <= time) {
@ -331,22 +335,15 @@ public class LrcView extends RecyclerView {
this.time = a;
if (!Lrcline) {
int currentLineIndex = getCurrentLineIndex(a);
if (currentLineIndex == -1) {
getAdapter().notifyDataSetChanged();
if (currentLineIndex < 3) {
return;
}
// smoothScrollToPosition(getCurrentLineIndex(a));
linearLayoutManager.smoothScrollToPosition(this,
new RecyclerView.State(), currentLineIndex);
// smoothScrollToPosition(getCurrentLineIndex(a));
getAdapter().notifyItemChanged(--currentLineIndex);
getAdapter().notifyItemChanged(getCurrentLineIndex(a));
return;
}
getAdapter().notifyDataSetChanged();
}
public void getLrc() {
for (lrc a : lrclist) {
sc(a.time + ":" + a.lrc + ":" + a.tlyric);
}
}
}

View File

@ -1,25 +1,16 @@
package com.muqingbfq;
public class xm {
public String id, name, zz;
public String id, name;
public Object picurl;
public boolean cz;
public xm(String id, String name, String zz, String picurl) {
public xm(String id, String name, String picurl) {
this.id = id;
this.name = name;
this.zz = zz;
this.picurl = picurl;
}
public xm(String id, String name, String picurl, boolean cz) {
public xm(String id, String name, int picurl) {
this.id = id;
this.name = name;
this.picurl = picurl;
this.cz = cz;
}
public xm(String id, String name, int picurl, boolean cz) {
this.id = id;
this.name = name;
this.picurl = picurl;
this.cz = cz;
}
}

View File

@ -30,9 +30,10 @@
<TextView
android:id="@+id/zz"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:maxLines="1"
android:gravity="center_horizontal"
android:text="@string/zz"
android:textSize="20sp" />
</LinearLayout>

View File

@ -29,9 +29,10 @@
<TextView
android:id="@+id/zz"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:maxLines="1"
android:gravity="center_horizontal"
android:text="@string/zz"
android:textSize="20sp" />
</LinearLayout>
@ -66,7 +67,8 @@
<com.muqingbfq.view.LrcView
android:id="@+id/lrcView"
android:layout_width="match_parent"
android:layout_height="260dp"
android:layout_height="wrap_content"
app:addOnGlobalLayoutListener="true"
android:layout_weight="2"/>
</LinearLayout>
</LinearLayout>

View File

@ -27,51 +27,56 @@
android:layout_height="36dp"
android:src="@drawable/like"
android:text="喜欢"
android:tint="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UseAppTint" />
<ImageView
android:id="@+id/syq"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/syq"
android:tint="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/kg"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
tools:ignore="ContentDescription,UseAppTint" />
<ImageView
android:id="@+id/kg"
android:layout_width="46dp"
android:layout_height="46dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:tint="@color/white"
android:src="@drawable/zt"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
tools:ignore="ContentDescription,UseAppTint" />
<ImageView
android:id="@+id/xyq"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/xyq"
android:tint="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/kg"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UseAppTint" />
<Button
<ImageView
android:id="@+id/lock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="锁定"
android:src="@drawable/lock"
android:tint="@color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
tools:ignore="UseAppTint" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -5,38 +5,20 @@
android:layout_width="120dp"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:background="@null">
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="120dp"
android:layout_height="120dp">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardview"
<com.muqingbfq.view.CardImage
android:id="@+id/image"
android:layout_width="120dp"
android:layout_height="120dp"
app:cardUseCompatPadding="true">
<ImageView
android:id="@+id/fh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id="@+id/kg"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_alignEnd="@id/cardview"
android:layout_alignBottom="@id/cardview"
android:layout_marginEnd="6dp"
android:layout_marginBottom="6dp"
android:src="@drawable/zt"
tools:ignore="RtlSymmetry" />
</RelativeLayout>
android:layout_gravity="bottom|end"
android:src="@drawable/zt"/>
</com.muqingbfq.view.CardImage>
<TextView
android:id="@+id/wb1"
@ -46,5 +28,5 @@
android:lines="2"
android:maxLines="2"
android:text="@string/name"
android:textColor="@color/text"/>
android:textColor="@color/text" />
</LinearLayout>

View File

@ -1,32 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:orientation="horizontal">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cardview"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.muqingbfq.view.CardImage
android:id="@+id/image"
android:layout_width="120dp"
android:layout_height="120dp"
app:cardUseCompatPadding="true">
<ImageView
android:id="@+id/fh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
app:cardUseCompatPadding="true"
android:padding="16dp">
<ImageView
android:id="@+id/kg"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginEnd="6dp"
android:layout_marginBottom="6dp"
android:layout_gravity="bottom|end"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:src="@drawable/zt"/>
</com.google.android.material.card.MaterialCardView>
</com.muqingbfq.view.CardImage>
<TextView
android:id="@+id/wb1"
android:layout_width="wrap_content"
@ -37,4 +30,5 @@
android:maxLines="2"
android:text="@string/name"
android:textColor="@color/text" />
</LinearLayout>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

View File

@ -7,5 +7,14 @@
&lt;!&ndash; Secondary brand color. &ndash;&gt;
<item name="colorOnSecondary">@color/text</item>-->
<item name="android:windowLightStatusBar">false</item>
<item name="android:colorPrimary">@color/bj_tint</item>
<item name="colorPrimaryDark">@color/bj_tint</item>
<item name="tabStyle">@style/Widget.App.TabLayout</item>
<item name="toolbarStyle">@style/Widget.App.Toolbar</item>
</style>
<!--
<style name="ThemeOverlay.App.TabLayout" parent="">
<item name="colorPrimary">@color/bj_tint</item>
</style>-->
</resources>

View File

@ -4,5 +4,6 @@
<!--声明MyTextView需要使用系统定义过的text属性,注意前面需要加上android命名-->
<attr name="TextColor" format="color" />
<attr name="Lrcline" format="boolean" />
<attr name="addOnGlobalLayoutListener" format="boolean" />
</declare-styleable>
</resources>

View File

@ -15,5 +15,6 @@
<color name="tm">#00FFFFFF</color>
<color name="bj">#F2ECF6</color>
<color name="button_bj">#B3E5FC</color>
<!-- <color name="button_bj">@color/bj</color>-->
<color name="bj_tint">#FFCCCC</color>
</resources>

View File

@ -15,34 +15,35 @@
<!-- <item name="android:colorControlActivated">#FF7F50</item>-->
<!-- 设置文本颜色 -->
<item name="android:textColorPrimary">@color/text</item>
<item name="android:colorPrimary">#00BCD4</item>
<item name="colorPrimaryDark">#8000BCD4</item>
<item name="android:colorPrimary">@color/bj</item>
<item name="colorPrimaryDark">@color/bj</item>
<item name="tabStyle">@style/Widget.App.TabLayout</item>
<item name="toolbarStyle">@style/Widget.App.Toolbar</item>
</style>
<style name="Widget.App.Toolbar" parent="Widget.Material3.Toolbar">
<item name="android:background">@drawable/background</item>
<item name="materialThemeOverlay">@style/ThemeOverlay.App.Toolbar</item>
</style>
<style name="ThemeOverlay.App.Toolbar" parent="">
<item name="colorSurface">@color/bj</item>
<item name="colorOnSurface">@color/bj</item>
</style>
<style name="ThemeOverlay.App.TabLayout" parent="">
<item name="colorPrimary">@color/bj_tint</item>
<item name="colorSurface">@color/bj</item>
<!-- <item name="colorOnSurface">@color/bj_tint</item>-->
</style>
<style name="Widget.App.TabLayout" parent="Widget.Material3.TabLayout">
<item name="materialThemeOverlay">@style/ThemeOverlay.App.TabLayout</item>
<!-- <item name="tabTextAppearance">@style/TextAppearance.App.LabelLarge</item>-->
</style>
<style name="ThemeOverlay.App.TabLayout" parent="">
<item name="colorPrimary">#00BCD4</item>
<item name="colorOnSurface">#ADD8E6</item>
<style name="Widget.App.Toolbar" parent="Widget.Material3.Toolbar">
<item name="android:background">@drawable/background</item>
<item name="materialThemeOverlay">@style/ThemeOverlay.App.Toolbar</item>
</style>
<style name="fragment_dialog" parent="Theme.muqing">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
@ -62,7 +63,7 @@
<!-- 按钮主题-->
<style name="Button">
<item name="android:backgroundTint">#1C71A9</item>
<item name="android:textColor">@color/text</item>
<item name="android:backgroundTint">@color/bj</item>
</style>
</resources>