OSDN Git Service

Repackaged com.andrew.apollo to com.cyngn.eleven
[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.appwidgets.RecentWidgetService;
23
24 import java.lang.ref.WeakReference;
25
26 /**
27  * Used to efficiently cache and recyle the {@link View}s used in the artist,
28  * album, song, playlist, and genre adapters.
29  * 
30  * @author Andrew Neal (andrewdneal@gmail.com)
31  */
32 public class MusicHolder {
33
34     /**
35      * This is the overlay ontop of the background artist, playlist, or genre
36      * image
37      */
38     public WeakReference<RelativeLayout> mOverlay;
39
40     /**
41      * This is the background artist, playlist, or genre image
42      */
43     public WeakReference<ImageView> mBackground;
44
45     /**
46      * This is the artist or album image
47      */
48     public WeakReference<ImageView> mImage;
49
50     /**
51      * This is the first line displayed in the list or grid
52      * 
53      * @see {@code #getView()} of a specific adapter for more detailed info
54      */
55     public WeakReference<TextView> mLineOne;
56
57     /**
58      * This is displayed on the right side of the first line in the list or grid
59      *
60      * @see {@code #getView()} of a specific adapter for more detailed info
61      */
62     public WeakReference<TextView> mLineOneRight;
63
64     /**
65      * This is the second line displayed in the list or grid
66      * 
67      * @see {@code #getView()} of a specific adapter for more detailed info
68      */
69     public WeakReference<TextView> mLineTwo;
70
71     /**
72      * This is the third line displayed in the list or grid
73      * 
74      * @see {@code #getView()} of a specific adapter for more detailed info
75      */
76     public WeakReference<TextView> mLineThree;
77
78     /**
79      * Constructor of <code>ViewHolder</code>
80      * 
81      * @param context The {@link Context} to use.
82      */
83     public MusicHolder(final View view) {
84         super();
85         // Initialize mOverlay
86         mOverlay = new WeakReference<RelativeLayout>(
87                 (RelativeLayout)view.findViewById(R.id.image_background));
88
89         // Initialize mBackground
90         mBackground = new WeakReference<ImageView>(
91                 (ImageView)view.findViewById(R.id.list_item_background));
92
93         // Initialize mImage
94         mImage = new WeakReference<ImageView>((ImageView)view.findViewById(R.id.image));
95
96         // Initialize mLineOne
97         mLineOne = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_one));
98
99         // Initialize mLineOneRight
100         mLineOneRight = new WeakReference<TextView>(
101                 (TextView)view.findViewById(R.id.line_one_right));
102
103         // Initialize mLineTwo
104         mLineTwo = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_two));
105
106         // Initialize mLineThree
107         mLineThree = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_three));
108     }
109
110     /**
111      * @param view The {@link View} used to initialize content
112      */
113     public final static class DataHolder {
114
115         /**
116          * This is the ID of the item being loaded in the adapter
117          */
118         public long mItemId;
119
120         /**
121          * This is the first line displayed in the list or grid
122          * 
123          * @see {@code #getView()} of a specific adapter for more detailed info
124          */
125         public String mLineOne;
126
127         /**
128          * This is displayed on the right side of the first line in the list or grid
129          *
130          * @see {@code #getView()} of a specific adapter for more detailed info
131          */
132         public String mLineOneRight;
133
134         /**
135          * This is the second line displayed in the list or grid
136          * 
137          * @see {@code #getView()} of a specific adapter for more detailed info
138          */
139         public String mLineTwo;
140
141         /**
142          * This is the third line displayed in the list or grid
143          * 
144          * @see {@code #getView()} of a specific adapter for more detailed info
145          */
146         public String mLineThree;
147
148         /**
149          * This is the album art bitmap used in {@link RecentWidgetService}.
150          */
151         public Bitmap mImage;
152
153         /**
154          * Constructor of <code>DataHolder</code>
155          */
156         public DataHolder() {
157             super();
158         }
159
160     }
161 }