mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Preparation to music streaming - Picking from Gelli
This commit is contained in:
parent
a28ad27288
commit
820f783d01
18 changed files with 1921 additions and 87 deletions
|
|
@ -135,7 +135,7 @@ public class MainActivity extends BaseActivity {
|
|||
* lo chiudo
|
||||
*/
|
||||
navController.addOnDestinationChangedListener((controller, destination, arguments) -> {
|
||||
if(bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED && (
|
||||
if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED && (
|
||||
destination.getId() == R.id.homeFragment ||
|
||||
destination.getId() == R.id.libraryFragment ||
|
||||
destination.getId() == R.id.searchFragment ||
|
||||
|
|
@ -164,32 +164,32 @@ public class MainActivity extends BaseActivity {
|
|||
}
|
||||
|
||||
private BottomSheetBehavior.BottomSheetCallback bottomSheetCallback =
|
||||
new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View view, int state) {
|
||||
switch (state) {
|
||||
case BottomSheetBehavior.STATE_SETTLING:
|
||||
PlayerBottomSheetFragment playerBottomSheetFragment = (PlayerBottomSheetFragment) getSupportFragmentManager().findFragmentByTag("PlayerBottomSheet");
|
||||
if(playerBottomSheetFragment == null) break;
|
||||
new BottomSheetBehavior.BottomSheetCallback() {
|
||||
@Override
|
||||
public void onStateChanged(@NonNull View view, int state) {
|
||||
switch (state) {
|
||||
case BottomSheetBehavior.STATE_SETTLING:
|
||||
PlayerBottomSheetFragment playerBottomSheetFragment = (PlayerBottomSheetFragment) getSupportFragmentManager().findFragmentByTag("PlayerBottomSheet");
|
||||
if (playerBottomSheetFragment == null) break;
|
||||
|
||||
playerBottomSheetFragment.scrollOnTop();
|
||||
break;
|
||||
case BottomSheetBehavior.STATE_HIDDEN:
|
||||
mainViewModel.deleteQueue();
|
||||
break;
|
||||
playerBottomSheetFragment.scrollOnTop();
|
||||
break;
|
||||
case BottomSheetBehavior.STATE_HIDDEN:
|
||||
mainViewModel.deleteQueue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlide(@NonNull View view, float slideOffset) {
|
||||
PlayerBottomSheetFragment playerBottomSheetFragment = (PlayerBottomSheetFragment) getSupportFragmentManager().findFragmentByTag("PlayerBottomSheet");
|
||||
if(playerBottomSheetFragment == null) return;
|
||||
@Override
|
||||
public void onSlide(@NonNull View view, float slideOffset) {
|
||||
PlayerBottomSheetFragment playerBottomSheetFragment = (PlayerBottomSheetFragment) getSupportFragmentManager().findFragmentByTag("PlayerBottomSheet");
|
||||
if (playerBottomSheetFragment == null) return;
|
||||
|
||||
float condensedSlideOffset = Math.max(0.0f, Math.min(0.2f, slideOffset - 0.2f)) / 0.2f;
|
||||
playerBottomSheetFragment.getPlayerHeader().setAlpha(1 - condensedSlideOffset);
|
||||
playerBottomSheetFragment.getPlayerHeader().setVisibility(condensedSlideOffset > 0.99 ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
};
|
||||
float condensedSlideOffset = Math.max(0.0f, Math.min(0.2f, slideOffset - 0.2f)) / 0.2f;
|
||||
playerBottomSheetFragment.getPlayerHeader().setAlpha(1 - condensedSlideOffset);
|
||||
playerBottomSheetFragment.getPlayerHeader().setVisibility(condensedSlideOffset > 0.99 ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Scroll on top del bottom sheet quando chiudo
|
||||
|
|
@ -197,7 +197,7 @@ public class MainActivity extends BaseActivity {
|
|||
*/
|
||||
public void setBottomSheetMusicInfo(Song song) {
|
||||
PlayerBottomSheetFragment playerBottomSheetFragment = (PlayerBottomSheetFragment) getSupportFragmentManager().findFragmentByTag("PlayerBottomSheet");
|
||||
if(playerBottomSheetFragment == null) return;
|
||||
if (playerBottomSheetFragment == null) return;
|
||||
|
||||
playerBottomSheetFragment.scrollPager(song, 0, false);
|
||||
}
|
||||
|
|
@ -246,7 +246,7 @@ public class MainActivity extends BaseActivity {
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if(bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
|
||||
if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
|
||||
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
else
|
||||
super.onBackPressed();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
@ -20,7 +19,6 @@ import com.cappielloantonio.play.adapter.PlayerSongQueueAdapter;
|
|||
import com.cappielloantonio.play.databinding.FragmentPlayerBottomSheetBinding;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activities.MainActivity;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.viewmodel.PlayerBottomSheetViewModel;
|
||||
|
||||
public class PlayerBottomSheetFragment extends Fragment {
|
||||
|
|
@ -98,7 +96,7 @@ public class PlayerBottomSheetFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void playSong(Song song) {
|
||||
Toast.makeText(activity, MusicUtil.getSongFileUri(song), Toast.LENGTH_SHORT).show();
|
||||
// Toast.makeText(activity, MusicUtil.getSongFileUri(song), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
public View getPlayerHeader() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue