Clover Coverage Report - Subsonic-Android Coverage Report
Coverage timestamp: ven dic 19 2014 17:57:13 EST
../../../../../img/srcFileCovDistChart6.png 65% of files have more coverage
20   181   13   1,82
4   64   0,65   11
11     1,18  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  SackOfViewsAdapter       Line # 50 20 13 54,3% 0.54285717
 
No Tests
 
1    /***
2    Copyright (c) 2008-2009 CommonsWare, LLC
3    Portions (c) 2009 Google, Inc.
4   
5    Licensed under the Apache License, Version 2.0 (the "License"); you may
6    not use this file except in compliance with the License. You may obtain
7    a copy of the License at
8    http://www.apache.org/licenses/LICENSE-2.0
9    Unless required by applicable law or agreed to in writing, software
10    distributed under the License is distributed on an "AS IS" BASIS,
11    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12    See the License for the specific language governing permissions and
13    limitations under the License.
14    */
15    package net.sourceforge.subsonic.androidapp.util;
16   
17    import android.view.View;
18    import android.view.ViewGroup;
19    import android.widget.BaseAdapter;
20    import android.widget.ListView;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    /**
26    * Adapter that simply returns row views from a list.
27    * <p/>
28    * If you supply a size, you must implement newView(), to
29    * create a required view. The adapter will then cache these
30    * views.
31    * <p/>
32    * If you supply a list of views in the constructor, that
33    * list will be used directly. If any elements in the list
34    * are null, then newView() will be called just for those
35    * slots.
36    * <p/>
37    * Subclasses may also wish to override areAllItemsEnabled()
38    * (default: false) and isEnabled() (default: false), if some
39    * of their rows should be selectable.
40    * <p/>
41    * It is assumed each view is unique, and therefore will not
42    * get recycled.
43    * <p/>
44    * Note that this adapter is not designed for long lists. It
45    * is more for screens that should behave like a list. This
46    * is particularly useful if you combine this with other
47    * adapters (e.g., SectionedAdapter) that might have an
48    * arbitrary number of rows, so it all appears seamless.
49    */
 
50    public class SackOfViewsAdapter extends BaseAdapter {
51    private List<View> views = null;
52   
53    /**
54    * Constructor creating an empty list of views, but with
55    * a specified count. Subclasses must override newView().
56    */
 
57  0 toggle public SackOfViewsAdapter(int count) {
58  0 super();
59   
60  0 views = new ArrayList<View>(count);
61   
62  0 for (int i = 0; i < count; i++) {
63  0 views.add(null);
64    }
65    }
66   
67    /**
68    * Constructor wrapping a supplied list of views.
69    * Subclasses must override newView() if any of the elements
70    * in the list are null.
71    */
 
72  33 toggle public SackOfViewsAdapter(List<View> views) {
73  33 for (View view : views) {
74  65 view.setLayoutParams(new ListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
75    }
76  33 this.views = views;
77    }
78   
79    /**
80    * Get the data item associated with the specified
81    * position in the data set.
82    *
83    * @param position Position of the item whose data we want
84    */
 
85  0 toggle @Override
86    public Object getItem(int position) {
87  0 return (views.get(position));
88    }
89   
90    /**
91    * How many items are in the data set represented by this
92    * Adapter.
93    */
 
94  8416 toggle @Override
95    public int getCount() {
96  8416 return (views.size());
97    }
98   
99    /**
100    * Returns the number of types of Views that will be
101    * created by getView().
102    */
 
103  504 toggle @Override
104    public int getViewTypeCount() {
105  504 return (getCount());
106    }
107   
108    /**
109    * Get the type of View that will be created by getView()
110    * for the specified item.
111    *
112    * @param position Position of the item whose data we want
113    */
 
114  326 toggle @Override
115    public int getItemViewType(int position) {
116  326 return (position);
117    }
118   
119    /**
120    * Are all items in this ListAdapter enabled? If yes it
121    * means all items are selectable and clickable.
122    */
 
123  0 toggle @Override
124    public boolean areAllItemsEnabled() {
125  0 return (false);
126    }
127   
128    /**
129    * Returns true if the item at the specified position is
130    * not a separator.
131    *
132    * @param position Position of the item whose data we want
133    */
 
134  444 toggle @Override
135    public boolean isEnabled(int position) {
136  444 return (false);
137    }
138   
139    /**
140    * Get a View that displays the data at the specified
141    * position in the data set.
142    *
143    * @param position Position of the item whose data we want
144    * @param convertView View to recycle, if not null
145    * @param parent ViewGroup containing the returned View
146    */
 
147  74 toggle @Override
148    public View getView(int position, View convertView,
149    ViewGroup parent) {
150  74 View result = views.get(position);
151   
152  74 if (result == null) {
153  0 result = newView(position, parent);
154  0 views.set(position, result);
155    }
156   
157  74 return (result);
158    }
159   
160    /**
161    * Get the row id associated with the specified position
162    * in the list.
163    *
164    * @param position Position of the item whose data we want
165    */
 
166  21 toggle @Override
167    public long getItemId(int position) {
168  21 return (position);
169    }
170   
171    /**
172    * Create a new View to go into the list at the specified
173    * position.
174    *
175    * @param position Position of the item whose data we want
176    * @param parent ViewGroup containing the returned View
177    */
 
178  0 toggle protected View newView(int position, ViewGroup parent) {
179  0 throw new RuntimeException("You must override newView()!");
180    }
181    }