2 * Copyright (C) 2012 Andrew Neal Licensed under the Apache License, Version 2.0
3 * (the "License"); you may not use this file except in compliance with the
4 * License. You may obtain a copy of the License at
5 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
6 * or agreed to in writing, software distributed under the License is
7 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 * KIND, either express or implied. See the License for the specific language
9 * governing permissions and limitations under the License.
12 package com.cyngn.eleven.ui;
14 import android.content.Context;
15 import android.graphics.Bitmap;
16 import android.view.View;
17 import android.widget.ImageView;
18 import android.widget.RelativeLayout;
19 import android.widget.TextView;
21 import com.cyngn.eleven.R;
22 import com.cyngn.eleven.widgets.PlayPauseProgressButton;
23 import com.cyngn.eleven.widgets.PopupMenuButton;
25 import java.lang.ref.WeakReference;
28 * Used to efficiently cache and recyle the {@link View}s used in the artist,
29 * album, song, playlist, and genre adapters.
31 * @author Andrew Neal (andrewdneal@gmail.com)
33 public class MusicHolder {
36 * This is the overlay ontop of the background artist, playlist, or genre
39 public WeakReference<RelativeLayout> mOverlay;
42 * This is the artist or album image
44 public WeakReference<ImageView> mImage;
47 * This is the first line displayed in the list or grid
49 * @see {@code #getView()} of a specific adapter for more detailed info
51 public WeakReference<TextView> mLineOne;
54 * This is displayed on the right side of the first line in the list or grid
56 * @see {@code #getView()} of a specific adapter for more detailed info
58 public WeakReference<TextView> mLineOneRight;
61 * This is the second line displayed in the list or grid
63 * @see {@code #getView()} of a specific adapter for more detailed info
65 public WeakReference<TextView> mLineTwo;
68 * The container for the circular progress bar and play/pause button
70 * @see {@code #getView()} of a specific adapter for more detailed info
72 public WeakReference<PlayPauseProgressButton> mPlayPauseProgressButton;
75 * The Padding container for the circular progress bar
77 public WeakReference<View> mPlayPauseProgressContainer;
80 * The song indicator for the currently playing track
82 public WeakReference<View> mNowPlayingIndicator;
85 * The divider for the list item
87 public WeakReference<View> mDivider;
90 * The divider for the list item
92 public WeakReference<PopupMenuButton> mPopupMenuButton;
95 * Constructor of <code>ViewHolder</code>
97 * @param context The {@link Context} to use.
99 public MusicHolder(final View view) {
102 mImage = new WeakReference<ImageView>((ImageView)view.findViewById(R.id.image));
104 // Initialize mLineOne
105 mLineOne = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_one));
107 // Initialize mLineOneRight
108 mLineOneRight = new WeakReference<TextView>(
109 (TextView)view.findViewById(R.id.line_one_right));
111 // Initialize mLineTwo
112 mLineTwo = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_two));
114 // Initialize Circular progress bar container
115 mPlayPauseProgressButton = new WeakReference<PlayPauseProgressButton>(
116 (PlayPauseProgressButton)view.findViewById(R.id.playPauseProgressButton));
118 // Get the padding container for the progress bar
119 mPlayPauseProgressContainer = new WeakReference<View>(
120 view.findViewById(R.id.play_pause_container));
122 mNowPlayingIndicator = new WeakReference<View>(view.findViewById(R.id.now_playing));
124 // Get the divider for the list item
125 mDivider = new WeakReference<View>(view.findViewById(R.id.divider));
127 // Get the pop up menu button
128 mPopupMenuButton = new WeakReference<PopupMenuButton>(
129 (PopupMenuButton)view.findViewById(R.id.popup_menu_button));
133 * @param view The {@link View} used to initialize content
135 public final static class DataHolder {
138 * This is the ID of the item being loaded in the adapter
143 * This is the first line displayed in the list or grid
145 * @see {@code #getView()} of a specific adapter for more detailed info
147 public String mLineOne;
150 * This is displayed on the right side of the first line in the list or grid
152 * @see {@code #getView()} of a specific adapter for more detailed info
154 public String mLineOneRight;
157 * This is the second line displayed in the list or grid
159 * @see {@code #getView()} of a specific adapter for more detailed info
161 public String mLineTwo;
164 * Constructor of <code>DataHolder</code>
166 public DataHolder() {