Compare commits
10 Commits
release/1.
...
b04bd7ca5a
| Author | SHA1 | Date | |
|---|---|---|---|
| b04bd7ca5a | |||
| ed47603a29 | |||
| 3ef606b89e | |||
| 6dfaf02422 | |||
| 72c9ce32c0 | |||
| 0dedeaf301 | |||
| 51f1b9494e | |||
| e2285ec1c5 | |||
| 6de3eeeb2f | |||
| 3cc08fc13d |
@@ -12,12 +12,12 @@ android {
|
||||
keyPassword '34864394'
|
||||
}
|
||||
}
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 32
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.yutou.nas_music_player"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 32
|
||||
versionCode 1
|
||||
versionName "1.1"
|
||||
|
||||
@@ -44,14 +44,14 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation 'com.google.android.material:material:1.6.0'
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
|
||||
implementation fileTree(dir: "libs", include: ["*.aar"])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
|
||||
implementation 'androidx.work:work-runtime:2.5.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.work:work-runtime:2.7.1'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
BIN
app/libs/POPDialog-release.aar
Normal file
BIN
app/libs/POPDialog-release.aar
Normal file
Binary file not shown.
@@ -14,9 +14,10 @@
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true">
|
||||
<activity
|
||||
android:screenOrientation="portrait"
|
||||
android:screenOrientation="fullSensor"
|
||||
android:name=".views.OpenActivity"
|
||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -46,7 +47,8 @@
|
||||
<action android:name="android.media.browse.MediaBrowserService" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
<receiver android:name="androidx.media.session.MediaButtonReceiver">
|
||||
<receiver android:name="androidx.media.session.MediaButtonReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
</intent-filter>
|
||||
|
||||
@@ -7,9 +7,11 @@ 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;
|
||||
@@ -19,7 +21,6 @@ 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;
|
||||
@@ -48,13 +49,14 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
public interface OnClickAction {
|
||||
void onClick(Intent intent, View view);
|
||||
}
|
||||
|
||||
protected OnClickAction clickAction;
|
||||
|
||||
public void setOnClickAction(OnClickAction onClickAction) {
|
||||
this.clickAction = onClickAction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<MusicData> list = new ArrayList<>();
|
||||
Context context;
|
||||
MediaBrowserHelper browserHelper;
|
||||
@@ -175,7 +177,17 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
super.bind(data);
|
||||
collectionDir(data);
|
||||
topDir(data);
|
||||
itemView.setOnClickListener(v -> clickAllList(data));
|
||||
itemView.setOnClickListener(v -> {
|
||||
clickAllList(data);
|
||||
}
|
||||
);
|
||||
itemView.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
showPOPWindows(data);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,6 +226,17 @@ 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) {
|
||||
@@ -305,6 +328,7 @@ 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);
|
||||
@@ -411,11 +435,10 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
.setTitle("添加文件夹到队列")
|
||||
.setMessage("将文件夹中所有歌曲添加到队列?")
|
||||
.setPositiveButton("添加", new DialogInterface.OnClickListener() {
|
||||
KProgressHUD hud;
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
hud = AppTools.showLoading(itemView.getContext());
|
||||
AppTools.showHud(itemView.getContext());
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("path", data.getFile());
|
||||
json.put("type", true);
|
||||
@@ -425,14 +448,15 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
||||
List<MusicData> list = (List<MusicData>) data;
|
||||
for (MusicData musicData : list) {
|
||||
MusicContainer.getInstance().addTmpList(musicData);
|
||||
hud.dismiss();
|
||||
}
|
||||
AppTools.hideHud();
|
||||
AppTools.toast(list.size() + "首歌已添加到队列中");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
AppTools.toast("添加失败:" + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -462,5 +486,52 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
*/
|
||||
public class PreviousPlayerList {
|
||||
private static final int INDEX=10;//记录十条
|
||||
private List<MusicData> list;
|
||||
private final List<MusicData> list;
|
||||
public PreviousPlayerList(){
|
||||
list=new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -30,12 +30,16 @@ import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
public class MusicContainer {
|
||||
@@ -68,13 +72,14 @@ public class MusicContainer {
|
||||
collectionMapList = new LinkedHashMap<>();
|
||||
previousPlayerList = new PreviousPlayerList();
|
||||
browserHelpers = new ArrayList<>();
|
||||
playIndex = ConfigTools.getPreferences().getInt("playIndex", -1);
|
||||
playIndex = ConfigTools.getConfigPreferences().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() {
|
||||
@@ -231,7 +236,7 @@ public class MusicContainer {
|
||||
isPause = false;
|
||||
return;
|
||||
}
|
||||
ConfigTools.getPreferences().edit().putInt("playIndex", playIndex).apply();
|
||||
ConfigTools.getConfigPreferences().edit().putInt("playIndex", playIndex).apply();
|
||||
nowPlayData = data;
|
||||
String url = data.getPlayUrl();
|
||||
previousPlayerList.add(data);
|
||||
@@ -358,6 +363,9 @@ public class MusicContainer {
|
||||
tmpList.remove(0);
|
||||
return;
|
||||
}
|
||||
if (playIndex < 0 || playIndex > playList.size()) {
|
||||
playIndex = 0;
|
||||
}
|
||||
switch (playModel) {
|
||||
case PLAY_MODEL_ORDER:
|
||||
playOrder(false);
|
||||
@@ -379,6 +387,9 @@ public class MusicContainer {
|
||||
*/
|
||||
public void playPrevious() {
|
||||
playIndex--;
|
||||
if(playIndex<0){
|
||||
playIndex=0;
|
||||
}
|
||||
MusicData data = previousPlayerList.getMusicData();
|
||||
if (data != null) {
|
||||
play(data);
|
||||
@@ -397,9 +408,8 @@ public class MusicContainer {
|
||||
playOfAllRandom();
|
||||
AppTools.toast("当前播放列表为空,随机播放");
|
||||
} else {//播放列表中的歌单
|
||||
ConfigTools.getPreferences().edit().putInt("playModel", MusicContainer.PLAY_MODEL_ORDER).apply();
|
||||
if (isRandom) {
|
||||
playIndex = new Random().nextInt(playList.size());
|
||||
playIndex = randomPlayIndex();
|
||||
} else {
|
||||
if (playList.size() > (playIndex + 1)) {
|
||||
playIndex++;
|
||||
@@ -412,6 +422,14 @@ public class MusicContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private int randomPlayIndex() {
|
||||
int tmp = new Random().nextInt(playList.size());
|
||||
if (tmp == playIndex) {
|
||||
return randomPlayIndex();
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单曲循环
|
||||
*/
|
||||
@@ -430,10 +448,10 @@ public class MusicContainer {
|
||||
|
||||
public List<MusicData> getPlayList() {
|
||||
System.out.println("playList.size() = " + playList.size() + " tmpList.size() = " + tmpList.size());
|
||||
if (!tmpList.isEmpty()) {
|
||||
return tmpList;
|
||||
}
|
||||
return playList;
|
||||
List<MusicData> tmp = new ArrayList<>();
|
||||
tmp.addAll(tmpList);
|
||||
tmp.addAll(playList);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -474,6 +492,10 @@ public class MusicContainer {
|
||||
this.playList.addAll(dataList);
|
||||
}
|
||||
|
||||
public void addPlayList(MusicData data) {
|
||||
this.playList.add(data);
|
||||
}
|
||||
|
||||
public int getPlayModel() {
|
||||
return playModel;
|
||||
}
|
||||
@@ -482,6 +504,10 @@ public class MusicContainer {
|
||||
return playIndex;
|
||||
}
|
||||
|
||||
public void setPlayIndex(int i) {
|
||||
this.playIndex = i;
|
||||
}
|
||||
|
||||
public class MusicLibs {
|
||||
|
||||
private MusicLibs() {
|
||||
|
||||
@@ -135,7 +135,7 @@ public class AppTools {
|
||||
AppData.handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(MyApplication.application, s, Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(MyApplication.application, s, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,5 +10,9 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class AlbumsActivity extends AppCompatActivity {
|
||||
breakApp.setOnClickListener(v -> finish());
|
||||
playAll.setOnClickListener(v -> {
|
||||
MusicContainer.getInstance().setPlayList(new ArrayList<>(adapter.getMusicDatas()));
|
||||
MusicContainer.getInstance().playNext();
|
||||
browserHelper.play(adapter.getMusicDatas().get(0));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,11 @@ import android.support.v4.media.MediaMetadataCompat;
|
||||
import android.support.v4.media.session.MediaControllerCompat;
|
||||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
@@ -22,10 +24,14 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityOptionsCompat;
|
||||
import androidx.core.util.Pair;
|
||||
import androidx.core.view.GestureDetectorCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.yutou.nas_music_player.Adapters.MusicLibsAdapter;
|
||||
import com.yutou.nas_music_player.Datas.MusicData;
|
||||
import com.yutou.nas_music_player.R;
|
||||
import com.yutou.nas_music_player.containers.MediaBrowserHelper;
|
||||
@@ -33,6 +39,7 @@ import com.yutou.nas_music_player.containers.MusicContainer;
|
||||
import com.yutou.nas_music_player.tools.AppData;
|
||||
import com.yutou.nas_music_player.tools.AppTools;
|
||||
import com.yutou.nas_music_player.tools.ConfigTools;
|
||||
import com.yutou.popdialog.POPDialog;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -51,6 +58,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
private TextView positionTime, durationTime, bitRate, playIndex;
|
||||
private SeekBar seekBar;
|
||||
private Handler handler;
|
||||
|
||||
private GestureDetectorCompat touch;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
@@ -136,45 +146,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
setPlayModelButton(model + 1, true);
|
||||
}
|
||||
});
|
||||
getWindow().getDecorView().setOnTouchListener(new View.OnTouchListener() {
|
||||
float downPosition_x = 0, downPosition_y = 0;
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
downPosition_x = event.getRawX();
|
||||
downPosition_y = event.getRawY();
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
if (Math.abs(downPosition_x - event.getRawX()) < 500 && downPosition_y - event.getRawY() > 500) {
|
||||
Pair<View, String> pImage = Pair.create((View) album_image, "main_album_image");
|
||||
Pair<View, String> pPrevious = Pair.create((View) previous, "previous");
|
||||
Pair<View, String> pPlay = Pair.create((View) play, "play");
|
||||
Pair<View, String> pNext = Pair.create((View) next, "next");
|
||||
Pair<View, String> pTitle = Pair.create((View) title, "title");
|
||||
Pair<View, String> pArtist = Pair.create((View) artist, "artist");
|
||||
Pair<View, String> pBar = Pair.create((View) seekBar, "bar");
|
||||
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this,
|
||||
pImage,
|
||||
pPrevious,
|
||||
pPlay,
|
||||
pNext,
|
||||
pBar,
|
||||
pTitle,
|
||||
pArtist).toBundle();
|
||||
|
||||
Intent intent = new Intent(
|
||||
MainActivity.this, PlayLibsActivity.class);
|
||||
intent.putExtra("bar_pos", seekBar.getProgress());
|
||||
if (bundle != null) {
|
||||
startActivity(intent, bundle);
|
||||
} else {
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
browserHelper = new MediaBrowserHelper(this);
|
||||
browserHelper.regPlayListener(new PlayListener());
|
||||
|
||||
@@ -301,6 +273,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
seekBar = findViewById(R.id.seekBar);
|
||||
playModel = findViewById(R.id.playModel);
|
||||
playIndex = findViewById(R.id.playIndex);
|
||||
touch = new GestureDetectorCompat(this, new MyTouch());
|
||||
int model = ConfigTools.getPreferences().getInt("playModel", MusicContainer.PLAY_MODEL_RANDOM);
|
||||
setPlayModelButton(model);
|
||||
}
|
||||
@@ -341,29 +314,62 @@ public class MainActivity extends AppCompatActivity {
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
float downX = 0;
|
||||
float downY = 0;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
downX = event.getRawX();
|
||||
downY = event.getRawY();
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
pass(event.getRawX(), event.getRawY());
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
return touch.onTouchEvent(event);
|
||||
}
|
||||
|
||||
private void pass(float upX, float upY) {
|
||||
boolean isOkY = Math.abs(upY - downY) <= 200;
|
||||
if (upX - downX > 200 && isOkY) {
|
||||
previous.callOnClick();
|
||||
} else if (upX - downX < -200 && isOkY) {
|
||||
next.callOnClick();
|
||||
private void toPlayList() {
|
||||
Pair<View, String> pImage = Pair.create((View) album_image, "main_album_image");
|
||||
Pair<View, String> pPrevious = Pair.create((View) previous, "previous");
|
||||
Pair<View, String> pPlay = Pair.create((View) play, "play");
|
||||
Pair<View, String> pNext = Pair.create((View) next, "next");
|
||||
Pair<View, String> pTitle = Pair.create((View) title, "title");
|
||||
Pair<View, String> pArtist = Pair.create((View) artist, "artist");
|
||||
Pair<View, String> pBar = Pair.create((View) seekBar, "bar");
|
||||
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this,
|
||||
pImage,
|
||||
pPrevious,
|
||||
pPlay,
|
||||
pNext,
|
||||
pBar,
|
||||
pTitle,
|
||||
pArtist).toBundle();
|
||||
|
||||
Intent intent = new Intent(
|
||||
MainActivity.this, PlayLibsActivity.class);
|
||||
intent.putExtra("bar_pos", seekBar.getProgress());
|
||||
if (bundle != null) {
|
||||
startActivity(intent, bundle);
|
||||
} else {
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void showPOPDialog() {
|
||||
List<MusicData> playList = MusicContainer.getInstance().getPlayList();
|
||||
POPDialog dialog = new POPDialog(this);
|
||||
RecyclerView recyclerView = null;
|
||||
dialog.enableExitButton(true);
|
||||
if (playList.isEmpty()) {
|
||||
dialog.setTitle("播放列表");
|
||||
dialog.setMessage("播放列表为空,正在全列表随机播放");
|
||||
} else {
|
||||
dialog.setTitle("播放列表:" + playList.size());
|
||||
MusicLibsAdapter adapter = new MusicLibsAdapter(this);
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
recyclerView = new RecyclerView(this);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.setLayoutParams(params);
|
||||
recyclerView.setAdapter(adapter);
|
||||
adapter.setData(playList);
|
||||
adapter.setBrowserHelper(browserHelper);
|
||||
dialog.setContentView(recyclerView);
|
||||
}
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private class PlayListener extends MediaControllerCompat.Callback {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
@@ -403,13 +409,30 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onSessionDestroyed() {
|
||||
super.onSessionDestroyed();
|
||||
System.out.println("连接被销毁");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onQueueChanged(List<MediaSessionCompat.QueueItem> queue) {
|
||||
super.onQueueChanged(queue);
|
||||
System.out.println("不知道是啥变换了");
|
||||
}
|
||||
}
|
||||
|
||||
private class MyTouch extends GestureDetector.SimpleOnGestureListener {
|
||||
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
float x = e1.getX() - e2.getX();
|
||||
float y = e1.getY() - e2.getY();
|
||||
if (Math.abs(x) < 200 && y > 300) {
|
||||
showPOPDialog();
|
||||
} else if (Math.abs(x) < 200 && y < -500) {
|
||||
toPlayList();
|
||||
} else if (Math.abs(y) < 200 && x > 300) {
|
||||
next.callOnClick();
|
||||
} else if (Math.abs(y) < 200 && x < -300) {
|
||||
previous.callOnClick();
|
||||
}
|
||||
return super.onFling(e1, e2, velocityX, velocityY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.yutou.nas_music_player.views;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@@ -9,7 +9,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
|
||||
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
||||
Reference in New Issue
Block a user