部分Bug修复
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -347,26 +347,26 @@ 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());
|
||||
|
||||
for (Place p : b) {
|
||||
double distance = DistanceCalculator.calculateDistance(Double.parseDouble(x), Double.parseDouble(y), p.getX(), p.getY());
|
||||
|
||||
if (shoucang.contains(p.getId() + "")) {
|
||||
p.setName(p.getName() + " 收藏" + " 距离您" + String.format(Locale.CHINA, "%.2f", distance) + "km");
|
||||
treeMap.put(distance - 1000, p);
|
||||
} else {
|
||||
p.setName(p.getName() + " 距离您" + String.format(Locale.CHINA, "%.2f", distance) + "km");
|
||||
treeMap.put(distance, p);
|
||||
if (shoucang.contains(p.getId() + "")) {
|
||||
p.setName(p.getName() + " 收藏" + " 距离您" + String.format(Locale.CHINA, "%.2f", distance) + "km");
|
||||
treeMap.put(distance - 1000, p);
|
||||
} else {
|
||||
p.setName(p.getName() + " 距离您" + String.format(Locale.CHINA, "%.2f", distance) + "km");
|
||||
treeMap.put(distance, p);
|
||||
}
|
||||
if (p.getNumJ() > 0) {
|
||||
p.setName(p.getName() + "\uD83D\uDCB3");
|
||||
}
|
||||
}
|
||||
if (p.getNumJ() > 0) {
|
||||
p.setName(p.getName() + "\uD83D\uDCB3");
|
||||
|
||||
for (Double key : treeMap.keySet()) {
|
||||
a.add(treeMap.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
for (Double key : treeMap.keySet()) {
|
||||
a.add(treeMap.get(key));
|
||||
}
|
||||
|
||||
}catch (Exception e) {}
|
||||
boolean flag2 = true;
|
||||
if (flag2) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user