修复BUG,更新UI

This commit is contained in:
muqing 2024-02-04 16:44:44 +08:00
parent 8a2bf60e93
commit 847d857fee
16 changed files with 212 additions and 233 deletions

View File

@ -18,7 +18,7 @@ android {
//noinspection ExpiredTargetSdkVersion,OldTargetApi //noinspection ExpiredTargetSdkVersion,OldTargetApi
targetSdk 31 targetSdk 31
versionCode 1 versionCode 1
versionName "1.9.7" versionName "1.9.9"
} }
compileOptions { compileOptions {

View File

@ -50,9 +50,7 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".login.enroll" />
<activity android:name=".login.user_logs" /> <activity android:name=".login.user_logs" />
<activity android:name=".login.user_editing" />
<activity android:name=".clean.fragment_clean" /> <activity android:name=".clean.fragment_clean" />
<activity android:name=".activity_search" /> <activity android:name=".activity_search" />
<activity <activity
@ -66,7 +64,6 @@
<activity android:name=".sz" /> <activity android:name=".sz" />
<activity android:name=".mq.llq" /> <activity android:name=".mq.llq" />
<activity android:name=".yc" /> <activity android:name=".yc" />
<activity android:name=".login.cookie" />
<service <service
android:name=".bfqkz" android:name=".bfqkz"

View File

@ -17,7 +17,6 @@ import com.mpatric.mp3agic.ID3v2;
import com.mpatric.mp3agic.Mp3File; import com.mpatric.mp3agic.Mp3File;
import com.muqingbfq.fragment.bflb_db; import com.muqingbfq.fragment.bflb_db;
import com.muqingbfq.fragment.mp3; import com.muqingbfq.fragment.mp3;
import com.muqingbfq.fragment.search;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj; import com.muqingbfq.mq.wj;
@ -58,6 +57,10 @@ public class MediaPlayer extends android.media.MediaPlayer {
super.pause(); super.pause();
// bfq.isPlaying = false; // bfq.isPlaying = false;
} }
if (bfqkz.notify != null) {
bfqkz.notify.tzl_button();
}
} }
@Override @Override
@ -69,6 +72,10 @@ public class MediaPlayer extends android.media.MediaPlayer {
return; return;
} }
super.start(); super.start();
if (bfqkz.notify != null) {
bfqkz.notify.tzl_button();
}
// bfq.isPlaying = true; // bfq.isPlaying = true;
} }
@ -154,9 +161,6 @@ public class MediaPlayer extends android.media.MediaPlayer {
if (bflb_db.adapter != null) { if (bflb_db.adapter != null) {
bflb_db.adapter.notifyDataSetChanged(); bflb_db.adapter.notifyDataSetChanged();
} }
if (search.lbspq != null) {
search.lbspq.notifyDataSetChanged();
}
if (mp3.adapter != null) { if (mp3.adapter != null) {
mp3.adapter.notifyDataSetChanged(); mp3.adapter.notifyDataSetChanged();
} }

View File

@ -201,12 +201,8 @@ public class activity_search extends FragmentActivity<ActivitySearchBinding> {
dismiss(); dismiss();
if (!TextUtils.isEmpty(name)) { if (!TextUtils.isEmpty(name)) {
search sea = (search) getSupportFragmentManager().findFragmentById(R.id.search_fragment); search sea = (search) getSupportFragmentManager().findFragmentById(R.id.search_fragment);
if (!name.equals(sea.name)) { binding.searchFragment.setVisibility(View.VISIBLE);
sea.i = 0; sea.sx(name);
sea.binding.tablayout.getTabAt(0).select();
}
sea.setVisibility(true);
sea.setStart(name);
addSearchRecord(name); addSearchRecord(name);
} }
} }
@ -300,10 +296,8 @@ public class activity_search extends FragmentActivity<ActivitySearchBinding> {
binding.searchRecycler.setVisibility(View.GONE); binding.searchRecycler.setVisibility(View.GONE);
return; return;
} }
search search = (com.muqingbfq.fragment.search) getSupportFragmentManager(). if (binding.searchFragment.getVisibility()==View.VISIBLE) {
findFragmentById(R.id.search_fragment); binding.searchFragment.setVisibility(View.GONE);
if (search.isVisible()) {
search.setVisibility(false);
} else { } else {
finish(); finish();
} }
@ -312,6 +306,5 @@ public class activity_search extends FragmentActivity<ActivitySearchBinding> {
@Override @Override
public void finish() { public void finish() {
super.finish(); super.finish();
com.muqingbfq.fragment.search.lbspq = null;
} }
} }

View File

@ -47,14 +47,6 @@ public class FileDownloader {
.show(); .show();
}); });
} }
String file_url = wj.mp3;
public FileDownloader(String x,MP3 mp3,boolean hc) {
if (hc) {
file_url = wj.filesdri + "hc/";
}
downloadFile(x,mp3);
}
public void downloadFile(MP3 x) { public void downloadFile(MP3 x) {
Request request = new Request.Builder() Request request = new Request.Builder()
.url(main.api + url.api + "?id=" + x.id + "&level=" + .url(main.api + url.api + "?id=" + x.id + "&level=" +
@ -106,7 +98,7 @@ public class FileDownloader {
// 下载失败处理 // 下载失败处理
return; return;
} }
File outputFile = new File(file_url, x.id + ".mp3"); File outputFile = new File(wj.mp3, x.id + ".mp3");
File parentFile = outputFile.getParentFile(); File parentFile = outputFile.getParentFile();
if (!parentFile.isDirectory()) { if (!parentFile.isDirectory()) {
parentFile.mkdirs(); parentFile.mkdirs();
@ -153,7 +145,7 @@ public class FileDownloader {
} }
} }
o.close(); o.close();
mp3file.save(file_url + x.id); mp3file.save(wj.mp3 + x.id);
outputFile.delete(); outputFile.delete();
} }
// 保存修改后的音乐文件删除原来的文件 // 保存修改后的音乐文件删除原来的文件

View File

@ -5,7 +5,6 @@ import android.content.Intent;
import com.mpatric.mp3agic.ID3v2; import com.mpatric.mp3agic.ID3v2;
import com.mpatric.mp3agic.Mp3File; import com.mpatric.mp3agic.Mp3File;
import com.muqingbfq.MP3; import com.muqingbfq.MP3;
import com.muqingbfq.bfq;
import com.muqingbfq.fragment.Media; import com.muqingbfq.fragment.Media;
import com.muqingbfq.home; import com.muqingbfq.home;
import com.muqingbfq.login.user_logs; import com.muqingbfq.login.user_logs;
@ -31,6 +30,7 @@ public class url extends Thread {
public static MP3 hq(MP3 x) { public static MP3 hq(MP3 x) {
// gj.sc(x.id); // gj.sc(x.id);
getLrc(x.id); getLrc(x.id);
Media.loadLyric();
try { try {
if (wj.cz(x.id)) { if (wj.cz(x.id)) {
x.url = x.id; x.url = x.id;

View File

@ -348,9 +348,6 @@ public class bfq extends AppCompatActivity<ActivityBfqBinding> {
//暂停 //暂停
kgsetImageResource(R.drawable.zt); kgsetImageResource(R.drawable.zt);
} }
if (bfqkz.notify != null) {
bfqkz.notify.tzl_button();
}
isPlaying = bool; isPlaying = bool;
} }

View File

@ -19,8 +19,8 @@ public class Media {
} catch (Exception e) { } catch (Exception e) {
gj.sc("Media loadLyric "+e); gj.sc("Media loadLyric "+e);
} }
me.wcy.lrcview.LrcView.Lrc(a, b);
return new String[]{a, b}; return new String[]{a, b};
// LrcView.setLrc(a, b);
// bfq.lrcView.getLrc(); // bfq.lrcView.getLrc();
// bfq.lrcView.loadLrc(a, b); // bfq.lrcView.loadLrc(a, b);
} }

View File

@ -3,6 +3,7 @@ package com.muqingbfq.fragment;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -21,7 +22,6 @@ import com.muqingbfq.bfq_an;
import com.muqingbfq.bfqkz; import com.muqingbfq.bfqkz;
import com.muqingbfq.databinding.FragmentBfqDbBinding; import com.muqingbfq.databinding.FragmentBfqDbBinding;
import com.muqingbfq.main; import com.muqingbfq.main;
import com.muqingbfq.mq.gj;
import java.util.Objects; import java.util.Objects;
@ -69,17 +69,17 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
main.handler.post(runnable); handler.post(runnable);
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
main.handler.removeCallbacks(runnable); handler.removeCallbacks(runnable);
} }
MP3 mp3; MP3 mp3;
boolean isPlaying = false; boolean isPlaying = false;
Handler handler = new Handler();
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -90,7 +90,7 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
if (bfqkz.mt != null && bfqkz.mt.isPlaying() != isPlaying) { if (bfqkz.mt != null && bfqkz.mt.isPlaying() != isPlaying) {
setkg(bfqkz.mt.isPlaying()); setkg(bfqkz.mt.isPlaying());
} }
main.handler.postDelayed(this, 1000); handler.postDelayed(this, 1000);
} }
}; };

View File

@ -10,13 +10,13 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.viewpager2.adapter.FragmentStateAdapter;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayoutMediator;
import com.muqingbfq.MP3; import com.muqingbfq.MP3;
import com.muqingbfq.XM; import com.muqingbfq.XM;
import com.muqingbfq.databinding.FragmentSearchBinding; import com.muqingbfq.databinding.FragmentSearchBinding;
import com.muqingbfq.list.MyViewHoder; import com.muqingbfq.databinding.RecyclerVBinding;
import com.muqingbfq.main; import com.muqingbfq.main;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wl; import com.muqingbfq.mq.wl;
@ -29,110 +29,126 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class search extends Fragment { public class search extends Fragment {
public static RecyclerView.Adapter<MyViewHoder> lbspq;
List<MP3> list = new ArrayList<>();
List<XM> xmList = new ArrayList<>();
public String name;
public FragmentSearchBinding binding; public FragmentSearchBinding binding;
public int i = 0; public static String string;
List<Fragment> fragments = new ArrayList<>();
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) { @Nullable Bundle savedInstanceState) {
binding = FragmentSearchBinding.inflate(inflater, container, false); binding = FragmentSearchBinding.inflate(inflater, container, false);
lbspq = new mp3.Adapter(list);
binding.tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { binding.viewPager.setAdapter(new FragmentStateAdapter(this) {
@NonNull
@Override @Override
public void onTabSelected(TabLayout.Tab tab) { public Fragment createFragment(int position) {
// 当用户再次选择已选择的选项卡时调用 return fragments.get(position);
search.this.i = tab.getPosition();
setStart(name);
} }
@Override @Override
public void onTabUnselected(TabLayout.Tab tab) { public int getItemCount() {
// 当选项卡退出选定状态时调用 return fragments.size();
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
// 当选项卡进入选定状态时调用
} }
}); });
setVisibility(false);
return binding.getRoot(); return binding.getRoot();
} }
public void setVisibility(boolean bool) { public static class mp3 extends Fragment {
if (bool) { List<MP3> list = new ArrayList<>();
binding.getRoot().setVisibility(View.VISIBLE); RecyclerVBinding binding;
} else {
binding.getRoot().setVisibility(View.GONE);
}
}
public int k; @Nullable
@Override
public void setStart(String name) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
if (i == 0) { binding = RecyclerVBinding.inflate(inflater, container, false);
new mp3.Adapter(list); binding.recycleview.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recyclerview.setLayoutManager(new LinearLayoutManager(getContext())); binding.recycleview.setAdapter(new com.muqingbfq.fragment.mp3.Adapter(list));
binding.recyclerview.setAdapter(lbspq);
} else if (i == 1) {
k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f) / 120;
binding.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recyclerview.setAdapter(new gd.baseadapter(getContext(),
xmList, true));
}
new start(name);
}
public class start extends Thread {
public start(String name) {
binding.recyclerview1Bar.setVisibility(View.VISIBLE);
list.clear();
xmList.clear();
search.this.name = name;
start(); start();
return binding.getRoot();
} }
boolean load = false;
private void start() {
list.clear();
if (binding == null) {
return;
}
binding.recyclerviewBar.setVisibility(View.VISIBLE);
binding.recyclerviewText.setVisibility(View.GONE);
new Thread() {
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@Override @Override
public void run() { public void run() {
super.run(); super.run();
if (i == 0) { mp3(list, string);
mp3();
load = !list.isEmpty();
} else if (i == 1) {
gd();
load = !xmList.isEmpty();
}
main.handler.post(() -> { main.handler.post(() -> {
binding.recyclerview.getAdapter().notifyDataSetChanged(); binding.recyclerviewBar.setVisibility(View.GONE);
binding.recyclerview1Bar.setVisibility(View.GONE); if (list.isEmpty()) {
if (load) { binding.recyclerviewText.setVisibility(View.VISIBLE);
binding.recyclerview1Text.setVisibility(View.GONE);
} else { } else {
binding.recyclerview1Text.setVisibility(View.VISIBLE); binding.recyclerviewText.setVisibility(View.GONE);
} }
binding.recycleview.getAdapter().notifyDataSetChanged();
}); });
} }
}.start();
}
} }
private void mp3() { public static class gd extends Fragment {
List<XM> list = new ArrayList<>();
RecyclerVBinding binding;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = RecyclerVBinding.inflate(inflater, container, false);
binding.recycleview.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recycleview.setAdapter(new com.muqingbfq.fragment.gd.baseadapter(getContext(),
list, true));
list.clear();
binding.recyclerviewBar.setVisibility(View.VISIBLE);
binding.recyclerviewText.setVisibility(View.GONE);
new Thread() {
@SuppressLint("NotifyDataSetChanged")
@Override
public void run() {
super.run();
gd(list, string);
main.handler.post(() -> {
binding.recyclerviewBar.setVisibility(View.GONE);
if (list.isEmpty()) {
binding.recyclerviewText.setVisibility(View.VISIBLE);
} else {
binding.recyclerviewText.setVisibility(View.GONE);
}
binding.recycleview.getAdapter().notifyDataSetChanged();
});
}
}.start();
return binding.getRoot();
}
}
public void sx(String string) {
search.string = string;
fragments.add(new mp3());
fragments.add(new gd());
String[] strtab = new String[]{"歌曲", "歌单"};
//将tabbView绑定到tab
new TabLayoutMediator(binding.tablayout, binding.viewPager, (tab, position) ->
tab.setText(strtab[position])).attach();
}
private static void mp3(List<MP3> list, String str) {
try { try {
Long.parseLong(name); Long.parseLong(str);
com.muqingbfq.api.playlist.hq(list, name); com.muqingbfq.api.playlist.hq(list, str);
return; return;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
gj.sc(e); gj.sc(e);
} }
String hq = wl.hq("/search?keywords=" + name + "&type=1"); String hq = wl.hq("/search?keywords=" + str + "&type=1");
try { try {
JSONArray jsonArray = new JSONObject(hq).getJSONObject("result") JSONArray jsonArray = new JSONObject(hq).getJSONObject("result")
.getJSONArray("songs"); .getJSONArray("songs");
@ -160,22 +176,22 @@ public class search extends Fragment {
} }
} }
private void gd() { private static void gd(List<XM> list, String str) {
try { try {
Long.parseLong(name); Long.parseLong(str);
String hq = wl.hq("/playlist/detail?id=" + name); String hq = wl.hq("/playlist/detail?id=" + str);
JSONObject js = new JSONObject(hq).getJSONObject("playlist"); JSONObject js = new JSONObject(hq).getJSONObject("playlist");
String id = js.getString("id"); String id = js.getString("id");
String name = js.getString("name"); String name = js.getString("name");
String coverImgUrl = js.getString("coverImgUrl"); String coverImgUrl = js.getString("coverImgUrl");
// gj.sc(name); // gj.sc(name);
xmList.add(new XM(id, name, coverImgUrl)); list.add(new XM(id, name, coverImgUrl));
return; return;
} catch (Exception e) { } catch (Exception e) {
gj.sc(e); gj.sc(e);
} }
try { try {
String hq = wl.hq("/search?keywords=" + name +"&type=1000"); String hq = wl.hq("/search?keywords=" + str + "&type=1000");
JSONArray jsonArray = new JSONObject(hq).getJSONObject("result") JSONArray jsonArray = new JSONObject(hq).getJSONObject("result")
.getJSONArray("playlists"); .getJSONArray("playlists");
int length = jsonArray.length(); int length = jsonArray.length();
@ -196,52 +212,10 @@ public class search extends Fragment {
+ "by " + jsonObject.getJSONObject("creator").getString("nickname") + "by " + jsonObject.getJSONObject("creator").getString("nickname")
+ ",播放" + ",播放"
+ formattedNumber + ""; + formattedNumber + "";
xmList.add(new XM(id, name, s, coverImgUrl)); list.add(new XM(id, name, s, coverImgUrl));
} }
} catch (Exception e) { } catch (Exception e) {
gj.sc(e); gj.sc(e);
} }
} }
/*
class spq extends RecyclerView.Adapter<MyViewHoder> {
public spq() {
lbspq = this;
}
@NonNull
@Override
public MyViewHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new MyViewHoder(ListMp3Binding.
inflate(getLayoutInflater(),parent,false));
}
@Override
public void onBindViewHolder(@NonNull MyViewHoder holder, int position) {
MP3 x = list.get(position);
holder.binding.name.setText(x.name);
holder.binding.zz.setText(x.zz);
int color = ContextCompat.getColor(holder.getContext(), R.color.text);
if (bfqkz.xm != null && x.id.equals(bfqkz.xm.id)) {
color = ContextCompat.getColor(holder.getContext(), R.color.text_cz);
}
holder.binding.name.setTextColor(color);
holder.binding.zz.setTextColor(color);
holder.itemView.setOnClickListener(view1 -> {
if (bfqkz.xm == null || !bfqkz.xm.id.equals(x.id)) {
bfqkz.xm = x;
new url(x);
}
// if (!com.muqingbfq.fragment.gd.gdid.equals(bflb_db.gdid)) {
gd.gdid = null;
bfqkz.list.clear();
bfqkz.list.addAll(list);
bfq.start(search.this.getContext());
});
}
@Override
public int getItemCount() {
return list.size();
}
}*/
} }

View File

@ -13,13 +13,13 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter; import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2; import androidx.viewpager2.widget.ViewPager2;
import com.jaeger.library.StatusBarUtil;
import com.muqingbfq.databinding.ActivityHomeBinding; import com.muqingbfq.databinding.ActivityHomeBinding;
import com.muqingbfq.fragment.bfq_db; import com.muqingbfq.fragment.bfq_db;
import com.muqingbfq.fragment.gd_adapter; import com.muqingbfq.fragment.gd_adapter;
@ -46,6 +46,7 @@ public class home extends com.muqingbfq.mq.AppCompatActivity<ActivityHomeBinding
appCompatActivity = this; appCompatActivity = this;
setTheme(R.style.Theme_muqing); setTheme(R.style.Theme_muqing);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
StatusBarUtil.setTransparent(this);
setContentView(getViewBinding().getRoot()); setContentView(getViewBinding().getRoot());
// binding.toolbar.setPadding(0, gj.getztl(this), 0, 0); // binding.toolbar.setPadding(0, gj.getztl(this), 0, 0);
DisplayMetrics dm = getResources().getDisplayMetrics(); DisplayMetrics dm = getResources().getDisplayMetrics();
@ -80,11 +81,6 @@ public class home extends com.muqingbfq.mq.AppCompatActivity<ActivityHomeBinding
} }
} }
@Override
protected void UI(@Nullable Bundle savedInstanceState) {
}
public static ComponentName componentName; public static ComponentName componentName;
private class Adaper extends FragmentStateAdapter { private class Adaper extends FragmentStateAdapter {

View File

@ -26,5 +26,7 @@ public abstract class AppCompatActivity<ViewBindingType extends ViewBinding> ext
UI(savedInstanceState); UI(savedInstanceState);
} }
protected abstract void UI(@Nullable Bundle savedInstanceState); protected void UI(@Nullable Bundle savedInstanceState) {
}
} }

View File

@ -57,6 +57,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:name="com.muqingbfq.fragment.search" android:name="com.muqingbfq.fragment.search"
android:visibility="gone"
tools:layout="@layout/fragment_search" /> tools:layout="@layout/fragment_search" />
<ListView <ListView
android:id="@+id/search_recycler" android:id="@+id/search_recycler"

View File

@ -2,44 +2,19 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:background="?android:colorBackground"> android:background="?android:colorBackground">
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout" android:id="@+id/tablayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/music" />
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Playlist" />
</com.google.android.material.tabs.TabLayout> </com.google.android.material.tabs.TabLayout>
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.viewpager2.widget.ViewPager2
<ProgressBar android:id="@+id/viewPager"
android:id="@+id/recyclerview1_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<TextView
android:id="@+id/recyclerview1_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loadnull"
android:textSize="26sp"
android:padding="6dp"
android:visibility="gone"
android:layout_centerInParent="true"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycleview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/recyclerview_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<TextView
android:id="@+id/recyclerview_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loadnull"
android:textSize="26sp"
android:padding="6dp"
android:visibility="gone"
android:layout_centerInParent="true"/>
</RelativeLayout>

View File

@ -386,6 +386,30 @@ public class LrcView extends View {
}); });
} }
public static void Lrc(String mainLrcText, String secondLrcText) {
StringBuilder sb = new StringBuilder("file://");
sb.append(mainLrcText);
if (secondLrcText != null) {
sb.append("#").append(secondLrcText);
}
String flag = sb.toString();
ExecutorService executor = Executors.newSingleThreadExecutor();
Callable<List<LrcEntry>> callable = () -> LrcUtils.parseLrc(
new String[]{mainLrcText, secondLrcText});
Future<List<LrcEntry>> future = executor.submit(callable);
try {
mLrcEntryList = future.get();
} catch (InterruptedException e) {
// 处理中断异常
e.printStackTrace();
} catch (ExecutionException e) {
// 处理执行异常
e.printStackTrace();
}
// 关闭线程池
executor.shutdown();
}
/** /**
* 歌词是否有效 * 歌词是否有效
* *