2 * //******************************************************************
4 * // Copyright 2016 Samsung Electronics All Rights Reserved.
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
8 * // Licensed under the Apache License, Version 2.0 (the "License");
9 * // you may not use this file except in compliance with the License.
10 * // You may obtain a copy of the License at
12 * // http://www.apache.org/licenses/LICENSE-2.0
14 * // Unless required by applicable law or agreed to in writing, software
15 * // distributed under the License is distributed on an "AS IS" BASIS,
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * // See the License for the specific language governing permissions and
18 * // limitations under the License.
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 package org.iotivity.base.examples.DirectPairing;
25 import android.content.Context;
26 import android.view.LayoutInflater;
27 import android.view.View;
28 import android.view.ViewGroup;
29 import android.widget.BaseExpandableListAdapter;
30 import android.widget.ImageView;
31 import android.widget.TextView;
33 import org.iotivity.base.examples.DirectPairing.Led;
35 import java.util.List;
37 public class ExpandableListAdapter extends BaseExpandableListAdapter {
38 private List<String> mGroupList;
39 private List<Object> mChilditemsList;
40 private Context mContext;
42 public ExpandableListAdapter(List<String> groupList, List<Object> childitemsList,
45 this.mContext = context;
46 this.mGroupList = groupList;
47 this.mChilditemsList = childitemsList;
51 public int getGroupCount() {
52 return mGroupList.size();
56 public int getChildrenCount(int groupPosition) {
61 public Object getGroup(int groupPosition) {
62 return mGroupList.get(groupPosition);
66 public Object getChild(int groupPosition, int childPosition) {
67 return this.mChilditemsList.get(childPosition);
71 public long getGroupId(int groupPosition) {
76 public long getChildId(int groupPosition, int childPosition) {
81 public boolean hasStableIds() {
86 public View getGroupView(int groupPosition, boolean isExpanded,
87 View convertView, ViewGroup parent) {
89 String data = (String) getGroup(groupPosition);
90 if (convertView == null) {
91 LayoutInflater infalInflater = (LayoutInflater) this.mContext
92 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
93 convertView = infalInflater.inflate(R.layout.list_group, null);
96 ImageView img = (ImageView) convertView.findViewById(R.id.image);
98 img.setImageResource(R.drawable.arrow_down);
101 img.setImageResource(R.drawable.arrow_right);
104 TextView groupText = (TextView) convertView.findViewById(R.id.title);
105 groupText.setText(mGroupList.get(groupPosition));
111 public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
112 View convertView, ViewGroup parent) {
113 LayoutInflater inflater = (LayoutInflater) mContext
114 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
115 convertView = inflater.inflate(R.layout.list_item, parent, false);
117 Led ledResource = (Led) getChild(groupPosition, childPosition);
118 TextView textItem = (TextView) convertView
119 .findViewById(R.id.textViewItem);
120 TextView textSource = (TextView) convertView
121 .findViewById(R.id.textViewSource);
122 TextView textStatus = (TextView) convertView
123 .findViewById(R.id.textViewStatus);
124 textStatus.setText("URI:" + "/a/led");
125 textItem.setText("State: " + ledResource.getState());
126 textSource.setText("Power: " + ledResource.getPower());
133 public boolean isChildSelectable(int groupPosition, int childPosition) {