OSDN Git Service

Eleven: Add song indicators, change ProfileSongAdapter to use SongAdapter
[android-x86/packages-apps-Eleven.git] / src / com / cyngn / eleven / ui / MusicHolder.java
1 /*
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.
10  */
11
12 package com.cyngn.eleven.ui;
13
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;
20
21 import com.cyngn.eleven.R;
22 import com.cyngn.eleven.widgets.PlayPauseProgressButton;
23 import com.cyngn.eleven.widgets.PopupMenuButton;
24
25 import java.lang.ref.WeakReference;
26
27 /**
28  * Used to efficiently cache and recyle the {@link View}s used in the artist,
29  * album, song, playlist, and genre adapters.
30  * 
31  * @author Andrew Neal (andrewdneal@gmail.com)
32  */
33 public class MusicHolder {
34
35     /**
36      * This is the overlay ontop of the background artist, playlist, or genre
37      * image
38      */
39     public WeakReference<RelativeLayout> mOverlay;
40
41     /**
42      * This is the artist or album image
43      */
44     public WeakReference<ImageView> mImage;
45
46     /**
47      * This is the first line displayed in the list or grid
48      * 
49      * @see {@code #getView()} of a specific adapter for more detailed info
50      */
51     public WeakReference<TextView> mLineOne;
52
53     /**
54      * This is displayed on the right side of the first line in the list or grid
55      *
56      * @see {@code #getView()} of a specific adapter for more detailed info
57      */
58     public WeakReference<TextView> mLineOneRight;
59
60     /**
61      * This is the second line displayed in the list or grid
62      * 
63      * @see {@code #getView()} of a specific adapter for more detailed info
64      */
65     public WeakReference<TextView> mLineTwo;
66
67     /**
68      * The container for the circular progress bar and play/pause button
69      *
70      * @see {@code #getView()} of a specific adapter for more detailed info
71      */
72     public WeakReference<PlayPauseProgressButton> mPlayPauseProgressButton;
73
74     /**
75      * The Padding container for the circular progress bar
76      */
77     public WeakReference<View> mPlayPauseProgressContainer;
78
79     /**
80      * The song indicator for the currently playing track
81      */
82     public WeakReference<View> mNowPlayingIndicator;
83
84     /**
85      * The divider for the list item
86      */
87     public WeakReference<View> mDivider;
88
89     /**
90      * The divider for the list item
91      */
92     public WeakReference<PopupMenuButton> mPopupMenuButton;
93
94     /**
95      * Constructor of <code>ViewHolder</code>
96      * 
97      * @param context The {@link Context} to use.
98      */
99     public MusicHolder(final View view) {
100         super();
101         // Initialize mImage
102         mImage = new WeakReference<ImageView>((ImageView)view.findViewById(R.id.image));
103
104         // Initialize mLineOne
105         mLineOne = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_one));
106
107         // Initialize mLineOneRight
108         mLineOneRight = new WeakReference<TextView>(
109                 (TextView)view.findViewById(R.id.line_one_right));
110
111         // Initialize mLineTwo
112         mLineTwo = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_two));
113
114         // Initialize Circular progress bar container
115         mPlayPauseProgressButton = new WeakReference<PlayPauseProgressButton>(
116                 (PlayPauseProgressButton)view.findViewById(R.id.playPauseProgressButton));
117
118         // Get the padding container for the progress bar
119         mPlayPauseProgressContainer = new WeakReference<View>(
120                 view.findViewById(R.id.play_pause_container));
121
122         mNowPlayingIndicator = new WeakReference<View>(view.findViewById(R.id.now_playing));
123
124         // Get the divider for the list item
125         mDivider = new WeakReference<View>(view.findViewById(R.id.divider));
126
127         // Get the pop up menu button
128         mPopupMenuButton = new WeakReference<PopupMenuButton>(
129                 (PopupMenuButton)view.findViewById(R.id.popup_menu_button));
130     }
131
132     /**
133      * @param view The {@link View} used to initialize content
134      */
135     public final static class DataHolder {
136
137         /**
138          * This is the ID of the item being loaded in the adapter
139          */
140         public long mItemId;
141
142         /**
143          * This is the first line displayed in the list or grid
144          * 
145          * @see {@code #getView()} of a specific adapter for more detailed info
146          */
147         public String mLineOne;
148
149         /**
150          * This is displayed on the right side of the first line in the list or grid
151          *
152          * @see {@code #getView()} of a specific adapter for more detailed info
153          */
154         public String mLineOneRight;
155
156         /**
157          * This is the second line displayed in the list or grid
158          * 
159          * @see {@code #getView()} of a specific adapter for more detailed info
160          */
161         public String mLineTwo;
162
163         /**
164          * Constructor of <code>DataHolder</code>
165          */
166         public DataHolder() {
167             super();
168         }
169
170     }
171 }