blob: 40a56d5c73d913b398c6d18640e477b6fba87868 (
plain)
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
|
/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.setupwizardlib.items;
/**
* Representation of zero or more items in a list. Each instance of ItemHierarchy should be capable
* of being wrapped in ItemAdapter and be displayed.
*
* For example, {@link com.android.setupwizardlib.items.Item} is a representation of a single item,
* typically with data provided from XML. {@link com.android.setupwizardlib.items.ItemGroup}
* represents a list of child item hierarchies it contains, but itself does not do any display.
*/
public interface ItemHierarchy {
/**
* Observer for any changes in this hierarchy. If anything updated that causes this hierarchy to
* show different content, this observer should be called.
*/
interface Observer {
/**
* Called when an underlying data update that can cause this hierarchy to show different
* content has occurred.
*/
void onChanged(ItemHierarchy itemHierarchy);
}
/**
* Register an observer to observe changes for this item hierarchy.
*/
void registerObserver(Observer observer);
/**
* Unregister a previously registered observer.
*/
void unregisterObserver(Observer observer);
/**
* @return the number of items this item hierarchy represent.
*/
int getCount();
/**
* Get the item at position.
*
* @param position An integer from 0 to {@link #getCount()}}, which indicates the position in
* this item hierarchy to get the child item.
* @return A representation of the item at {@code position}. Must not be {@code null}.
*/
IItem getItemAt(int position);
/**
* Find an item hierarchy within this hierarchy which has the given ID. Or null if no match is
* found. This hierarchy will be returned if our ID matches. Same restrictions for Android
* resource IDs apply to this ID. In fact, typically this ID is a resource ID generated from
* XML.
*
* @param id An ID to search for in this item hierarchy.
* @return An ItemHierarchy which matches the given ID.
*/
ItemHierarchy findItemById(int id);
}
|