部分Bug修复

This commit is contained in:
2025-05-14 21:55:24 +08:00
parent 29c6c2567c
commit 98be6c946e
7 changed files with 54 additions and 27 deletions

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View File

@@ -1,10 +1,12 @@
package org.astral.findmaimaiultra.adapter;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
@@ -20,6 +22,7 @@ import java.util.List;
public class SuggestMusicRatingAdapter extends RecyclerView.Adapter<SuggestMusicRatingAdapter.ViewHolder> {
private List<MusicRating> musicRatings;
private final SharedPreferences projectE;
private OnItemClickListener listener;
public interface OnItemClickListener {
@@ -31,10 +34,12 @@ public class SuggestMusicRatingAdapter extends RecyclerView.Adapter<SuggestMusic
this.listener = listener;
}
public SuggestMusicRatingAdapter(List<MusicRating> musicRatings) {
public SuggestMusicRatingAdapter(List<MusicRating> musicRatings, SharedPreferences projectE) {
this.musicRatings = musicRatings;
this.projectE = projectE;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@@ -91,6 +96,26 @@ public class SuggestMusicRatingAdapter extends RecyclerView.Adapter<SuggestMusic
listener.onItemClick(musicRating);
}
});
// Long-press listener to delete project
holder.itemView.setOnLongClickListener(v -> {
// Remove project from SharedPreferences
String projectKey = "project" + musicRating.getMusicId();
if (projectE.contains(projectKey)) {
SharedPreferences.Editor editor = projectE.edit();
editor.remove(projectKey);
editor.apply();
// Remove item from the list and refresh
musicRatings.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position, musicRatings.size());
Toast.makeText(v.getContext(), "Project removed", Toast.LENGTH_SHORT).show();
}
return true;
});
}
private int getAchievementImageResId(int achievement) {

View File

@@ -347,7 +347,7 @@ public class HomeFragment extends Fragment {
a.clear();
TreeMap<Double, Place> treeMap = new TreeMap<>();
try {
for (Place p : b) {
double distance = DistanceCalculator.calculateDistance(Double.parseDouble(x), Double.parseDouble(y), p.getX(), p.getY());
@@ -366,7 +366,7 @@ public class HomeFragment extends Fragment {
for (Double key : treeMap.keySet()) {
a.add(treeMap.get(key));
}
}catch (Exception e) {}
boolean flag2 = true;
if (flag2) {
getActivity().runOnUiThread(new Runnable() {

View File

@@ -561,7 +561,9 @@ public class MusicFragment extends Fragment {
.load("https://assets2.lxns.net/maimai/jacket/" + song.getId() + ".png")
.into(songImage);
TextView songTitle = dialogView.findViewById(R.id.song_title);
songTitle.setTextColor(getResources().getColor(R.color.textcolorPrimary));
TextView songArtist = dialogView.findViewById(R.id.song_artist);
songArtist.setTextColor(getResources().getColor(R.color.textcolorPrimary));
songTitle.setText(song.getTitle());
songArtist.setText(song.getArtist());
@@ -592,6 +594,7 @@ public class MusicFragment extends Fragment {
cell.setTextColor(getResources().getColor(R.color.primary));
}else {
cell.setText(100.5001 - (((float)j-1) * 0.5) + "%");
cell.setTextColor(getResources().getColor(R.color.textcolorPrimary));
}
cell.setPadding(8, 8, 8, 8);
row.addView(cell);
@@ -606,6 +609,7 @@ public class MusicFragment extends Fragment {
double a = 100.5001 - (((float)j-1) * 0.5);
Log.d("TAG", "a: " + a);
cell.setText("" + getRatingChart(diff.get(i-1),a)); // 示例数据
cell.setTextColor(getResources().getColor(R.color.textcolorPrimary));
int finalI = i;
int finalJ = j;
@@ -631,6 +635,7 @@ public class MusicFragment extends Fragment {
Snackbar.make(v, "已添加", Snackbar.LENGTH_SHORT)
.setAction("确定", null)
.show();
dataanlysis();
});
builder1.setNegativeButton("取消", (dialog, which) -> {
dialog.dismiss();
@@ -666,6 +671,8 @@ public class MusicFragment extends Fragment {
else{
extraInfo.setText("BPM" + song.getBpm());
}
extraInfo.setTextColor(getResources().getColor(R.color.textcolorPrimary));
builder.setPositiveButton("关闭", (dialog, which) -> dialog.dismiss());
builder.show();
}
@@ -909,7 +916,7 @@ public class MusicFragment extends Fragment {
au.setText("Rating分析:最低分 " + worstRating + "分,最高分 " + bestRating + ",平均分" + (finalTotal / 50) + "");
adapterSuggest = new SuggestMusicRatingAdapter(suggestMusicRatingList);
adapterSuggest = new SuggestMusicRatingAdapter(suggestMusicRatingList,project);
suggest.setAdapter(adapterSuggest);
adapterSuggest.notifyDataSetChanged();
});

View File

@@ -73,12 +73,5 @@
android:text="额外信息"
android:layout_marginTop="16dp" />
<!-- 添加到计划按钮 -->
<com.google.android.material.button.MaterialButton
android:id="@+id/add_to_plan_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="添加到计划"
android:layout_marginTop="16dp" />
</LinearLayout>
</ScrollView>

View File

@@ -10,6 +10,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Song Title"
android:textColor="@color/textcolorPrimary"
android:textSize="16sp"
android:textStyle="bold"
android:ellipsize="end"

View File

@@ -18,6 +18,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="@color/textcolorPrimary"
android:textStyle="bold" />
<TextView