Skip to content

Commit

Permalink
Android: Changed look of secondary menu in Artist cell. Now aligned w…
Browse files Browse the repository at this point in the history
…ith album art. However adding ImageButton seems to have blocked selecting the cell when the buttons are visible (just like the grid view...)

Related to issue #406.
  • Loading branch information
ycastonguay committed Sep 9, 2013
1 parent c652373 commit b5529bb
Show file tree
Hide file tree
Showing 5 changed files with 305 additions and 271 deletions.
Expand Up @@ -81,14 +81,15 @@ public override View GetView(int position, View convertView, ViewGroup parent)

var layoutAlbums = view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowserCell_layoutAlbums);
var layoutSubtitle = view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowserCell_layoutSubtitle);
var layoutMenu = view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowserCell_layoutMenu);
var lblTitle = view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowserCell_lblTitle);
var lblTitleWithSubtitle = view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowserCell_lblTitleWithSubtitle);
var lblSubtitle = view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowserCell_lblSubtitle);
var index = view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowserCell_index);
var imageNowPlaying = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageNowPlaying);
var btnAdd = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageAdd);
var btnPlay = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imagePlay);
var btnDelete = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageDelete);
var btnAdd = view.FindViewById<ImageButton>(Resource.Id.mobileLibraryBrowserCell_imageAdd);
var btnPlay = view.FindViewById<ImageButton>(Resource.Id.mobileLibraryBrowserCell_imagePlay);
var btnDelete = view.FindViewById<ImageButton>(Resource.Id.mobileLibraryBrowserCell_imageDelete);
var layoutAlbumCount = view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowserCell_layoutAlbumCount);
var lblAlbumCount = view.FindViewById<TextView>(Resource.Id.mobileLibraryBrowserCell_lblAlbumCount);
var imageAlbum1 = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageAlbum1);
Expand All @@ -109,12 +110,14 @@ public override View GetView(int position, View convertView, ViewGroup parent)

if (IsEditingRow && position == _editingRowPosition)
{
layoutMenu.Visibility = ViewStates.Visible;
btnAdd.Visibility = ViewStates.Visible;
btnPlay.Visibility = ViewStates.Visible;
btnDelete.Visibility = ViewStates.Visible;
}
else
{
layoutMenu.Visibility = ViewStates.Gone;
btnAdd.Visibility = ViewStates.Gone;
btnPlay.Visibility = ViewStates.Gone;
btnDelete.Visibility = ViewStates.Gone;
Expand Down Expand Up @@ -160,7 +163,7 @@ public override View GetView(int position, View convertView, ViewGroup parent)
{
string bitmapKey = item.Query.ArtistName + "_" + item.AlbumTitles[a];
Console.WriteLine("MLBLA - GetView - bitmapKey: {0}", bitmapKey);
if (_fragment.BitmapCache.KeyExists(bitmapKey))
if (_fragment.SmallBitmapCache.KeyExists(bitmapKey))
{
ImageView imageAlbum = null;
if (a == 0)
Expand All @@ -173,7 +176,7 @@ public override View GetView(int position, View convertView, ViewGroup parent)
if (imageAlbum != null)
{
imageAlbum.Tag = bitmapKey;
imageAlbum.SetImageBitmap(_fragment.BitmapCache.GetBitmapFromMemoryCache(bitmapKey));
imageAlbum.SetImageBitmap(_fragment.SmallBitmapCache.GetBitmapFromMemoryCache(bitmapKey));
}
}
else
Expand Down Expand Up @@ -213,7 +216,7 @@ public void RefreshAlbumArtCell(string artistName, string albumTitle, byte[] alb
if(image != null)
image.Tag = artistName + "_" + albumTitle;
//mainActivity.BitmapCache.LoadBitmapFromByteArray(albumArtData, artistName + "_" + albumTitle, image);
_fragment.BitmapCache.LoadBitmapFromByteArray(albumArtData, artistName + "_" + albumTitle, image);
_fragment.SmallBitmapCache.LoadBitmapFromByteArray(albumArtData, artistName + "_" + albumTitle, image);
//});
}
else
Expand Down Expand Up @@ -259,6 +262,7 @@ public void ResetEditingRow()
if (view == null)
return;

var layoutMenu = view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowserCell_layoutMenu);
var imageAdd = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageAdd);
var imagePlay = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imagePlay);
var imageDelete = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageDelete);
Expand All @@ -267,10 +271,12 @@ public void ResetEditingRow()
Animation anim = AnimationUtils.LoadAnimation(_context, Resource.Animation.listviewoptions_fade_out);
anim.AnimationEnd += (sender, args) =>
{
layoutMenu.Visibility = ViewStates.Gone;
imageAdd.Visibility = ViewStates.Gone;
imagePlay.Visibility = ViewStates.Gone;
imageDelete.Visibility = ViewStates.Gone;
};
layoutMenu.StartAnimation(anim);
imageAdd.StartAnimation(anim);
imagePlay.StartAnimation(anim);
imageDelete.StartAnimation(anim);
Expand All @@ -286,6 +292,7 @@ public void SetEditingRow(int position)
if (view == null)
return;

var layoutMenu = view.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowserCell_layoutMenu);
var imageAdd = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageAdd);
var imagePlay = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imagePlay);
var imageDelete = view.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageDelete);
Expand All @@ -300,10 +307,12 @@ public void SetEditingRow(int position)
else if (IsEditingRow && oldPosition >= 0)
{
// Fade in the new controls
layoutMenu.Visibility = ViewStates.Visible;
imageAdd.Visibility = ViewStates.Visible;
imagePlay.Visibility = ViewStates.Visible;
imageDelete.Visibility = ViewStates.Visible;
Animation anim = AnimationUtils.LoadAnimation(_context, Resource.Animation.listviewoptions_fade_in);
layoutMenu.StartAnimation(anim);
imageAdd.StartAnimation(anim);
imagePlay.StartAnimation(anim);
imageDelete.StartAnimation(anim);
Expand All @@ -313,6 +322,7 @@ public void SetEditingRow(int position)
var viewOldPosition = _listView.GetChildAt(oldPositionVisibleCellIndex);
if (viewOldPosition != null)
{
var layoutMenuOld = viewOldPosition.FindViewById<LinearLayout>(Resource.Id.mobileLibraryBrowserCell_layoutMenu);
var imageAddOld = viewOldPosition.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageAdd);
var imagePlayOld = viewOldPosition.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imagePlay);
var imageDeleteOld = viewOldPosition.FindViewById<ImageView>(Resource.Id.mobileLibraryBrowserCell_imageDelete);
Expand All @@ -321,10 +331,12 @@ public void SetEditingRow(int position)
Animation animOld = AnimationUtils.LoadAnimation(_context, Resource.Animation.listviewoptions_fade_out);
animOld.AnimationEnd += (sender, args) =>
{
layoutMenuOld.Visibility = ViewStates.Gone;
imageAddOld.Visibility = ViewStates.Gone;
imagePlayOld.Visibility = ViewStates.Gone;
imageDeleteOld.Visibility = ViewStates.Gone;
};
layoutMenuOld.StartAnimation(anim);
imageAddOld.StartAnimation(animOld);
imagePlayOld.StartAnimation(animOld);
imageDeleteOld.StartAnimation(animOld);
Expand All @@ -335,10 +347,12 @@ public void SetEditingRow(int position)
else if (!IsEditingRow)
{
// Fade in the controls
layoutMenu.Visibility = ViewStates.Visible;
imageAdd.Visibility = ViewStates.Visible;
imagePlay.Visibility = ViewStates.Visible;
imageDelete.Visibility = ViewStates.Visible;
Animation anim = AnimationUtils.LoadAnimation(_context, Resource.Animation.listviewoptions_fade_in);
layoutMenu.StartAnimation(anim);
imageAdd.StartAnimation(anim);
imagePlay.StartAnimation(anim);
imageDelete.StartAnimation(anim);
Expand Down
Expand Up @@ -68,9 +68,9 @@ public void SetPreset(EQPreset preset)
Invalidate();
}

public override void Draw(global::Android.Graphics.Canvas canvas)
public override void Draw(Canvas canvas)
{
//Console.WriteLine("************************************************************EqualizerPresetGraphView - Draw - Width: {0} Height: {1}", Width, Height);
//Console.WriteLine("EqualizerPresetGraphView - Draw - Width: {0} Height: {1}", Width, Height);

float padding = 6 * Resources.DisplayMetrics.Density;
float heightAvailable = Height - (padding*2);
Expand Down Expand Up @@ -126,7 +126,7 @@ public override void Draw(global::Android.Graphics.Canvas canvas)
float ratio = (band.Gain + 6f) / 12f;
float y = padding + heightAvailable - (ratio * (Height - (padding * 2)));

//Console.WriteLine("************************************************************EqualizerPresetGraphView - Draw - Width: {0} Height: {1} ratio: {2} x: {3} y: {4} padding: {5} heightAvailable: {6}", Width, Height, ratio, x, y, padding, heightAvailable);
//Console.WriteLine("EqualizerPresetGraphView - Draw - Width: {0} Height: {1} ratio: {2} x: {3} y: {4} padding: {5} heightAvailable: {6}", Width, Height, ratio, x, y, padding, heightAvailable);
points.Add(x);
points.Add(y);

Expand Down
Expand Up @@ -62,6 +62,7 @@ public class MobileLibraryBrowserFragment : BaseFragment, IMobileLibraryBrowserV
ListView _listViewPlaylists;

public BitmapCache BitmapCache { get; set; }
public BitmapCache SmallBitmapCache { get; set; }

// Leave an empty constructor or the application will crash at runtime
public MobileLibraryBrowserFragment() : base(null)
Expand All @@ -88,6 +89,7 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024);
int cacheSize = maxMemory / 8;
BitmapCache = new BitmapCache(Activity, cacheSize, size.X / 2, size.X / 2); // Max size = half the screen (grid has 2 columns)
SmallBitmapCache = new BitmapCache(Activity, cacheSize, 44 * (int)Resources.DisplayMetrics.Density, 44 * (int)Resources.DisplayMetrics.Density);

_viewFlipper = _view.FindViewById<ViewFlipper>(Resource.Id.mobileLibraryBrowser_viewFlipper);
_imageAlbum = _view.FindViewById<SquareImageView>(Resource.Id.mobileLibraryBrowser_imageAlbum);
Expand Down
79 changes: 47 additions & 32 deletions MPfm/MPfm.Android/Resources/Layout/MobileLibraryBrowserCell.axml
Expand Up @@ -115,37 +115,52 @@
android:textColor="@color/list_secondarytext"
android:textSize="12dp" />
</LinearLayout>
<ImageView
android:id="@+id/mobileLibraryBrowserCell_imagePlay"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:background="@android:color/transparent"
android:src="@drawable/icon_play" />
<ImageView
android:id="@+id/mobileLibraryBrowserCell_imageAdd"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:background="@android:color/transparent"
android:src="@drawable/icon_add" />
<ImageView
android:id="@+id/mobileLibraryBrowserCell_imageDelete"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:background="@android:color/transparent"
android:src="@drawable/icon_trash" />
<ImageView
android:id="@+id/mobileLibraryBrowserCell_imageNowPlaying"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="6dp"
android:visibility="gone"
android:background="@android:color/transparent"
android:src="@drawable/icon_speaker" />
<LinearLayout
android:id="@+id/mobileLibraryBrowserCell_layoutMenu"
android:layout_width="200dp"
android:layout_height="fill_parent"
android:layout_gravity="right"
android:layout_marginRight="4dp"
android:visibility="gone"
android:gravity="right"
android:background="#FFFFFF"
android:orientation="horizontal">
<ImageButton
android:id="@+id/mobileLibraryBrowserCell_imagePlay"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:visibility="gone"
android:background="@drawable/albumcellbutton_selector"
android:src="@drawable/actionbar_play" />
<ImageButton
android:id="@+id/mobileLibraryBrowserCell_imageAdd"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginTop="4dp"
android:layout_marginRight="4dp"
android:visibility="gone"
android:background="@drawable/albumcellbutton_selector"
android:src="@drawable/actionbar_add" />
<ImageButton
android:id="@+id/mobileLibraryBrowserCell_imageDelete"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginRight="2dp"
android:layout_marginTop="4dp"
android:visibility="gone"
android:background="@drawable/albumcellbutton_selector"
android:src="@drawable/actionbar_trash" />
<ImageView
android:id="@+id/mobileLibraryBrowserCell_imageNowPlaying"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:visibility="gone"
android:background="@android:color/transparent"
android:src="@drawable/icon_speaker" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

0 comments on commit b5529bb

Please sign in to comment.