Compare commits

..

No commits in common. "b04bd7ca5a1e41c0a5597d146a2f520572df385d" and "6dfaf02422ca7e02165df4d7640044b00940007e" have entirely different histories.

6 changed files with 10 additions and 106 deletions

Binary file not shown.

View File

@ -7,11 +7,9 @@ import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.Toast;
import androidx.annotation.NonNull;
@ -21,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSONObject;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.kaopiz.kprogresshud.KProgressHUD;
import com.yutou.nas_music_player.Datas.MusicData;
import com.yutou.nas_music_player.Interfaces.NetworkInterface;
import com.yutou.nas_music_player.MyApplication;
@ -177,17 +176,7 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
super.bind(data);
collectionDir(data);
topDir(data);
itemView.setOnClickListener(v -> {
clickAllList(data);
}
);
itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
showPOPWindows(data);
return true;
}
});
itemView.setOnClickListener(v -> clickAllList(data));
}
}
@ -226,17 +215,6 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
dislike = itemView.findViewById(R.id.dislike);
icon = itemView.findViewById(R.id.album_image);
play_mask = itemView.findViewById(R.id.play_mask);
icon.setTag("icon");
title.setTag("title");
artist.setTag("artist");
message.setTag("message");
buttons.setTag("buttons");
collection.setTag("collection");
top.setTag("top");
dislike.setTag("dislike");
play_mask.setTag("play_mask");
}
protected void collectionDir(MusicData data) {
@ -328,7 +306,6 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
}
protected void clickAlbum(MusicData data) {
System.out.println("点击item");
if (data == null)
return;
Intent intent = new Intent(itemView.getContext(), AlbumsActivity.class);
@ -486,52 +463,5 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
}
});
}
PopupWindow popupWindow = null;
protected void showPOPWindows(MusicData data) {
Button button = new Button(context);
button.setText("添加到列表");
button.setOnClickListener(view -> {
AppTools.showHud(context);
if(!data.isDir()){
MusicContainer.getInstance().addPlayList(data);
AppTools.hideHud();
AppTools.toast( "已添加到队列中");
popupWindow.dismiss();
return;
}
JSONObject json = new JSONObject();
json.put("path", data.getFile());
json.put("type", true);
MusicContainer.getLibs().onDirMusicData(json, new NetworkInterface() {
@Override
public void httpGetData(Object data1, int state) {
List<MusicData> list = (List<MusicData>) data1;
int i = 0;
for (MusicData musicData : list) {
if (!musicData.isDir()) {
MusicContainer.getInstance().addPlayList(musicData);
i++;
}
}
AppTools.hideHud();
AppTools.toast(i + "首歌已添加到队列中");
popupWindow.dismiss();
MusicContainer.getInstance().setPlayModel(MusicContainer.PLAY_MODEL_ORDER);
MusicContainer.getInstance().playNext();
}
@Override
public void httpError(Exception e) {
AppTools.toast("添加失败:" + e.getMessage());
}
});
});
popupWindow = new PopupWindow(button, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setOutsideTouchable(true);
popupWindow.showAsDropDown(itemView, 200, 0);
}
}
}

View File

@ -8,7 +8,7 @@ import java.util.List;
*/
public class PreviousPlayerList {
private static final int INDEX=10;//记录十条
private final List<MusicData> list;
private List<MusicData> list;
public PreviousPlayerList(){
list=new ArrayList<>();
}

View File

@ -72,14 +72,13 @@ public class MusicContainer {
collectionMapList = new LinkedHashMap<>();
previousPlayerList = new PreviousPlayerList();
browserHelpers = new ArrayList<>();
playIndex = ConfigTools.getConfigPreferences().getInt("playIndex", -1);
playIndex = ConfigTools.getPreferences().getInt("playIndex", -1);
initMediaPlayer();
libs = new MusicLibs();
}
public void setPlayModel(int playModel) {
this.playModel = playModel;
ConfigTools.getConfigPreferences().edit().putInt("playModel", playModel).apply();
}
private void initMediaPlayer() {
@ -236,7 +235,7 @@ public class MusicContainer {
isPause = false;
return;
}
ConfigTools.getConfigPreferences().edit().putInt("playIndex", playIndex).apply();
ConfigTools.getPreferences().edit().putInt("playIndex", playIndex).apply();
nowPlayData = data;
String url = data.getPlayUrl();
previousPlayerList.add(data);
@ -363,9 +362,6 @@ public class MusicContainer {
tmpList.remove(0);
return;
}
if (playIndex < 0 || playIndex > playList.size()) {
playIndex = 0;
}
switch (playModel) {
case PLAY_MODEL_ORDER:
playOrder(false);
@ -387,9 +383,6 @@ public class MusicContainer {
*/
public void playPrevious() {
playIndex--;
if(playIndex<0){
playIndex=0;
}
MusicData data = previousPlayerList.getMusicData();
if (data != null) {
play(data);
@ -408,8 +401,9 @@ public class MusicContainer {
playOfAllRandom();
AppTools.toast("当前播放列表为空,随机播放");
} else {//播放列表中的歌单
ConfigTools.getPreferences().edit().putInt("playModel", MusicContainer.PLAY_MODEL_ORDER).apply();
if (isRandom) {
playIndex = randomPlayIndex();
playIndex = new Random().nextInt(playList.size());
} else {
if (playList.size() > (playIndex + 1)) {
playIndex++;
@ -422,14 +416,6 @@ public class MusicContainer {
}
}
private int randomPlayIndex() {
int tmp = new Random().nextInt(playList.size());
if (tmp == playIndex) {
return randomPlayIndex();
}
return tmp;
}
/**
* 单曲循环
*/
@ -492,10 +478,6 @@ public class MusicContainer {
this.playList.addAll(dataList);
}
public void addPlayList(MusicData data) {
this.playList.add(data);
}
public int getPlayModel() {
return playModel;
}
@ -504,10 +486,6 @@ public class MusicContainer {
return playIndex;
}
public void setPlayIndex(int i) {
this.playIndex = i;
}
public class MusicLibs {
private MusicLibs() {

View File

@ -135,7 +135,7 @@ public class AppTools {
AppData.handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(MyApplication.application, s, Toast.LENGTH_SHORT).show();
Toast.makeText(MyApplication.application, s, Toast.LENGTH_LONG).show();
}
});
}

View File

@ -10,9 +10,5 @@ public class ConfigTools {
public static SharedPreferences getPreferences(){
return MyApplication.application.getSharedPreferences("app_config", Context.MODE_PRIVATE);
}
public static SharedPreferences getConfigPreferences(){
return MyApplication.application.getSharedPreferences("config", Context.MODE_PRIVATE);
}
}