diff --git a/app/libs/POPDialog-release.aar b/app/libs/POPDialog-release.aar new file mode 100644 index 0000000..8798a58 Binary files /dev/null and b/app/libs/POPDialog-release.aar differ diff --git a/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java b/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java index d7c7ccd..e51d371 100644 --- a/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java +++ b/app/src/main/java/com/yutou/nas_music_player/views/MainActivity.java @@ -13,6 +13,7 @@ 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; @@ -24,10 +25,13 @@ 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; @@ -315,7 +319,8 @@ public class MainActivity extends AppCompatActivity { public boolean onTouchEvent(MotionEvent event) { return touch.onTouchEvent(event); } - private void toPlayList(){ + + private void toPlayList() { Pair pImage = Pair.create((View) album_image, "main_album_image"); Pair pPrevious = Pair.create((View) previous, "previous"); Pair pPlay = Pair.create((View) play, "play"); @@ -342,6 +347,29 @@ public class MainActivity extends AppCompatActivity { } } + private void showPOPDialog() { + List 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 @@ -397,17 +425,14 @@ public class MainActivity extends AppCompatActivity { 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 > 500) { - System.out.println("上"); + if (Math.abs(x) < 200 && y > 300) { + showPOPDialog(); } else if (Math.abs(x) < 200 && y < -500) { toPlayList(); - System.out.println("下"); } else if (Math.abs(y) < 200 && x > 300) { next.callOnClick(); - System.out.println("右"); } else if (Math.abs(y) < 200 && x < -300) { previous.callOnClick(); - System.out.println("左"); } return super.onFling(e1, e2, velocityX, velocityY); }