From 0ef923a146612e6bd016fd0a3f8a3d90799d9cc0 Mon Sep 17 00:00:00 2001
From: mahsiat-atiye <atieh.atieh.jamshidpoor@gmail.com>
Date: Mon, 22 Jun 2020 17:45:20 +0430
Subject: [PATCH] At ten second skip like youtube #827 Pause & Play on tapping
 screen like youtube #833

---
 .../player/PlayerAlbumCoverFragment.java      | 38 ++++++++++++++++++-
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/fragments/player/PlayerAlbumCoverFragment.java b/app/src/main/java/com/kabouzeid/gramophone/ui/fragments/player/PlayerAlbumCoverFragment.java
index 814483bd5..0cb826ae4 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/ui/fragments/player/PlayerAlbumCoverFragment.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/ui/fragments/player/PlayerAlbumCoverFragment.java
@@ -2,8 +2,11 @@
 
 import android.animation.Animator;
 import android.os.Bundle;
+
 import androidx.annotation.NonNull;
 import androidx.viewpager.widget.ViewPager;
+
+import android.util.Log;
 import android.view.GestureDetector;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -14,6 +17,7 @@
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import com.kabouzeid.gramophone.R;
 import com.kabouzeid.gramophone.adapter.AlbumCoverPagerAdapter;
@@ -57,6 +61,7 @@ public class PlayerAlbumCoverFragment extends AbsMusicServiceFragment implements
     private Lyrics lyrics;
     private MusicProgressViewUpdateHelper progressViewUpdateHelper;
 
+
     @Override
     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         View view = inflater.inflate(R.layout.fragment_player_album_cover, container, false);
@@ -66,12 +71,35 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
 
     @Override
     public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
+        Log.d("test18", "onViewCreated: player album");
         super.onViewCreated(view, savedInstanceState);
         viewPager.addOnPageChangeListener(this);
         viewPager.setOnTouchListener(new View.OnTouchListener() {
             GestureDetector gestureDetector = new GestureDetector(getActivity(), new GestureDetector.SimpleOnGestureListener() {
+                @Override
+                public boolean onDoubleTap(MotionEvent e) {
+                    int futurePosition = MusicPlayerRemote.getSongProgressMillis() + 10000;
+                    if (futurePosition <= MusicPlayerRemote.getSongDurationMillis()) {
+                        MusicPlayerRemote.seekTo(futurePosition);
+                        onUpdateProgressViews(MusicPlayerRemote.getSongProgressMillis(), MusicPlayerRemote.getSongDurationMillis());
+                    }
+                    return super.onDoubleTap(e);
+                }
+
+                @Override
+                public boolean onDoubleTapEvent(MotionEvent e) {
+                    return super.onDoubleTapEvent(e);
+                }
+
                 @Override
                 public boolean onSingleTapConfirmed(MotionEvent e) {
+//                    todo
+                    if (MusicPlayerRemote.isPlaying()) {
+                        MusicPlayerRemote.pauseSong();
+                    } else {
+                        MusicPlayerRemote.resumePlaying();
+                    }
+
                     if (callbacks != null) {
                         callbacks.onToolbarToggled();
                         return true;
@@ -131,6 +159,7 @@ public void onPageSelected(int position) {
         }
     }
 
+
     private AlbumCoverPagerAdapter.AlbumCoverFragment.ColorReceiver colorReceiver = new AlbumCoverPagerAdapter.AlbumCoverFragment.ColorReceiver() {
         @Override
         public void onColorReady(int color, int requestCode) {
@@ -220,14 +249,18 @@ public void setCallbacks(Callbacks listener) {
 
     @Override
     public void onUpdateProgressViews(int progress, int total) {
-        if (!isLyricsLayoutBound()) return;
+        if (!isLyricsLayoutBound()) {
+            return;
+        }
 
         if (!isLyricsLayoutVisible()) {
             hideLyricsLayout();
             return;
         }
 
-        if (!(lyrics instanceof AbsSynchronizedLyrics)) return;
+        if (!(lyrics instanceof AbsSynchronizedLyrics)) {
+            return;
+        }
         AbsSynchronizedLyrics synchronizedLyrics = (AbsSynchronizedLyrics) lyrics;
 
         lyricsLayout.setVisibility(View.VISIBLE);
@@ -237,6 +270,7 @@ public void onUpdateProgressViews(int progress, int total) {
         String line = synchronizedLyrics.getLine(progress);
 
         if (!oldLine.equals(line) || oldLine.isEmpty()) {
+
             lyricsLine1.setText(oldLine);
             lyricsLine2.setText(line);