优化了部分UI,修复了歌单BUG,修复一些其余BUG

This commit is contained in:
muqing 2024-01-31 11:43:28 +08:00
parent ba6d8dcedc
commit 8e13e2fcd5
26 changed files with 387 additions and 258 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

View File

@ -1,10 +1,15 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintHardcodedText" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,android.content.res.Resources.Theme,obtainStyledAttributes" />
</inspection_tool>
<inspection_tool class="DataFlowIssue" enabled="false" level="WARNING" enabled_by_default="false">
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false" />
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="false" />
</inspection_tool>
<inspection_tool class="FieldMayBeFinal" enabled="true" level="INFORMATION" enabled_by_default="true" />
<inspection_tool class="InnerClassMayBeStatic" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK" />

View File

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

View File

@ -61,6 +61,9 @@ public class activity_search extends FragmentActivity {
//设置是否换行
manager.setFlexWrap(FlexWrap.WRAP);
manager.setAlignItems(AlignItems.STRETCH);
// binding.searchRecycler.setBackgroundColor(gj.getbackgroundColor(this));
binding.listRecycler.setLayoutManager(manager);
binding.listRecycler.setAdapter(new SearchRecordAdapter());
@ -196,7 +199,7 @@ public class activity_search extends FragmentActivity {
search sea = (search) getSupportFragmentManager().findFragmentById(R.id.search_fragment);
if (!name.equals(sea.name)) {
sea.i = 0;
sea.inflate.tablayout.getTabAt(0).select();
sea.binding.tablayout.getTabAt(0).select();
}
sea.setVisibility(true);
sea.setStart(name);

View File

@ -12,6 +12,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.DecimalFormat;
import java.util.List;
public class resource {
@ -59,7 +60,18 @@ public class resource {
String id = js.getString("id");
String name = js.getString("name");
String coverImgUrl = js.getString("coverImgUrl");
return new XM(id, name, coverImgUrl);
long playCount = js.getLong("playCount");
String formattedNumber = String.valueOf(playCount);
if (playCount > 9999) {
DecimalFormat df = new DecimalFormat("#,###.0万");
formattedNumber = df.format(playCount / 10000);
}
String s = js.getInt("trackCount") + "首,"
+ "by " + js.getJSONObject("creator").getString("nickname")
+ ",播放"
+ formattedNumber + "";
return new XM(id, name, s, coverImgUrl);
}
// 排行榜

View File

@ -136,4 +136,22 @@ public class bfq_an {
bfqkz.like_bool = contains;
bfq.setlike(contains);
}
public static boolean getlike(MP3 xm) {
boolean contains = false;
String dqwb = wj.dqwb(wj.gd + "mp3_like.json");
if (dqwb != null) {
try {
Type type = new TypeToken<List<MP3>>() {
}.getType();
List<MP3> o = new Gson().fromJson(dqwb, type);
if (o != null) {
contains = o.contains(xm);
}
} catch (Exception e) {
wj.sc(wj.gd + "mp3_like.json");
}
}
return contains;
}
}

View File

@ -16,7 +16,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.muqingbfq.R;
import com.muqingbfq.databinding.CleanBinding;
import com.muqingbfq.databinding.ActivityCleanBinding;
import com.muqingbfq.mq.FragmentActivity;
import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
@ -28,11 +28,11 @@ import java.util.List;
public class fragment_clean extends FragmentActivity {
List<String[]> list = new ArrayList<>();
List<String> list_box = new ArrayList<>();
CleanBinding binding;
ActivityCleanBinding binding;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = CleanBinding.inflate(getLayoutInflater());
binding = ActivityCleanBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
UI();
}

View File

@ -175,25 +175,18 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
@SuppressLint("NotifyDataSetChanged")
@Override
public void run() {
super.run();
String hq = playlist.gethq(xm.id);
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();
JSONObject json = new JSONObject(hq);
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(() -> {
notifyItemChanged(position);
wode.addlist(xm);
});
json.put("message", fh.message);
// json.put(fh.id, json);
wj.xrwb(wj.gd + xm.id, json.toString());
wode.addlist(fh);
main.handler.post(() -> notifyItemChanged(position));
} catch (JSONException e) {
gj.sc("list gd onclick thear " + e);
}
@ -205,12 +198,9 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
// 删除项目
try {
wj.sc(wj.gd + xm.id);
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());
wode.removelist(xm);
} catch (JSONException e) {
notifyItemRemoved(position);
} catch (Exception e) {
gj.sc(e);
}
break;

View File

@ -1,12 +1,8 @@
package com.muqingbfq.fragment;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@ -24,13 +20,11 @@ import com.bumptech.glide.request.RequestOptions;
import com.muqingbfq.MP3;
import com.muqingbfq.R;
import com.muqingbfq.XM;
import com.muqingbfq.activity_search;
import com.muqingbfq.api.resource;
import com.muqingbfq.api.url;
import com.muqingbfq.bfqkz;
import com.muqingbfq.databinding.FragmentGdBinding;
import com.muqingbfq.databinding.ListMp3ImageBinding;
import com.muqingbfq.home;
import com.muqingbfq.main;
import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
@ -47,13 +41,6 @@ public class gd_adapter extends Fragment {
List<MP3> listmp3 = new ArrayList<>();
FragmentGdBinding binding;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setHasOptionsMenu(true);
// 其他初始化代码...
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -61,12 +48,14 @@ public class gd_adapter extends Fragment {
//初始化工具栏
((AppCompatActivity) requireActivity()).setSupportActionBar(binding.toolbar);
DrawerLayout drawerLayout = home.appCompatActivity.findViewById(R.id.chct);
DrawerLayout drawerLayout = requireActivity().findViewById(R.id.chct);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
getActivity(), drawerLayout, binding.toolbar, R.string.app_name, R.string.app_name);
drawerLayout.addDrawerListener(toggle);
toggle.syncState();
// setHasOptionsMenu(true);
binding.toolbar.setPadding(0, gj.getztl(getContext()), 0, 0);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
@ -82,8 +71,6 @@ public class gd_adapter extends Fragment {
main.handler.post(new sx());
}
}.start();
binding.recyclerview2.setFocusable(false);
binding.recyclerview2.setLayoutManager(new LinearLayoutManager(getContext()){
@Override
public boolean canScrollVertically() {
@ -152,24 +139,9 @@ public class gd_adapter extends Fragment {
@Override
public void run() {
binding.recyclerview1.getAdapter().notifyDataSetChanged();
binding.recyclerview1Bar.setVisibility(View.GONE);
}
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.home, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_search) {
Intent intent = new Intent(getContext(), activity_search.class);
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
public void mp3list() {
new Thread(){
@SuppressLint("NotifyDataSetChanged")
@ -198,7 +170,10 @@ public class gd_adapter extends Fragment {
listmp3.add(new MP3(id, name, zz.toString(), picUrl));
}
wj.xrwb(wj.filesdri + "songs.josn", hq);
main.handler.post(() -> binding.recyclerview2.getAdapter().notifyDataSetChanged());
main.handler.post(() ->{
binding.recyclerview2.getAdapter().notifyDataSetChanged();
binding.recyclerview2Bar.setVisibility(View.GONE);
});
} catch (Exception e) {
gj.sc(e);
}

View File

@ -21,18 +21,16 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.muqingbfq.MP3;
import com.muqingbfq.R;
import com.muqingbfq.XM;
import com.muqingbfq.api.FileDownloader;
import com.muqingbfq.api.playlist;
import com.muqingbfq.api.resource;
import com.muqingbfq.api.url;
import com.muqingbfq.bfq;
import com.muqingbfq.bfq_an;
import com.muqingbfq.bfqkz;
import com.muqingbfq.databinding.FragmentMp3Binding;
import com.muqingbfq.databinding.ListMp3Binding;
@ -42,20 +40,17 @@ import com.muqingbfq.mq.FragmentActivity;
import com.muqingbfq.mq.gj;
import com.muqingbfq.mq.wj;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class mp3 extends FragmentActivity {
private List<MP3> list = new ArrayList<>();
private List<MP3> list_ys = new ArrayList<>();
public static adaper lbspq;
FragmentMp3Binding binding;
// private static String id;
// private static String id;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -88,7 +83,7 @@ public class mp3 extends FragmentActivity {
});
//添加Android自带的分割线
binding.lb.addItemDecoration(
new DividerItemDecoration(this,DividerItemDecoration.VERTICAL));
new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
}
@Override
@ -137,6 +132,7 @@ public class mp3 extends FragmentActivity {
String id;
public start(String id) {
binding.recyclerview1Bar.setVisibility(View.VISIBLE);
this.id = id;
list.clear();
list_ys.clear();
@ -154,7 +150,15 @@ public class mp3 extends FragmentActivity {
playlist.hq(list, id);
}
list_ys = list;
main.handler.post(new lbspq_sx());
main.handler.post(() -> {
lbspq.notifyDataSetChanged();
binding.recyclerview1Bar.setVisibility(View.GONE);
if (list.isEmpty()) {
binding.recyclerview1Text.setVisibility(View.VISIBLE);
} else {
binding.recyclerview1Text.setVisibility(View.GONE);
}
});
}
}
@ -170,10 +174,12 @@ public class mp3 extends FragmentActivity {
private List<MP3> list;
private List<MP3> list_ys;
public adaper(List list) {
this.list = list;
list_ys = list;
}
@NonNull
@Override
public MyViewHoder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@ -204,15 +210,26 @@ public class mp3 extends FragmentActivity {
bfq.start(holder.getContext());
});
holder.itemView.setOnLongClickListener(view -> {
String a[] = new String[]{"喜欢歌曲", "下载歌曲", "复制名字"};
List<String> stringList = new ArrayList<>();
boolean getlike = bfq_an.getlike(x);
if (getlike) {
stringList.add("取消喜欢");
} else {
stringList.add("喜欢歌曲");
}
if (!wj.cz(wj.mp3 + x.id)) {
stringList.add("下载歌曲");
}
stringList.add("复制名字");
String[] array = stringList.toArray(new String[0]);
new MaterialAlertDialogBuilder(view.getContext()).
setItems(a, (dialog, id) -> {
String title = a[id];
switch (title) {
setItems(array, (dialog, id) -> {
switch (array[id]) {
case "下载歌曲":
new FileDownloader(view.getContext()).downloadFile(x);
break;
case "喜欢歌曲":
case "取消喜欢":
try {
Gson gson = new Gson();
Type type = new TypeToken<List<MP3>>() {
@ -221,16 +238,10 @@ public class mp3 extends FragmentActivity {
if (list == null) {
list = new ArrayList<>();
}
if (bfqkz.like_bool) {
list.remove(bfqkz.xm);
bfq.setlike(false);
} else {
if (!list.contains(bfqkz.xm)) {
list.add(bfqkz.xm);
bfq.setlike(true);
}
}
bfqkz.like_bool = !bfqkz.like_bool;
if (list.contains(x))
list.remove(x);
else
list.add(x);
wj.xrwb(wj.gd + "mp3_like.json", gson.toJson(list));
} catch (Exception e) {
e.printStackTrace();

View File

@ -36,21 +36,16 @@ public class search extends Fragment {
List<XM> xmList = new ArrayList<>();
public String name;
public FragmentSearchBinding inflate;
public FragmentSearchBinding binding;
public int i = 0;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
inflate = FragmentSearchBinding.inflate(inflater, container, false);
binding = FragmentSearchBinding.inflate(inflater, container, false);
lbspq = new mp3.adaper(list);
View view = inflate.getRoot();
TypedValue typedValue = new TypedValue();
requireContext().getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true);
// 设置背景颜色
view.setBackgroundColor(typedValue.data);
inflate.tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
binding.tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
// 当用户再次选择已选择的选项卡时调用
@ -71,14 +66,14 @@ public class search extends Fragment {
}
});
setVisibility(false);
return view;
return binding.getRoot();
}
public void setVisibility(boolean bool) {
if (bool) {
inflate.getRoot().setVisibility(View.VISIBLE);
binding.getRoot().setVisibility(View.VISIBLE);
} else {
inflate.getRoot().setVisibility(View.GONE);
binding.getRoot().setVisibility(View.GONE);
}
}
@ -87,13 +82,13 @@ public class search extends Fragment {
public void setStart(String name) {
if (i == 0) {
new mp3.adaper(list);
inflate.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
inflate.recyclerview.setAdapter(lbspq);
binding.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recyclerview.setAdapter(lbspq);
} else if (i == 1) {
k = (int) (main.k / getResources().getDisplayMetrics().density + 0.5f) / 120;
inflate.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
inflate.recyclerview.setAdapter(new gd.baseadapter(getContext(),
xmList, true, inflate.recyclerview));
binding.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
binding.recyclerview.setAdapter(new gd.baseadapter(getContext(),
xmList, true, binding.recyclerview));
}
new start(name);
@ -101,22 +96,33 @@ public class search extends Fragment {
public class start extends Thread {
public start(String name) {
binding.recyclerview1Bar.setVisibility(View.VISIBLE);
list.clear();
xmList.clear();
search.this.name = name;
start();
}
boolean load = false;
@SuppressLint("NotifyDataSetChanged")
@Override
public void run() {
super.run();
if (i == 0) {
mp3();
load = !list.isEmpty();
} else if (i == 1) {
gd();
load = !xmList.isEmpty();
}
main.handler.post(() -> inflate.recyclerview.getAdapter().notifyDataSetChanged());
main.handler.post(() -> {
binding.recyclerview.getAdapter().notifyDataSetChanged();
binding.recyclerview1Bar.setVisibility(View.GONE);
if (load) {
binding.recyclerview1Text.setVisibility(View.GONE);
} else {
binding.recyclerview1Text.setVisibility(View.VISIBLE);
}
});
}
}
@ -178,21 +184,21 @@ public class search extends Fragment {
for (int i = 0; i < length; i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String id = jsonObject.getString("id");
int trackCount = jsonObject.getInt("trackCount");
String nickname = "by " + jsonObject.getJSONObject("creator")
.getString("nickname");
long playCount = jsonObject.getLong("playCount");
String name = jsonObject.getString("name");
String coverImgUrl = jsonObject.getString("coverImgUrl");
// gj.sc(name);
long playCount = jsonObject.getLong("playCount");
String formattedNumber = String.valueOf(playCount);
if (playCount > 9999) {
DecimalFormat df = new DecimalFormat("#,###.0万");
formattedNumber = df.format(playCount / 10000);
}
xmList.add(new XM(id, name, trackCount + "首," + nickname + ",播放"
+ formattedNumber + "", coverImgUrl));
String s = jsonObject.getInt("trackCount") + "首,"
+ "by " + jsonObject.getJSONObject("creator").getString("nickname")
+ ",播放"
+ formattedNumber + "";
xmList.add(new XM(id, name, s, coverImgUrl));
}
} catch (Exception e) {
gj.sc(e);

View File

@ -5,9 +5,6 @@ import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@ -30,7 +27,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.gson.Gson;
import com.muqingbfq.R;
import com.muqingbfq.XM;
import com.muqingbfq.activity_search;
import com.muqingbfq.api.playlist;
import com.muqingbfq.api.resource;
import com.muqingbfq.bfqkz;
@ -50,9 +46,7 @@ import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -75,14 +69,6 @@ public class wode extends Fragment {
};
@SuppressLint("StaticFieldLeak")
public static baseadapter adaper;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setHasOptionsMenu(true);
// 其他初始化代码...
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@ -204,23 +190,17 @@ public class wode extends Fragment {
super.run();
String hq = playlist.gethq(finalStr);
if (hq != null) {
wj.xrwb(wj.gd + finalStr, 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(finalStr);
JSONObject json = new JSONObject();
JSONObject json = new JSONObject(hq);
json.put("name", fh.name);
json.put("picUrl", fh.picurl);
jsonObject.put(fh.id, json);
wj.xrwb(wj.gd_xz, jsonObject.toString());
sx();
gj.xcts(getContext(), "成功");
json.put("message", fh.message);
// json.put(fh.id, json);
wj.xrwb(wj.gd + finalStr, json.toString());
addlist(fh);
} catch (JSONException e) {
gj.sc("list gd onclick thear " + e);
gj.xcts(getContext(), "失败");
}
}
}
@ -293,15 +273,28 @@ public class wode extends Fragment {
public void sx() {
try {
adaper.list.clear();
JSONObject date = new JSONObject(wj.dqwb(wj.gd_xz));
for (Iterator<String> it = date.keys(); it.hasNext(); ) {
String id = it.next();
JSONObject jsonObject = date.getJSONObject(id);
File file = new File(wj.gd);
for (File a : file.listFiles()) {
gj.sc(a);
String id = a.getName();
if (id.endsWith(".json")) {
return;
}
String dqwb = wj.dqwb(a.toString());
JSONObject jsonObject = new JSONObject(dqwb);
String name = jsonObject.getString("name");
String picUrl = jsonObject.getString("picUrl");
adaper.list.add(new XM(id, name, picUrl));
String message = jsonObject.getString("message");
adaper.list.add(new XM(id, name, message, picUrl));
}
main.handler.post(() -> binding.recyclerview2.getAdapter().notifyDataSetChanged());
main.handler.post(() ->{
adaper.notifyDataSetChanged();
if (adaper.list.isEmpty()) {
binding.recyclerview2Text.setVisibility(View.VISIBLE);
} else {
binding.recyclerview2Text.setVisibility(View.GONE);
}
});
} catch (Exception e) {
gj.sc(e);
}
@ -309,9 +302,10 @@ public class wode extends Fragment {
@SuppressLint("NotifyDataSetChanged")
public static void addlist(XM xm) {
if (adaper != null&&!adaper.list.contains(xm)) {
if (adaper != null) {
adaper.list.remove(xm);
adaper.list.add(xm);
adaper.notifyDataSetChanged();
main.handler.post(() -> adaper.notifyDataSetChanged());
}
}
@ -351,22 +345,6 @@ public class wode extends Fragment {
.into(binding.imageView);
}
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.home, menu);
super.onCreateOptionsMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_search) {
Intent intent = new Intent(getContext(), activity_search.class);
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
class baseadapter extends RecyclerView.Adapter<gd.VH> {
public List<XM> list = new ArrayList<>();
@NonNull
@ -376,10 +354,6 @@ public class wode extends Fragment {
.inflate(R.layout.list_gd_b, parent, false)));
}
public void setList(List<XM> list) {
this.list = list;
}
@Override
public void onBindViewHolder(@NonNull gd.VH holder, @SuppressLint("RecyclerView") int position) {
XM xm = list.get(position);
@ -403,18 +377,15 @@ public class wode extends Fragment {
super.run();
String hq = playlist.gethq(xm.id);
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();
JSONObject json = new JSONObject(hq);
json.put("name", fh.name);
json.put("picUrl", fh.picurl);
jsonObject.put(fh.id, json);
wj.xrwb(wj.gd_xz, jsonObject.toString());
json.put("message", fh.message);
// json.put(fh.id, json);
wj.xrwb(wj.gd + xm.id, json.toString());
addlist(fh);
main.handler.post(() -> notifyItemChanged(position));
} catch (JSONException e) {
gj.sc("list gd onclick thear " + e);
@ -427,12 +398,9 @@ public class wode extends Fragment {
// 删除项目
try {
wj.sc(wj.gd + xm.id);
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());
notifyItemRemoved(position);
} catch (JSONException e) {
} catch (Exception e) {
gj.sc(e);
}
break;
@ -477,8 +445,14 @@ public class wode extends Fragment {
@Override
public int getItemCount() {
if (list.isEmpty()) {
binding.recyclerview2Text.setVisibility(View.VISIBLE);
} else {
binding.recyclerview2Text.setVisibility(View.GONE);
}
return list.size();
}
}
}

View File

@ -3,10 +3,13 @@ package com.muqingbfq;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.media.MediaBrowserCompat;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
@ -206,4 +209,23 @@ public class home extends AppCompatActivity {
mBrowser.disconnect();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.home,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_search) {
Intent intent = new Intent(getContext(), activity_search.class);
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
private Context getContext() {
return this;
}
}

View File

@ -7,6 +7,7 @@ import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
import android.util.DisplayMetrics;
import android.util.Log;
@ -14,6 +15,8 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.muqingbfq.main;
import com.muqingbfq.yc;
@ -179,4 +182,15 @@ public class gj {
getIdentifier("status_bar_height", "dimen", "android");
return context.getResources().getDimensionPixelSize(resourceId);
}
public static int getbackgroundColor(AppCompatActivity appCompatActivity) {
TypedArray array = appCompatActivity.getTheme().obtainStyledAttributes(new int[] {
android.R.attr.colorBackground
// android.R.attr.textColorPrimary,
});
int backgroundColor = array.getColor(0, 0xFF00FF);
// int textColor = array.getColor(1, 0xFF00FF);
array.recycle();
return backgroundColor;
}
}

View File

@ -2,6 +2,7 @@ package com.muqingbfq.view;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
@ -48,7 +49,7 @@ public class Edit extends LinearLayout {
private void initView() {
setGravity(Gravity.CENTER_VERTICAL);
setBackgroundResource(R.drawable.ui_editview);
setPadding(30, 10, 30, 10);
setPadding(30, 0, 30, 0);
//构建编辑框
editText = new EditText(getContext());
editText.setHint("搜索");
@ -74,11 +75,12 @@ public class Edit extends LinearLayout {
ImageView imageView = new ImageView(getContext());
imageView.setImageResource(R.drawable.sousuo);
imageView.setImageTintList(ContextCompat.getColorStateList(getContext(),
R.color.text_tm));
addView(imageView, (int) TypedValue.applyDimension(TypedValue.
COMPLEX_UNIT_DIP, 26, getResources().getDisplayMetrics())
, (int) TypedValue.applyDimension(TypedValue.
COMPLEX_UNIT_DIP, 26, getResources().getDisplayMetrics()));
LayoutParams layoutParams = new LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);

View File

@ -21,7 +21,7 @@ public class RecyclerViewH extends RecyclerView {
public RecyclerViewH(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
private boolean disallowIntercept = false;
// private boolean disallowIntercept = false;
private int startX = 0;
private int startY = 0;
@ -43,7 +43,9 @@ public class RecyclerViewH extends RecyclerView {
if (Math.abs(disY) > ViewConfiguration.get(getContext()).getScaledTouchSlop()) {
// 当前手指移动距离大于系统认定的最小滚动距离时不允许父容器拦截触摸事件
getParent().requestDisallowInterceptTouchEvent(true);
}else
} else {
break;
}
/*
if (disX > disY) {
//为了解决RecyclerView嵌套RecyclerView时横向滑动的问题
@ -55,7 +57,6 @@ public class RecyclerViewH extends RecyclerView {
} else {
getParent().requestDisallowInterceptTouchEvent(true);
}*/
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
getParent().requestDisallowInterceptTouchEvent(false);
@ -66,7 +67,6 @@ public class RecyclerViewH extends RecyclerView {
}
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
this.disallowIntercept = disallowIntercept;
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}

View File

@ -3,7 +3,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:fitsSystemWindows="true">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"

View File

@ -62,9 +62,11 @@
android:id="@+id/search_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="@color/bj"/>
android:background="?android:colorBackground"
android:visibility="gone"/>
</RelativeLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/bfq_db"
android:layout_width="match_parent"

View File

@ -50,11 +50,26 @@
app:cardUseCompatPadding="true"
app:contentPadding="6dp">
<ProgressBar
android:id="@+id/recyclerview1_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/recyclerview1_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nullPlaylists"
android:textSize="26sp"
android:padding="6dp"
android:visibility="gone"
android:layout_centerHorizontal="true"/>
<com.muqingbfq.view.RecyclerViewH
android:id="@+id/recyclerview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:focusableInTouchMode="false"
android:nestedScrollingEnabled="false"
tools:itemCount="6" />
</com.google.android.material.card.MaterialCardView>
@ -72,10 +87,25 @@
app:cardUseCompatPadding="true"
app:contentPadding="6dp">
<ProgressBar
android:id="@+id/recyclerview2_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/recyclerview2_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nullPlaylists"
android:textSize="26sp"
android:padding="6dp"
android:visibility="gone"
android:layout_centerHorizontal="true"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview2"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:nestedScrollingEnabled="false" />
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -3,37 +3,67 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.muqingbfq.view.Text
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/text"
android:textSize="26sp" />
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autofillHints="text"
android:backgroundTint="@color/text_tm"
android:hint="输入需要搜索的音乐"
android:visibility="gone"/>
android:imeOptions="actionSearch"
android:inputType="text"
android:maxLines="1"
android:visibility="gone"
tools:ignore="HardcodedText" />
</LinearLayout>
</com.google.android.material.appbar.MaterialToolbar>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ProgressBar
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:layout_centerInParent="true"
android:padding="6dp"
android:text="@string/loadnull"
android:textSize="26sp"
android:visibility="gone" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/lb"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_height="match_parent" />
</RelativeLayout>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/bfq_db"

View File

@ -3,7 +3,8 @@
android:layout_width="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">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
@ -17,9 +18,28 @@
android:layout_height="wrap_content"
android:text="@string/Playlist" />
</com.google.android.material.tabs.TabLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
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_height="match_parent"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"/>
</RelativeLayout>
</LinearLayout>

View File

@ -99,27 +99,37 @@
android:nestedScrollingEnabled="false" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
app:cardUseCompatPadding="true"
app:contentPadding="6dp"
app:layout_constraintTop_toBottomOf="@+id/cardview2">
app:layout_constraintTop_toBottomOf="@+id/cardview2"
android:orientation="vertical">
<RelativeLayout
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Downloadplaylist"
android:padding="6dp"
android:textSize="26sp" />
<TextView
android:id="@+id/recyclerview2_text"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:padding="6dp"
android:text="@string/nullPlaylists"
android:textSize="20sp"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="false"
android:nestedScrollingEnabled="false"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -2,6 +2,6 @@
<resources>
<color name="ztl">#1C1B1F</color>
<color name="text">@color/white</color>
<color name="text_tm">#CCC2DC</color>
<color name="text_tm">#80FFFFFF</color>
<color name="bj">#2A2831</color>
</resources>

View File

@ -12,7 +12,7 @@
<color name="text_cz">#03A9F4</color>
<color name="text_cz_tm">#9903A9F4</color>
<color name="text">#000000</color>
<color name="text_tm">#625B71</color>
<color name="text_tm">#80000000</color>
<color name="tm">#00FFFFFF</color>
<color name="bj">#F2ECF6</color>

View File

@ -31,6 +31,10 @@
<string name="quxiao">取消</string>
<string name="jianchagegnxin">检查更新</string>
<string name="endapp">关闭软件</string>
<string name="nullPlaylists">暂无歌单</string>
<string name="Downloadplaylist">下载歌单</string>
<string name="loadnull">加载失败</string>
<string-array name="gd_list">
<item>下载歌单</item>
<item>收藏歌单(不可用)</item>