();
104 | if(values.size() > 0){
105 | Log.i("ji", values.get(0) + "");
106 | this.setId(values.get(0));
107 | for(int i = 1; i < values.size(); i++){
108 | this.valeurs.add(values.get(i));
109 | }
110 | }
111 | }
112 |
113 | // Récupére une valeur spécifique
114 | public String getValue(int i){
115 | return this.valeurs.get(i);
116 | }
117 |
118 | // Récupére un type de propriété spécifique
119 | public Property.Type getPropertyType(int i){
120 | return this.properties.get(i).getType();
121 | }
122 |
123 | // Récupére le nom de propriété spécifique
124 | public String getPropertyName(int i){
125 | return this.properties.get(i).getName();
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/src/com/example/rfid/ProfileDetailActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentActivity;
6 | import android.support.v4.app.NavUtils;
7 | import android.view.MenuItem;
8 |
9 | /**
10 | * An activity representing a single Profile detail screen. This activity is
11 | * only used on handset devices. On tablet-size devices, item details are
12 | * presented side-by-side with a list of items in a {@link ProfileListActivity}.
13 | *
14 | * This activity is mostly just a 'shell' activity containing nothing more than
15 | * a {@link ProfileDetailFragment}.
16 | */
17 | public class ProfileDetailActivity extends FragmentActivity {
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_profile_detail);
23 |
24 | // Show the Up button in the action bar.
25 | getActionBar().setDisplayHomeAsUpEnabled(true);
26 |
27 | // savedInstanceState is non-null when there is fragment state
28 | // saved from previous configurations of this activity
29 | // (e.g. when rotating the screen from portrait to landscape).
30 | // In this case, the fragment will automatically be re-added
31 | // to its container so we don't need to manually add it.
32 | // For more information, see the Fragments API guide at:
33 | //
34 | // http://developer.android.com/guide/components/fragments.html
35 | //
36 | if (savedInstanceState == null) {
37 | // Create the detail fragment and add it to the activity
38 | // using a fragment transaction.
39 | Bundle arguments = new Bundle();
40 | arguments.putString(ProfileDetailFragment.ARG_ITEM_ID, getIntent()
41 | .getStringExtra(ProfileDetailFragment.ARG_ITEM_ID));
42 | ProfileDetailFragment fragment = new ProfileDetailFragment();
43 | fragment.setArguments(arguments);
44 | getSupportFragmentManager().beginTransaction()
45 | .add(R.id.profile_detail_container, fragment).commit();
46 | }
47 | }
48 |
49 | @Override
50 | public boolean onOptionsItemSelected(MenuItem item) {
51 | switch (item.getItemId()) {
52 | case android.R.id.home:
53 | // This ID represents the Home or Up button. In the case of this
54 | // activity, the Up button is shown. Use NavUtils to allow users
55 | // to navigate up one level in the application structure. For
56 | // more details, see the Navigation pattern on Android Design:
57 | //
58 | // http://developer.android.com/design/patterns/navigation.html#up-vs-back
59 | //
60 | NavUtils.navigateUpTo(this, new Intent(this,
61 | ProfileListActivity.class));
62 | return true;
63 | }
64 | return super.onOptionsItemSelected(item);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/com/example/rfid/ProfileDetailFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.example.rfid.dummy.DummyContent;
11 |
12 | /**
13 | * A fragment representing a single Profile detail screen. This fragment is
14 | * either contained in a {@link ProfileListActivity} in two-pane mode (on
15 | * tablets) or a {@link ProfileDetailActivity} on handsets.
16 | */
17 | public class ProfileDetailFragment extends Fragment {
18 | /**
19 | * The fragment argument representing the item ID that this fragment
20 | * represents.
21 | */
22 | public static final String ARG_ITEM_ID = "item_id";
23 |
24 | /**
25 | * The dummy content this fragment is presenting.
26 | */
27 | private DummyContent.DummyItem mItem;
28 |
29 | /**
30 | * Mandatory empty constructor for the fragment manager to instantiate the
31 | * fragment (e.g. upon screen orientation changes).
32 | */
33 | public ProfileDetailFragment() {
34 | }
35 |
36 | @Override
37 | public void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 |
40 | if (getArguments().containsKey(ARG_ITEM_ID)) {
41 | // Load the dummy content specified by the fragment
42 | // arguments. In a real-world scenario, use a Loader
43 | // to load content from a content provider.
44 | mItem = DummyContent.ITEM_MAP.get(getArguments().getString(
45 | ARG_ITEM_ID));
46 | }
47 | }
48 |
49 | @Override
50 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
51 | Bundle savedInstanceState) {
52 | View rootView = inflater.inflate(R.layout.fragment_profile_detail,
53 | container, false);
54 |
55 | // Show the dummy content as text in a TextView.
56 | if (mItem != null) {
57 | ((TextView) rootView.findViewById(R.id.profile_detail))
58 | .setText(mItem.content);
59 | }
60 |
61 | return rootView;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/com/example/rfid/ProfileListActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentActivity;
6 |
7 | /**
8 | * An activity representing a list of Profiles. This activity has different
9 | * presentations for handset and tablet-size devices. On handsets, the activity
10 | * presents a list of items, which when touched, lead to a
11 | * {@link ProfileDetailActivity} representing item details. On tablets, the
12 | * activity presents the list of items and item details side-by-side using two
13 | * vertical panes.
14 | *
15 | * The activity makes heavy use of fragments. The list of items is a
16 | * {@link ProfileListFragment} and the item details (if present) is a
17 | * {@link ProfileDetailFragment}.
18 | *
19 | * This activity also implements the required
20 | * {@link ProfileListFragment.Callbacks} interface to listen for item
21 | * selections.
22 | */
23 | public class ProfileListActivity extends FragmentActivity implements
24 | ProfileListFragment.Callbacks {
25 |
26 | /**
27 | * Whether or not the activity is in two-pane mode, i.e. running on a tablet
28 | * device.
29 | */
30 | private boolean mTwoPane;
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_profile_list);
36 |
37 | if (findViewById(R.id.profile_detail_container) != null) {
38 | // The detail container view will be present only in the
39 | // large-screen layouts (res/values-large and
40 | // res/values-sw600dp). If this view is present, then the
41 | // activity should be in two-pane mode.
42 | mTwoPane = true;
43 |
44 | // In two-pane mode, list items should be given the
45 | // 'activated' state when touched.
46 | ((ProfileListFragment) getSupportFragmentManager()
47 | .findFragmentById(R.id.profile_list))
48 | .setActivateOnItemClick(true);
49 | }
50 |
51 | // TODO: If exposing deep links into your app, handle intents here.
52 | }
53 |
54 | /**
55 | * Callback method from {@link ProfileListFragment.Callbacks} indicating
56 | * that the item with the given ID was selected.
57 | */
58 | @Override
59 | public void onItemSelected(String id) {
60 | if (mTwoPane) {
61 | // In two-pane mode, show the detail view in this activity by
62 | // adding or replacing the detail fragment using a
63 | // fragment transaction.
64 | Bundle arguments = new Bundle();
65 | arguments.putString(ProfileDetailFragment.ARG_ITEM_ID, id);
66 | ProfileDetailFragment fragment = new ProfileDetailFragment();
67 | fragment.setArguments(arguments);
68 | getSupportFragmentManager().beginTransaction()
69 | .replace(R.id.profile_detail_container, fragment).commit();
70 |
71 | } else {
72 | // In single-pane mode, simply start the detail activity
73 | // for the selected item ID.
74 | Intent detailIntent = new Intent(this, ProfileDetailActivity.class);
75 | detailIntent.putExtra(ProfileDetailFragment.ARG_ITEM_ID, id);
76 | startActivity(detailIntent);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/com/example/rfid/ProfileListFragment.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ListFragment;
6 | import android.view.View;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.ListView;
9 |
10 | import com.example.rfid.dummy.DummyContent;
11 |
12 | /**
13 | * A list fragment representing a list of Profiles. This fragment also supports
14 | * tablet devices by allowing list items to be given an 'activated' state upon
15 | * selection. This helps indicate which item is currently being viewed in a
16 | * {@link ProfileDetailFragment}.
17 | *
18 | * Activities containing this fragment MUST implement the {@link Callbacks}
19 | * interface.
20 | */
21 | public class ProfileListFragment extends ListFragment {
22 |
23 | /**
24 | * The serialization (saved instance state) Bundle key representing the
25 | * activated item position. Only used on tablets.
26 | */
27 | private static final String STATE_ACTIVATED_POSITION = "activated_position";
28 |
29 | /**
30 | * The fragment's current callback object, which is notified of list item
31 | * clicks.
32 | */
33 | private Callbacks mCallbacks = sDummyCallbacks;
34 |
35 | /**
36 | * The current activated item position. Only used on tablets.
37 | */
38 | private int mActivatedPosition = ListView.INVALID_POSITION;
39 |
40 | /**
41 | * A callback interface that all activities containing this fragment must
42 | * implement. This mechanism allows activities to be notified of item
43 | * selections.
44 | */
45 | public interface Callbacks {
46 | /**
47 | * Callback for when an item has been selected.
48 | */
49 | public void onItemSelected(String id);
50 | }
51 |
52 | /**
53 | * A dummy implementation of the {@link Callbacks} interface that does
54 | * nothing. Used only when this fragment is not attached to an activity.
55 | */
56 | private static Callbacks sDummyCallbacks = new Callbacks() {
57 | @Override
58 | public void onItemSelected(String id) {
59 | }
60 | };
61 |
62 | /**
63 | * Mandatory empty constructor for the fragment manager to instantiate the
64 | * fragment (e.g. upon screen orientation changes).
65 | */
66 | public ProfileListFragment() {
67 | }
68 |
69 | @Override
70 | public void onCreate(Bundle savedInstanceState) {
71 | super.onCreate(savedInstanceState);
72 |
73 | // TODO: replace with a real list adapter.
74 | setListAdapter(new ArrayAdapter(getActivity(),
75 | android.R.layout.simple_list_item_activated_1,
76 | android.R.id.text1, DummyContent.ITEMS));
77 | }
78 |
79 | @Override
80 | public void onViewCreated(View view, Bundle savedInstanceState) {
81 | super.onViewCreated(view, savedInstanceState);
82 |
83 | // Restore the previously serialized activated item position.
84 | if (savedInstanceState != null
85 | && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
86 | setActivatedPosition(savedInstanceState
87 | .getInt(STATE_ACTIVATED_POSITION));
88 | }
89 | }
90 |
91 | @Override
92 | public void onAttach(Activity activity) {
93 | super.onAttach(activity);
94 |
95 | // Activities containing this fragment must implement its callbacks.
96 | if (!(activity instanceof Callbacks)) {
97 | throw new IllegalStateException(
98 | "Activity must implement fragment's callbacks.");
99 | }
100 |
101 | mCallbacks = (Callbacks) activity;
102 | }
103 |
104 | @Override
105 | public void onDetach() {
106 | super.onDetach();
107 |
108 | // Reset the active callbacks interface to the dummy implementation.
109 | mCallbacks = sDummyCallbacks;
110 | }
111 |
112 | @Override
113 | public void onListItemClick(ListView listView, View view, int position,
114 | long id) {
115 | super.onListItemClick(listView, view, position, id);
116 |
117 | // Notify the active callbacks interface (the activity, if the
118 | // fragment is attached to one) that an item has been selected.
119 | mCallbacks.onItemSelected(DummyContent.ITEMS.get(position).id);
120 | }
121 |
122 | @Override
123 | public void onSaveInstanceState(Bundle outState) {
124 | super.onSaveInstanceState(outState);
125 | if (mActivatedPosition != ListView.INVALID_POSITION) {
126 | // Serialize and persist the activated item position.
127 | outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
128 | }
129 | }
130 |
131 | /**
132 | * Turns on activate-on-click mode. When this mode is on, list items will be
133 | * given the 'activated' state when touched.
134 | */
135 | public void setActivateOnItemClick(boolean activateOnItemClick) {
136 | // When setting CHOICE_MODE_SINGLE, ListView will automatically
137 | // give items the 'activated' state when touched.
138 | getListView().setChoiceMode(
139 | activateOnItemClick ? ListView.CHOICE_MODE_SINGLE
140 | : ListView.CHOICE_MODE_NONE);
141 | }
142 |
143 | private void setActivatedPosition(int position) {
144 | if (position == ListView.INVALID_POSITION) {
145 | getListView().setItemChecked(mActivatedPosition, false);
146 | } else {
147 | getListView().setItemChecked(position, true);
148 | }
149 |
150 | mActivatedPosition = position;
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/src/com/example/rfid/Property.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid;
2 |
3 | public class Property {
4 | public static enum Type {
5 | String,
6 | Number,
7 | Boolean,
8 | Date;
9 | };
10 |
11 | private String name;
12 | private Type type;
13 | private boolean required;
14 |
15 | public Property(String name, Property.Type type, boolean required){
16 | this.name = name;
17 | this.type = type;
18 | this.required = required;
19 | }
20 |
21 | public String getName() {
22 | return this.name;
23 | }
24 |
25 | public Type getType() {
26 | return this.type;
27 | }
28 |
29 | public boolean isRequired() {
30 | return required;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/com/example/rfid/Utils.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid;
2 |
3 | import android.app.Activity;
4 | import android.app.AlertDialog;
5 | import android.content.DialogInterface;
6 | import android.content.Intent;
7 | import android.content.pm.PackageInfo;
8 | import android.content.pm.PackageManager;
9 | import android.nfc.NfcAdapter;
10 | import android.os.Build;
11 | import android.provider.Settings;
12 | import android.util.Log;
13 | import android.view.WindowManager;
14 | import android.widget.Toast;
15 |
16 | import com.example.rfid.R;
17 |
18 | import org.w3c.dom.Node;
19 |
20 | import javax.xml.transform.OutputKeys;
21 | import javax.xml.transform.Result;
22 | import javax.xml.transform.Source;
23 | import javax.xml.transform.Transformer;
24 | import javax.xml.transform.TransformerFactory;
25 | import javax.xml.transform.dom.DOMSource;
26 | import javax.xml.transform.stream.StreamResult;
27 |
28 | import java.io.ByteArrayOutputStream;
29 | import java.io.StringWriter;
30 | import java.nio.charset.Charset;
31 | import java.util.List;
32 |
33 | public class Utils {
34 |
35 | // Vérify if the NFC is activated
36 | public static void checkNfcEnabled(final Activity activity, NfcAdapter adapter) {
37 | if (adapter.isEnabled()) {
38 | return;
39 | }
40 | new AlertDialog.Builder(activity)
41 | .setTitle(R.string.nfc_disabled)
42 | .setMessage(R.string.turn_on_nfc)
43 | .setCancelable(true)
44 | .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
45 | public void onClick(DialogInterface dialog, int id) {
46 | dialog.dismiss();
47 | }
48 | })
49 | .setNeutralButton(R.string.wireless_settings, new DialogInterface.OnClickListener() {
50 | public void onClick(DialogInterface dialog, int id) {
51 | activity.startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
52 | }
53 | })
54 | .show();
55 | }
56 |
57 | // Conversion from an int to an array of bytes
58 | public static final byte[] intToByteArray(int value) {
59 | byte[] tmp = new byte[] {
60 | (byte)(value >>> 16),
61 | (byte)(value >>> 8),
62 | (byte)value
63 | };
64 |
65 | return new byte[] {
66 | tmp[2],
67 | tmp[1],
68 | tmp[0]
69 | };
70 | }
71 |
72 | // Decoding the data in the charset ISO-8859-1
73 | public static String decodeISO(byte[] bytes) {
74 | return new String(bytes, Charset.forName("ISO-8859-1"));
75 | }
76 |
77 | // Encoding the data in the charset ISO-8859-1
78 | public static byte[] encodeISO(String string) {
79 | return string.getBytes(Charset.forName("ISO-8859-1"));
80 | }
81 |
82 | // Encoding the data in the charset ISO-8859-1 and return an array of Bytes
83 | public static Byte[] encodeISO(String string, int length) {
84 | byte[] temp = string.getBytes(Charset.forName("ISO-8859-1"));
85 | byte[] result = new byte[length];
86 |
87 |
88 | for(int i = 0; i < temp.length; i++) {
89 | result[i] = temp[i];
90 | }
91 |
92 | for(int i = temp.length; i < length; i++) {
93 | result[i] = (byte) 0x0;
94 | }
95 |
96 | Byte[] resultConvert = new Byte[result.length];
97 |
98 | for(int i = 0; i < result.length; i++){
99 | resultConvert[i] = (Byte)result[i];
100 | }
101 |
102 | return resultConvert;
103 | }
104 |
105 | // Encoding the data in the charset ISO-8859-1 and return an array of bytes
106 | public static byte[] encodeISOByte(String string, int length) {
107 | byte[] temp = string.getBytes(Charset.forName("ISO-8859-1"));
108 | byte[] result = new byte[length];
109 |
110 |
111 | if(length > temp.length){
112 | for(int i = 0; i < temp.length; i++) {
113 | result[i] = temp[i];
114 | }
115 | }
116 | else{
117 | for(int i = 0; i < length; i++) {
118 | result[i] = temp[i];
119 | }
120 | }
121 |
122 | for(int i = temp.length; i < length; i++) {
123 | result[i] = (byte) 0x0;
124 | }
125 |
126 | Log.i("Resultat", result + "");
127 | return result;
128 | }
129 |
130 | // Encapsulation of the message for the NFC communication
131 | public static byte[] wrapMessage (byte command, byte[] parameters) throws Exception {
132 | ByteArrayOutputStream stream = new ByteArrayOutputStream();
133 |
134 | stream.write((byte) 0x90);
135 | stream.write(command);
136 | stream.write((byte) 0x00);
137 | stream.write((byte) 0x00);
138 | if (parameters != null) {
139 | stream.write((byte) parameters.length);
140 | stream.write(parameters);
141 | }
142 | stream.write((byte) 0x00);
143 |
144 | return stream.toByteArray();
145 | }
146 |
147 | // Conversion bytes data to string
148 | public static String getHexString (byte[] b) throws Exception {
149 | String result = "";
150 | for (int i=0; i < b.length; i++) {
151 | result += Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
152 | }
153 | return result;
154 | }
155 |
156 | // Conversion bytes data to string with a default result
157 | public static String getHexString (byte[] b, String defaultResult) {
158 | try {
159 | return getHexString(b);
160 | } catch (Exception ex) {
161 | return defaultResult;
162 | }
163 | }
164 |
165 | // Conversion string data to bytes[]
166 | public static byte[] hexStringToByteArray (String s) {
167 | if ((s.length() % 2) != 0) {
168 | throw new IllegalArgumentException("Bad input string: " + s);
169 | }
170 |
171 | int len = s.length();
172 | byte[] data = new byte[len / 2];
173 | for (int i = 0; i < len; i += 2) {
174 | data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
175 | + Character.digit(s.charAt(i+1), 16));
176 | }
177 | return data;
178 | }
179 |
180 | // Conversion byte[] to int
181 | public static int byteArrayToInt(byte[] b) {
182 | return byteArrayToInt(b, 0);
183 | }
184 |
185 | // Get information about the card (NFC)
186 | public static String getDeviceInfoString() {
187 | return String.format("nModel: %s (%s %s)\nOS: %s\n\n",
188 | Build.MODEL,
189 | Build.MANUFACTURER,
190 | Build.BRAND,
191 | Build.VERSION.RELEASE);
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/src/com/example/rfid/XMLParser.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid;
2 |
3 | import org.xml.sax.Attributes;
4 | import org.xml.sax.SAXException;
5 | import org.xml.sax.helpers.DefaultHandler;
6 |
7 | import android.content.Context;
8 | import android.util.Log;
9 |
10 | public class XMLParser extends DefaultHandler {
11 |
12 | private Profile profile = null;
13 | private StringBuffer buffer;
14 |
15 |
16 | @Override
17 | public void startDocument() throws SAXException {
18 | //Open the document
19 | Log.w("DEBUT DOCUMENT","Handler");
20 |
21 | }
22 | @Override
23 | public void endDocument() throws SAXException {
24 | // End of the document
25 | Log.w("END DOCUMENT","Handler");
26 | }
27 |
28 | @Override
29 | public void startElement(String namespaceURI, String localName,String qName, Attributes atts) throws SAXException {
30 |
31 | Log.i("Start LocalName", localName);
32 | buffer = new StringBuffer();
33 |
34 | if (localName.equals("profil"))
35 | {
36 | Log.i("XML", "Creation du profile");
37 | profile = new Profile();
38 | }
39 | else if (localName.equals("properties"))
40 | {
41 | profile.initProperties();
42 | }
43 | else if (localName.equals("entry"))
44 | {
45 | String name = atts.getValue("name");
46 | String type = atts.getValue("type");
47 | String required = atts.getValue("required");
48 | profile.addProperty(name,type,required);
49 | }
50 | else{
51 |
52 | }
53 | }
54 |
55 | @Override
56 | public void endElement(String namespaceURI, String localName, String qName)throws SAXException {
57 | if(localName.equals("id")){
58 | profile.setId(buffer.toString());
59 | }
60 | else if(localName.equals("name")){
61 | profile.setName(buffer.toString());
62 | }
63 | }
64 |
65 | public void characters(char[] ch,int start, int length) throws SAXException{
66 | String lecture = new String(ch,start,length);
67 | if(buffer != null) buffer.append(lecture);
68 | }
69 |
70 |
71 | public Profile getProfile()
72 | {
73 | return this.profile;
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/src/com/example/rfid/dummy/DummyContent.java:
--------------------------------------------------------------------------------
1 | package com.example.rfid.dummy;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | /**
9 | * Helper class for providing sample content for user interfaces created by
10 | * Android template wizards.
11 | *
12 | * TODO: Replace all uses of this class before publishing your app.
13 | */
14 | public class DummyContent {
15 |
16 | /**
17 | * An array of sample (dummy) items.
18 | */
19 | public static List ITEMS = new ArrayList();
20 |
21 | /**
22 | * A map of sample (dummy) items, by ID.
23 | */
24 | public static Map ITEM_MAP = new HashMap();
25 |
26 | static {
27 | // Add 3 sample items.
28 | addItem(new DummyItem("1", "Item 1"));
29 | addItem(new DummyItem("2", "Item 2"));
30 | addItem(new DummyItem("3", "Item 3"));
31 | }
32 |
33 | private static void addItem(DummyItem item) {
34 | ITEMS.add(item);
35 | ITEM_MAP.put(item.id, item);
36 | }
37 |
38 | /**
39 | * A dummy item representing a piece of content.
40 | */
41 | public static class DummyItem {
42 | public String id;
43 | public String content;
44 |
45 | public DummyItem(String id, String content) {
46 | this.id = id;
47 | this.content = content;
48 | }
49 |
50 | @Override
51 | public String toString() {
52 | return content;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------