修改上滑为显示当前播放列表,下滑为库
新增POPDialog组件
This commit is contained in:
parent
6de3eeeb2f
commit
e2285ec1c5
BIN
app/libs/POPDialog-release.aar
Normal file
BIN
app/libs/POPDialog-release.aar
Normal file
Binary file not shown.
@ -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,6 +319,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return touch.onTouchEvent(event);
|
||||
}
|
||||
|
||||
private void toPlayList() {
|
||||
Pair<View, String> pImage = Pair.create((View) album_image, "main_album_image");
|
||||
Pair<View, String> pPrevious = Pair.create((View) previous, "previous");
|
||||
@ -342,6 +347,29 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user