LoadOccupancyGridDialog.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.app.DialogFragment;
20 import android.content.Context;
21 import android.os.Bundle;
22 import android.view.LayoutInflater;
23 import android.view.View;
24 import android.view.ViewGroup;
25 import android.widget.AdapterView;
26 import android.widget.ArrayAdapter;
27 import android.widget.Button;
28 import android.widget.ListView;
29 import android.widget.TextView;
30 
32 
33 
37 public class LoadOccupancyGridDialog extends DialogFragment implements View.OnClickListener {
38  private static final String TAG = LoadOccupancyGridDialog.class.getSimpleName();
39  CallbackListener mCallbackListener;
40  Context mContext;
41 
42  public interface CallbackListener {
43  void onClickItemLoadOccupancyGridDialog(String name);
44  }
45 
46  @Override
47  public void onAttach(Context context) {
48  super.onAttach(context);
49  mContext = context;
50  mCallbackListener = (CallbackListener) context;
51  }
52 
53  @Override
54  public View onCreateView(LayoutInflater inflator, ViewGroup container,
55  Bundle savedInstanceState) {
56  View dialogView = inflator.inflate(R.layout.dialog_load_occupancy_grid, null);
57  getDialog().setTitle(R.string.load_occupancy_grid_dialog_title);
58 
59  Button cancelButton = (Button) dialogView.findViewById(R.id.load_occupancy_grid_cancel);
60  cancelButton.setOnClickListener(new View.OnClickListener() {
61  @Override
62  public void onClick(View view) {
63  dismiss();
64  }
65  });
66 
67  Bundle bundle = getArguments();
68  if(bundle.getBoolean(getString(R.string.show_load_occupancy_grid_empty_key))) {
69  TextView errorTextView = (TextView) dialogView.findViewById(R.id.load_occupancy_grid_empty_message);
70  errorTextView.setVisibility(View.VISIBLE);
71  }
72 
73  if(bundle.getBoolean(getString(R.string.show_load_occupancy_grid_error_key))) {
74  TextView errorTextView = (TextView) dialogView.findViewById(R.id.load_occupancy_grid_error_message);
75  errorTextView.setVisibility(View.VISIBLE);
76  }
77 
78  java.util.ArrayList<java.lang.String> nameList = bundle.getStringArrayList(getString(R.string.list_names_occupancy_grid_key));
79  ListView listView = (ListView) dialogView.findViewById(R.id.load_occupancy_grid_list);
80  ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, R.layout.custom_list_item, nameList);
81  listView.setAdapter(adapter);
82  listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
83  @Override
84  public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
85  mCallbackListener.onClickItemLoadOccupancyGridDialog(
86  adapterView.getItemAtPosition(i).toString());
87  dismiss();
88  }
89  });
90  return dialogView;
91  }
92 
93  @Override
94  public void onClick(View v) {
95 
96  }
97 }
View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState)


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