1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/*
* Copyright (C) 2011 Christopher Eby <kreed@kreed.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package ch.blinkenlights.android.vanilla;
import android.content.Intent;
import android.view.View;
import android.widget.ListAdapter;
/**
* Provides support for limiters and a few other methods LibraryActivity uses
* for its adapters.
*/
public interface LibraryAdapter extends ListAdapter {
/**
* Return the type of media represented by this adapter. One of
* MediaUtils.TYPE_*.
*/
int getMediaType();
/**
* Set the limiter for the adapter.
*
* A limiter is intended to restrict displayed media to only those that are
* children of a given parent media item.
*
* @param limiter The limiter, created by
* {@link LibraryAdapter#buildLimiter(long)}.
*/
void setLimiter(Limiter limiter);
/**
* Returns the limiter currently active on this adapter or null if none are
* active.
*/
Limiter getLimiter();
/**
* Builds a limiter based off of the media represented by the given row.
*
* @param id The id of the row.
* @see LibraryAdapter#getLimiter()
* @see LibraryAdapter#setLimiter(Limiter)
*/
Limiter buildLimiter(long id);
/**
* Set a new filter.
*
* The data should be requeried after calling this.
*
* @param filter The terms to filter on, separated by spaces. Only
* media that contain all of the terms (in any order) will be displayed
* after filtering is complete.
*/
void setFilter(String filter);
/**
* Retrieve the data for this adapter. The data must be set with
* {@link LibraryAdapter#commitQuery(Object)} before it takes effect.
*
* This should be called on a worker thread.
*
* @return The data. Contents depend on the sub-class.
*/
Object query();
/**
* Retrieve a query which will fetch all songs represented by
* this adapter.
*
* @return a query task.
*/
QueryTask buildSongQuery(String[] projection);
/**
* Update the adapter with the given data.
*
* Must be called on the UI thread.
*
* @param data Data from {@link LibraryAdapter#query()}.
*/
void commitQuery(Object data);
/**
* Clear the data for this adapter.
*
* Must be called on the UI thread.
*/
void clear();
/**
* Creates the row data used by LibraryActivity.
*/
Intent createData(View row);
/**
* Extra for row data: media id. type: long.
*/
String DATA_ID = "id";
/**
* Special id for {@link #DATA_ID}: the row represented is a header view.
*/
long HEADER_ID = -1;
/**
* Special id for {@link #DATA_ID}: invalid id.
*/
long INVALID_ID = -2;
/**
* Extra for row data: media title. type: String.
*/
String DATA_TITLE = "title";
/**
* Extra for row data: media type. type: int. One of MediaUtils.TYPE_*.
*/
String DATA_TYPE = "type";
/**
* Extra for row data: canonical file path. type: String. Only present if
* type is {@link MediaUtils#TYPE_FILE}.
*/
String DATA_FILE = "file";
/**
* Extra for row data: if true, row has expander arrow. type: boolean.
*/
String DATA_EXPANDABLE = "expandable";
}
|