Skip to content

Commit c92540d

Browse files
committed
Update UI logic, naming, and audio device selection
Refactored method names for C# conventions and improved adapter setup logic in HomePageFragment. Enhanced queue scrolling behavior and replaced info pill with audio device selection dialog in NowPlayingFragment, including null checks and cancel option. Added debug output in SongAdapter, made SongDetailFragment partial, and adjusted null handling in SongOverviewFragment.
1 parent 7898f2f commit c92540d

File tree

7 files changed

+39
-26
lines changed

7 files changed

+39
-26
lines changed

Dimmer/Dimmer.Droid/ViewsAndPages/NativeViews/Activity/TransitionActivity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected override void OnCreate(Bundle? savedInstanceState)
157157
private SmoothBottomBar _bottomBar;
158158

159159

160-
public static void hideKeyboard(TransitionActivity activity)
160+
public static void HideKeyboard(TransitionActivity activity)
161161
{
162162

163163
InputMethodManager? imm = (InputMethodManager?)activity.GetSystemService(InputMethodService);

Dimmer/Dimmer.Droid/ViewsAndPages/NativeViews/HomePageFragment.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,7 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup? container,
308308
_songListRecycler.SetPadding(0, 0, 0, AppUtil.DpToPx(160));
309309
_songListRecycler.SetClipToPadding(false);
310310

311-
if (MyViewModel.SearchResults.Count > 0)
312-
{
313-
_adapter = new SongAdapter(ctx, MyViewModel, this);
314-
_songListRecycler.SetAdapter(_adapter);
315-
316-
317-
318-
// Add Recycler to Content
319311
contentLinear.AddView(_songListRecycler);
320-
}
321312
//contentLinear.AddView(pagerView);
322313

323314
// Add Content to Root
@@ -508,9 +499,16 @@ public override void OnResume()
508499

509500
default:
510501
var songCount = MyViewModel.SearchResults.Count;
511-
if (songCount > 1)
502+
if (songCount >= 1)
512503
{
513504
songsTotal.Text = $"{MyViewModel.SearchResults.Count} Songs";
505+
506+
if (MyViewModel.SearchResults.Count > 0)
507+
{
508+
_adapter = new SongAdapter(this.View.Context, MyViewModel, this);
509+
_songListRecycler.SetAdapter(_adapter);
510+
511+
}
514512
}
515513
else if (songCount == 1)
516514
{

Dimmer/Dimmer.Droid/ViewsAndPages/NativeViews/Misc/PlaybackQueueBottomSheet.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,13 @@ public void ScrollToSong(SongModelView? requestedSong=null)
189189
var index = MyViewModel.PlaybackQueue.IndexOf(requestedSong);
190190
if (_pendingScrollToCurrent)
191191
{
192-
_recyclerView.ScrollToPosition(index);
192+
_recyclerView.SmoothScrollToPosition(index-3);
193193
_pendingScrollToCurrent = false;
194194
}
195195
else
196196
{
197-
_recyclerView.ScrollToPosition(index);
197+
_recyclerView.SmoothScrollToPosition(index-3);
198+
_pendingScrollToCurrent = false;
198199
//_recyclerView.SmoothScrollToPosition(index);
199200
}
200201
}

Dimmer/Dimmer.Droid/ViewsAndPages/NativeViews/NowPlayingFragment.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public partial class NowPlayingFragment : Fragment, IOnBackInvokedCallback
6868
public DimmerSliderListener SeekListener { get; private set; }
6969
public CardView formatCard { get; private set; }
7070
public TextView formatViewText { get; private set; }
71-
public Button infoPill { get; private set; }
71+
public Button audioDevicesPill { get; private set; }
7272
public Chip SelectedAudioTextView { get; private set; }
7373

7474
public NowPlayingFragment()
@@ -146,6 +146,7 @@ private LinearLayout CreateMiniPlayer(Context ctx)
146146
ViewCompat.SetTransitionName(_miniCover, tName);
147147
card.Click += (s, e) =>
148148
{
149+
if (string.IsNullOrEmpty(MyViewModel.CurrentPlayingSongView.TitleDurationKey)) return;
149150
string? tName = ViewCompat.GetTransitionName(_miniCover);
150151
if (tName != null)
151152
{
@@ -461,10 +462,7 @@ private ScrollView CreateExpandedPlayer(Context ctx)
461462
SelectedAudioTextView.Text = MyViewModel.SelectedAudioDevice?.Name;
462463
SelectedAudioTextView.Click += (s, e) =>
463464
{
464-
var dialog = ShowDifferentAudioDevicesDialog();
465465

466-
467-
dialog.Show();
468466
};
469467
//volumeRow.AddView(_volumeSlider, new LinearLayout.LayoutParams(0, -2, 1f)); // Stretch slider
470468
//volumeRow.AddView(volUpIcon, new LinearLayout.LayoutParams(AppUtil.DpToPx(24), AppUtil.DpToPx(24)));
@@ -506,6 +504,8 @@ private ScrollView CreateExpandedPlayer(Context ctx)
506504
var queueSheet = new QueueBottomSheetFragment(MyViewModel, _queueBtn);
507505
_queueBtn.Enabled = false;
508506
queueSheet.Show(ParentFragmentManager, "QueueSheet");
507+
508+
await Task.Delay(1200);
509509
queueSheet.ScrollToSong(MyViewModel.CurrentPlayingSongView);
510510
};
511511

@@ -594,10 +594,13 @@ private ScrollView CreateExpandedPlayer(Context ctx)
594594
}
595595
};
596596

597-
infoPill = CreatePillButton(ctx, "Info", Resource.Drawable.infocircle);
598-
infoPill.Click += (s, e) =>
597+
audioDevicesPill = CreatePillButton(ctx, "Info", Resource.Drawable.ic_vol_type_speaker_dark);
598+
audioDevicesPill.Click += (s, e) =>
599599
{
600-
600+
var dialog = ShowDifferentAudioDevicesDialog();
601+
602+
603+
dialog?.Show();
601604
};
602605

603606
// Distribute evenly with weights or margins
@@ -607,7 +610,7 @@ private ScrollView CreateExpandedPlayer(Context ctx)
607610
pillsRow.AddView(_queueBtn, pillParams);
608611
pillsRow.AddView(_loveBtn, pillParams);
609612
pillsRow.AddView(_toggleLyricsViewBtn, pillParams);
610-
pillsRow.AddView(infoPill, pillParams);
613+
pillsRow.AddView(audioDevicesPill, pillParams);
611614
root.AddView(pillsRow);
612615

613616
//// --- F. Bottom Actions (Queue, View Song, Options) ---
@@ -729,9 +732,11 @@ private void UpdateLoveBtnUI(bool isChecked)
729732
}
730733
}
731734

732-
public MaterialAlertDialogBuilder ShowDifferentAudioDevicesDialog()
735+
public MaterialAlertDialogBuilder? ShowDifferentAudioDevicesDialog()
733736
{
734-
var builder = new MaterialAlertDialogBuilder(Activity);
737+
if (MyViewModel.AudioDevices is null) return null;
738+
if (MyViewModel.SelectedAudioDevice is null) return null;
739+
var builder = new MaterialAlertDialogBuilder(Activity!);
735740
builder.SetTitle("Select Audio Device");
736741

737742
var albumNamesArray = MyViewModel.AudioDevices.Select(x=>x.Name).ToArray();
@@ -745,6 +750,7 @@ public MaterialAlertDialogBuilder ShowDifferentAudioDevicesDialog()
745750

746751

747752
});
753+
748754
builder.SetNegativeButton("Cancel", (sender, args) =>
749755
{
750756
//Dismiss();
@@ -776,6 +782,8 @@ private MaterialButton CreatePillButton(Context ctx, string text, int iconRes)
776782
btn.IconPadding = AppUtil.DpToPx(4);
777783
btn.CornerRadius = AppUtil.DpToPx(50); // Fully rounded (Pill)
778784
btn.SetPadding(AppUtil.DpToPx(12), 0, AppUtil.DpToPx(12), 0);
785+
//btn.SetHeight(AppUtil.DpToPx(23));
786+
//btn.SetWidth(AppUtil.DpToPx(23));
779787
btn.TextSize = 14;
780788
btn.SetSingleLine(true);
781789
btn.Ellipsize = Android.Text.TextUtils.TruncateAt.End;

Dimmer/Dimmer.Droid/ViewsAndPages/NativeViews/SingleSong/SongDetailFragment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Dimmer.ViewsAndPages.NativeViews.SingleSong;
1717

18-
public class SongDetailFragment : Fragment , IOnBackInvokedCallback
18+
public partial class SongDetailFragment : Fragment , IOnBackInvokedCallback
1919
{
2020
private readonly string _transitionName;
2121
private readonly BaseViewModelAnd _viewModel;

Dimmer/Dimmer.Droid/ViewsAndPages/NativeViews/SingleSong/SongOverviewFragment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup? container,
6767

6868

6969

70-
List<ArtistModelView?> artists = MyViewModel.SelectedSong!.ArtistsInDB(MyViewModel.RealmFactory)!;
70+
List<ArtistModelView?> artists = MyViewModel.SelectedSong.ArtistsInDB(MyViewModel.RealmFactory)!;
7171
foreach (var art in artists)
7272
{
7373
if (art is null) continue;

Dimmer/Dimmer.Droid/ViewsAndPages/NativeViews/SongAdapter.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ private void SetupReactivePipeline(BaseViewModelAnd myViewModel, string songsToW
122122
{
123123

124124
sourceStream
125-
.ObserveOn(RxSchedulers.UI) // Must be on UI thread to update RecyclerView
125+
.ObserveOn(RxSchedulers.UI)
126+
.Do(s =>
127+
{
128+
129+
130+
Debug.WriteLine(MyViewModel.SearchResults.Count);
131+
})// Must be on UI thread to update RecyclerView
126132
.Bind(out _songs) // Automatically keeps _songs in sync with the source
127133
.Subscribe(changes =>
128134
{

0 commit comments

Comments
 (0)