MapChooserPreference.java
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Intermodalics All Rights Reserved.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 package eu.intermodalics.tango_ros_streamer.android;
00018 
00019 import android.content.Context;
00020 import android.preference.ListPreference;
00021 import android.util.AttributeSet;
00022 
00023 import java.util.ArrayList;
00024 import java.util.Map;
00025 
00026 
00027 public class MapChooserPreference extends ListPreference {
00028     private static final String TAG = MapChooserPreference.class.getSimpleName();
00029 
00030     public MapChooserPreference (Context context, AttributeSet attrs) {
00031         super(context, attrs);
00032         setValueIndex(0);
00033     }
00034 
00035     public MapChooserPreference (Context context) {
00036         this(context, null);
00037     }
00038 
00039     public void setMapList(Map<String, String> uuidNameMap) {
00040         if (uuidNameMap != null) {
00041             ArrayList<String> uuids = new ArrayList<String>();
00042             ArrayList<String> names = new ArrayList<String>();
00043             for (String uuid : uuidNameMap.keySet()) {
00044                 uuids.add(uuid);
00045                 names.add(uuidNameMap.get(uuid));
00046             }
00047             setEntries(names.toArray(new CharSequence[names.size()]));
00048             setEntryValues(uuids.toArray(new CharSequence[uuids.size()]));
00049         }
00050     }
00051 }


TangoRosStreamer
Author(s):
autogenerated on Thu Jun 6 2019 19:49:57