Compare commits
7 Commits
release/1.
...
6dfaf02422
| Author | SHA1 | Date | |
|---|---|---|---|
| 6dfaf02422 | |||
| 72c9ce32c0 | |||
| 0dedeaf301 | |||
| 51f1b9494e | |||
| e2285ec1c5 | |||
| 6de3eeeb2f | |||
| 3cc08fc13d |
@@ -12,12 +12,12 @@ android {
|
|||||||
keyPassword '34864394'
|
keyPassword '34864394'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileSdkVersion 30
|
compileSdkVersion 32
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.yutou.nas_music_player"
|
applicationId "com.yutou.nas_music_player"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 30
|
targetSdkVersion 32
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.1"
|
versionName "1.1"
|
||||||
|
|
||||||
@@ -44,14 +44,14 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.google.android.material:material:1.4.0'
|
implementation 'com.google.android.material:material:1.6.0'
|
||||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
|
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.aar"])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||||
implementation 'androidx.work:work-runtime:2.5.0'
|
implementation 'androidx.work:work-runtime:2.7.1'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.0'
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
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:theme="@style/AppTheme"
|
||||||
android:usesCleartextTraffic="true">
|
android:usesCleartextTraffic="true">
|
||||||
<activity
|
<activity
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="fullSensor"
|
||||||
android:name=".views.OpenActivity"
|
android:name=".views.OpenActivity"
|
||||||
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar">
|
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
@@ -46,7 +47,8 @@
|
|||||||
<action android:name="android.media.browse.MediaBrowserService" />
|
<action android:name="android.media.browse.MediaBrowserService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
<receiver android:name="androidx.media.session.MediaButtonReceiver">
|
<receiver android:name="androidx.media.session.MediaButtonReceiver"
|
||||||
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|||||||
@@ -45,14 +45,15 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
public static final int LIBS_MODEL_PLAY_LIST = 4;
|
public static final int LIBS_MODEL_PLAY_LIST = 4;
|
||||||
public static final int LIBS_MODEL_PLAY_Collection = 5;
|
public static final int LIBS_MODEL_PLAY_Collection = 5;
|
||||||
|
|
||||||
public interface OnClickAction{
|
public interface OnClickAction {
|
||||||
void onClick(Intent intent,View view);
|
void onClick(Intent intent, View view);
|
||||||
}
|
|
||||||
protected OnClickAction clickAction;
|
|
||||||
public void setOnClickAction(OnClickAction onClickAction) {
|
|
||||||
this.clickAction=onClickAction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected OnClickAction clickAction;
|
||||||
|
|
||||||
|
public void setOnClickAction(OnClickAction onClickAction) {
|
||||||
|
this.clickAction = onClickAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
List<MusicData> list = new ArrayList<>();
|
List<MusicData> list = new ArrayList<>();
|
||||||
@@ -141,7 +142,7 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setModel(int model) {
|
public void setModel(int model) {
|
||||||
this.model=model;
|
this.model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ViewHolderCollection extends ViewHolder {
|
public class ViewHolderCollection extends ViewHolder {
|
||||||
@@ -298,9 +299,9 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
Intent intent = new Intent(itemView.getContext(), AlbumsActivity.class);
|
Intent intent = new Intent(itemView.getContext(), AlbumsActivity.class);
|
||||||
intent.putExtra("model", 2);
|
intent.putExtra("model", 2);
|
||||||
intent.putExtra("fid", data.getId());
|
intent.putExtra("fid", data.getId());
|
||||||
intent.putExtra("image",data.getImg(AppData.imageWidth, AppData.imageHigh));
|
intent.putExtra("image", data.getImg(AppData.imageWidth, AppData.imageHigh));
|
||||||
if(clickAction!=null){
|
if (clickAction != null) {
|
||||||
clickAction.onClick(intent,icon);
|
clickAction.onClick(intent, icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,10 +311,10 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
Intent intent = new Intent(itemView.getContext(), AlbumsActivity.class);
|
Intent intent = new Intent(itemView.getContext(), AlbumsActivity.class);
|
||||||
intent.putExtra("model", 0);
|
intent.putExtra("model", 0);
|
||||||
intent.putExtra("album", data.getAlbum());
|
intent.putExtra("album", data.getAlbum());
|
||||||
intent.putExtra("image",data.getImg(AppData.imageWidth, AppData.imageHigh));
|
intent.putExtra("image", data.getImg(AppData.imageWidth, AppData.imageHigh));
|
||||||
intent.putExtra("color",AppTools.getImageColor(data.getImg(AppData.minImageWidth,AppData.minImageHigh)));
|
intent.putExtra("color", AppTools.getImageColor(data.getImg(AppData.minImageWidth, AppData.minImageHigh)));
|
||||||
if(clickAction!=null){
|
if (clickAction != null) {
|
||||||
clickAction.onClick(intent,icon);
|
clickAction.onClick(intent, icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,8 +367,8 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
icon.setOnClickListener(new View.OnClickListener() {
|
icon.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (data.getImg(AppData.minImageWidth,AppData.minImageHigh) != null) {
|
if (data.getImg(AppData.minImageWidth, AppData.minImageHigh) != null) {
|
||||||
Glide.with(MyApplication.application).load(data.getImg(AppData.minImageWidth,AppData.minImageHigh))
|
Glide.with(MyApplication.application).load(data.getImg(AppData.minImageWidth, AppData.minImageHigh))
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
||||||
.into(icon);
|
.into(icon);
|
||||||
icon.setTag("img");
|
icon.setTag("img");
|
||||||
@@ -411,11 +412,10 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
.setTitle("添加文件夹到队列")
|
.setTitle("添加文件夹到队列")
|
||||||
.setMessage("将文件夹中所有歌曲添加到队列?")
|
.setMessage("将文件夹中所有歌曲添加到队列?")
|
||||||
.setPositiveButton("添加", new DialogInterface.OnClickListener() {
|
.setPositiveButton("添加", new DialogInterface.OnClickListener() {
|
||||||
KProgressHUD hud;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
hud = AppTools.showLoading(itemView.getContext());
|
AppTools.showHud(itemView.getContext());
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("path", data.getFile());
|
json.put("path", data.getFile());
|
||||||
json.put("type", true);
|
json.put("type", true);
|
||||||
@@ -425,14 +425,15 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
List<MusicData> list = (List<MusicData>) data;
|
List<MusicData> list = (List<MusicData>) data;
|
||||||
for (MusicData musicData : list) {
|
for (MusicData musicData : list) {
|
||||||
MusicContainer.getInstance().addTmpList(musicData);
|
MusicContainer.getInstance().addTmpList(musicData);
|
||||||
hud.dismiss();
|
|
||||||
}
|
}
|
||||||
|
AppTools.hideHud();
|
||||||
|
AppTools.toast(list.size()+"首歌已添加到队列中");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void httpError(Exception e) {
|
public void httpError(Exception e) {
|
||||||
|
AppTools.toast("添加失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -448,7 +449,7 @@ public class MusicLibsAdapter extends RecyclerView.Adapter<MusicLibsAdapter.View
|
|||||||
|
|
||||||
|
|
||||||
protected void showImage(MusicData musicData, ViewHolder holder) {
|
protected void showImage(MusicData musicData, ViewHolder holder) {
|
||||||
musicData.getImg(AppData.minImageWidth,AppData.minImageHigh, new NetworkInterface() {
|
musicData.getImg(AppData.minImageWidth, AppData.minImageHigh, new NetworkInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void httpGetData(Object data, int state) {
|
public void httpGetData(Object data, int state) {
|
||||||
Glide.with(MyApplication.application).load((Bitmap) data)
|
Glide.with(MyApplication.application).load((Bitmap) data)
|
||||||
|
|||||||
@@ -30,12 +30,16 @@ import java.io.IOException;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
public class MusicContainer {
|
public class MusicContainer {
|
||||||
@@ -430,10 +434,10 @@ public class MusicContainer {
|
|||||||
|
|
||||||
public List<MusicData> getPlayList() {
|
public List<MusicData> getPlayList() {
|
||||||
System.out.println("playList.size() = " + playList.size() + " tmpList.size() = " + tmpList.size());
|
System.out.println("playList.size() = " + playList.size() + " tmpList.size() = " + tmpList.size());
|
||||||
if (!tmpList.isEmpty()) {
|
List<MusicData> tmp=new ArrayList<>();
|
||||||
return tmpList;
|
tmp.addAll(tmpList);
|
||||||
}
|
tmp.addAll(playList);
|
||||||
return playList;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ public class AlbumsActivity extends AppCompatActivity {
|
|||||||
breakApp.setOnClickListener(v -> finish());
|
breakApp.setOnClickListener(v -> finish());
|
||||||
playAll.setOnClickListener(v -> {
|
playAll.setOnClickListener(v -> {
|
||||||
MusicContainer.getInstance().setPlayList(new ArrayList<>(adapter.getMusicDatas()));
|
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.MediaControllerCompat;
|
||||||
import android.support.v4.media.session.MediaSessionCompat;
|
import android.support.v4.media.session.MediaSessionCompat;
|
||||||
import android.support.v4.media.session.PlaybackStateCompat;
|
import android.support.v4.media.session.PlaybackStateCompat;
|
||||||
|
import android.view.GestureDetector;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -22,10 +24,14 @@ import android.widget.Toast;
|
|||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.app.ActivityOptionsCompat;
|
import androidx.core.app.ActivityOptionsCompat;
|
||||||
import androidx.core.util.Pair;
|
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.alibaba.fastjson.JSON;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
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.Datas.MusicData;
|
||||||
import com.yutou.nas_music_player.R;
|
import com.yutou.nas_music_player.R;
|
||||||
import com.yutou.nas_music_player.containers.MediaBrowserHelper;
|
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.AppData;
|
||||||
import com.yutou.nas_music_player.tools.AppTools;
|
import com.yutou.nas_music_player.tools.AppTools;
|
||||||
import com.yutou.nas_music_player.tools.ConfigTools;
|
import com.yutou.nas_music_player.tools.ConfigTools;
|
||||||
|
import com.yutou.popdialog.POPDialog;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -51,6 +58,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private TextView positionTime, durationTime, bitRate, playIndex;
|
private TextView positionTime, durationTime, bitRate, playIndex;
|
||||||
private SeekBar seekBar;
|
private SeekBar seekBar;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
|
|
||||||
|
private GestureDetectorCompat touch;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||||
@@ -130,51 +140,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int model = (int) playModel.getTag();
|
int model = (int) playModel.getTag();
|
||||||
if (model == MusicContainer.PLAY_MODEL_LIST_RANDOM) {
|
if (model == MusicContainer.PLAY_MODEL_LIST_RANDOM) {
|
||||||
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM,true);
|
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setPlayModelButton(model + 1,true);
|
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 = new MediaBrowserHelper(this);
|
||||||
browserHelper.regPlayListener(new PlayListener());
|
browserHelper.regPlayListener(new PlayListener());
|
||||||
|
|
||||||
@@ -270,7 +242,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
AppTools.toast("列表随机");
|
AppTools.toast("列表随机");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM,isButton);
|
setPlayModelButton(MusicContainer.PLAY_MODEL_RANDOM, isButton);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ConfigTools.getPreferences().edit().putInt("playModel", model).apply();
|
ConfigTools.getPreferences().edit().putInt("playModel", model).apply();
|
||||||
@@ -301,6 +273,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
seekBar = findViewById(R.id.seekBar);
|
seekBar = findViewById(R.id.seekBar);
|
||||||
playModel = findViewById(R.id.playModel);
|
playModel = findViewById(R.id.playModel);
|
||||||
playIndex = findViewById(R.id.playIndex);
|
playIndex = findViewById(R.id.playIndex);
|
||||||
|
touch = new GestureDetectorCompat(this, new MyTouch());
|
||||||
int model = ConfigTools.getPreferences().getInt("playModel", MusicContainer.PLAY_MODEL_RANDOM);
|
int model = ConfigTools.getPreferences().getInt("playModel", MusicContainer.PLAY_MODEL_RANDOM);
|
||||||
setPlayModelButton(model);
|
setPlayModelButton(model);
|
||||||
}
|
}
|
||||||
@@ -341,29 +314,62 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return super.onKeyUp(keyCode, event);
|
return super.onKeyUp(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
float downX = 0;
|
|
||||||
float downY = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
return touch.onTouchEvent(event);
|
||||||
downX = event.getRawX();
|
|
||||||
downY = event.getRawY();
|
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_UP) {
|
|
||||||
pass(event.getRawX(), event.getRawY());
|
|
||||||
}
|
|
||||||
return super.onTouchEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pass(float upX, float upY) {
|
private void toPlayList() {
|
||||||
boolean isOkY = Math.abs(upY - downY) <= 200;
|
Pair<View, String> pImage = Pair.create((View) album_image, "main_album_image");
|
||||||
if (upX - downX > 200 && isOkY) {
|
Pair<View, String> pPrevious = Pair.create((View) previous, "previous");
|
||||||
previous.callOnClick();
|
Pair<View, String> pPlay = Pair.create((View) play, "play");
|
||||||
} else if (upX - downX < -200 && isOkY) {
|
Pair<View, String> pNext = Pair.create((View) next, "next");
|
||||||
next.callOnClick();
|
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 {
|
private class PlayListener extends MediaControllerCompat.Callback {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
@@ -403,13 +409,30 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onSessionDestroyed() {
|
public void onSessionDestroyed() {
|
||||||
super.onSessionDestroyed();
|
super.onSessionDestroyed();
|
||||||
System.out.println("连接被销毁");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onQueueChanged(List<MediaSessionCompat.QueueItem> queue) {
|
public void onQueueChanged(List<MediaSessionCompat.QueueItem> queue) {
|
||||||
super.onQueueChanged(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.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ buildscript {
|
|||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
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
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
Reference in New Issue
Block a user