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.appwidgets.RecentWidgetService;
24 import java.lang.ref.WeakReference;
27 * Used to efficiently cache and recyle the {@link View}s used in the artist,
28 * album, song, playlist, and genre adapters.
30 * @author Andrew Neal (andrewdneal@gmail.com)
32 public class MusicHolder {
35 * This is the overlay ontop of the background artist, playlist, or genre
38 public WeakReference<RelativeLayout> mOverlay;
41 * This is the background artist, playlist, or genre image
43 public WeakReference<ImageView> mBackground;
46 * This is the artist or album image
48 public WeakReference<ImageView> mImage;
51 * This is the first line displayed in the list or grid
53 * @see {@code #getView()} of a specific adapter for more detailed info
55 public WeakReference<TextView> mLineOne;
58 * This is displayed on the right side of the first line in the list or grid
60 * @see {@code #getView()} of a specific adapter for more detailed info
62 public WeakReference<TextView> mLineOneRight;
65 * This is the second line displayed in the list or grid
67 * @see {@code #getView()} of a specific adapter for more detailed info
69 public WeakReference<TextView> mLineTwo;
72 * This is the third line displayed in the list or grid
74 * @see {@code #getView()} of a specific adapter for more detailed info
76 public WeakReference<TextView> mLineThree;
79 * Constructor of <code>ViewHolder</code>
81 * @param context The {@link Context} to use.
83 public MusicHolder(final View view) {
85 // Initialize mOverlay
86 mOverlay = new WeakReference<RelativeLayout>(
87 (RelativeLayout)view.findViewById(R.id.image_background));
89 // Initialize mBackground
90 mBackground = new WeakReference<ImageView>(
91 (ImageView)view.findViewById(R.id.list_item_background));
94 mImage = new WeakReference<ImageView>((ImageView)view.findViewById(R.id.image));
96 // Initialize mLineOne
97 mLineOne = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_one));
99 // Initialize mLineOneRight
100 mLineOneRight = new WeakReference<TextView>(
101 (TextView)view.findViewById(R.id.line_one_right));
103 // Initialize mLineTwo
104 mLineTwo = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_two));
106 // Initialize mLineThree
107 mLineThree = new WeakReference<TextView>((TextView)view.findViewById(R.id.line_three));
111 * @param view The {@link View} used to initialize content
113 public final static class DataHolder {
116 * This is the ID of the item being loaded in the adapter
121 * This is the first line displayed in the list or grid
123 * @see {@code #getView()} of a specific adapter for more detailed info
125 public String mLineOne;
128 * This is displayed on the right side of the first line in the list or grid
130 * @see {@code #getView()} of a specific adapter for more detailed info
132 public String mLineOneRight;
135 * This is the second line displayed in the list or grid
137 * @see {@code #getView()} of a specific adapter for more detailed info
139 public String mLineTwo;
142 * This is the third line displayed in the list or grid
144 * @see {@code #getView()} of a specific adapter for more detailed info
146 public String mLineThree;
149 * This is the album art bitmap used in {@link RecentWidgetService}.
151 public Bitmap mImage;
154 * Constructor of <code>DataHolder</code>
156 public DataHolder() {