LoadOccupancyGridDialog.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.app.DialogFragment;
00020 import android.content.Context;
00021 import android.os.Bundle;
00022 import android.view.LayoutInflater;
00023 import android.view.View;
00024 import android.view.ViewGroup;
00025 import android.widget.AdapterView;
00026 import android.widget.ArrayAdapter;
00027 import android.widget.Button;
00028 import android.widget.ListView;
00029 import android.widget.TextView;
00030 
00031 import eu.intermodalics.tango_ros_streamer.R;
00032 
00033 
00037 public class LoadOccupancyGridDialog extends DialogFragment implements View.OnClickListener {
00038     private static final String TAG = LoadOccupancyGridDialog.class.getSimpleName();
00039     CallbackListener mCallbackListener;
00040     Context mContext;
00041 
00042     public interface CallbackListener {
00043         void onClickItemLoadOccupancyGridDialog(String name);
00044     }
00045 
00046     @Override
00047     public void onAttach(Context context) {
00048         super.onAttach(context);
00049         mContext = context;
00050         mCallbackListener = (CallbackListener) context;
00051     }
00052 
00053     @Override
00054     public View onCreateView(LayoutInflater inflator, ViewGroup container,
00055                              Bundle savedInstanceState) {
00056         View dialogView = inflator.inflate(R.layout.dialog_load_occupancy_grid, null);
00057         getDialog().setTitle(R.string.load_occupancy_grid_dialog_title);
00058 
00059         Button cancelButton = (Button) dialogView.findViewById(R.id.load_occupancy_grid_cancel);
00060         cancelButton.setOnClickListener(new View.OnClickListener() {
00061             @Override
00062             public void onClick(View view) {
00063                 dismiss();
00064             }
00065         });
00066 
00067         Bundle bundle = getArguments();
00068         if(bundle.getBoolean(getString(R.string.show_load_occupancy_grid_empty_key))) {
00069             TextView errorTextView = (TextView) dialogView.findViewById(R.id.load_occupancy_grid_empty_message);
00070             errorTextView.setVisibility(View.VISIBLE);
00071         }
00072 
00073         if(bundle.getBoolean(getString(R.string.show_load_occupancy_grid_error_key))) {
00074             TextView errorTextView = (TextView) dialogView.findViewById(R.id.load_occupancy_grid_error_message);
00075             errorTextView.setVisibility(View.VISIBLE);
00076         }
00077 
00078         java.util.ArrayList<java.lang.String> nameList = bundle.getStringArrayList(getString(R.string.list_names_occupancy_grid_key));
00079         ListView listView = (ListView) dialogView.findViewById(R.id.load_occupancy_grid_list);
00080         ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.custom_list_item, nameList);
00081         listView.setAdapter(adapter);
00082         listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
00083             @Override
00084             public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
00085                 mCallbackListener.onClickItemLoadOccupancyGridDialog(
00086                         adapterView.getItemAtPosition(i).toString());
00087                 dismiss();
00088             }
00089         });
00090         return dialogView;
00091     }
00092 
00093     @Override
00094     public void onClick(View v) {
00095 
00096     }
00097 }


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