MapChooserPreference.java
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Intermodalics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package eu.intermodalics.tango_ros_streamer.android;
18 
19 import android.content.Context;
20 import android.preference.ListPreference;
21 import android.util.AttributeSet;
22 
23 import java.util.ArrayList;
24 import java.util.Map;
25 
26 
27 public class MapChooserPreference extends ListPreference {
28  private static final String TAG = MapChooserPreference.class.getSimpleName();
29 
30  public MapChooserPreference (Context context, AttributeSet attrs) {
31  super(context, attrs);
32  setValueIndex(0);
33  }
34 
35  public MapChooserPreference (Context context) {
36  this(context, null);
37  }
38 
39  public void setMapList(Map<String, String> uuidNameMap) {
40  if (uuidNameMap != null) {
41  ArrayList<String> uuids = new ArrayList<String>();
42  ArrayList<String> names = new ArrayList<String>();
43  for (String uuid : uuidNameMap.keySet()) {
44  uuids.add(uuid);
45  names.add(uuidNameMap.get(uuid));
46  }
47  setEntries(names.toArray(new CharSequence[names.size()]));
48  setEntryValues(uuids.toArray(new CharSequence[uuids.size()]));
49  }
50  }
51 }


TangoRosStreamer
Author(s):
autogenerated on Mon Jun 10 2019 15:37:54