//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public android.view.View onCreateView(android.view.LayoutInflater inflater, @Nullable android.view.ViewGroup container, @Nullable android.os.Bundle savedInstanceState) public override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_device_category_list, container, false); IList <IDictionary <string, string> > groupData = new List <IDictionary <string, string> >(); IList <IList <IDictionary <string, string> > > childData = new List <IList <IDictionary <string, string> > >(); string[] deviceCategory = Resources.getStringArray(R.array.device_categories); string[] posPrinterChildren = Resources.getStringArray(R.array.pos_printer_children); for (int i = 0; i < deviceCategory.Length; i++) { IDictionary <string, string> groupMap = new Dictionary <string, string>(); groupData.Add(groupMap); groupMap[KEY_TITLE] = deviceCategory[i]; groupMap[KEY_SUBTITLE] = ""; if (deviceCategory[i].Equals(getString([email protected]_printer))) { IList <IDictionary <string, string> > children = new List <IDictionary <string, string> >(); for (int j = 0; j < posPrinterChildren.Length; j++) { IDictionary <string, string> childMap = new Dictionary <string, string>(); children.Add(childMap); childMap[KEY_TITLE] = posPrinterChildren[j]; childMap[KEY_SUBTITLE] = ""; } childData.Add(children); } else { IList <IDictionary <string, string> > children = new List <IDictionary <string, string> >(); childData.Add(children); } } string[] from = new string[] { KEY_TITLE, KEY_SUBTITLE }; int[] to = new int[] { android.R.id.text1, android.R.id.text2 }; ExpandableListAdapter adapter = new SimpleExpandableListAdapter(Activity, groupData, android.R.layout.simple_expandable_list_item_1, from, to, childData, android.R.layout.simple_expandable_list_item_2, from, to); expandableListView = (ExpandableListView)view; expandableListView.OnGroupClickListener = this; expandableListView.OnChildClickListener = this; expandableListView.Adapter = adapter; return(view); }
// Demonstrates how to iterate through the supported GATT Services/Characteristics. // In this sample, we populate the data structure that is bound to the ExpandableListView // on the UI. public void DisplayGattServices (IList<BluetoothGattService> gattServices) { if (gattServices == null) return; String uuid = null; String unknownServiceString = Resources.GetString (Resource.String.unknown_service); String unknownCharaString = Resources.GetString (Resource.String.unknown_characteristic); List <Dictionary <String, Object>> gattServiceData = new List <Dictionary <String, Object>> (); List <List <Dictionary <String, String>>> gattCharacteristicData = new List <List <Dictionary <String, String>>> (); mGattCharacteristics = new List <List <BluetoothGattCharacteristic>> (); // Loops through available GATT Services. foreach (BluetoothGattService gattService in gattServices) { Dictionary <String, Object> currentServiceData = new Dictionary <String, Object>(); uuid = gattService.Uuid.ToString (); currentServiceData.Add ( LIST_NAME, SampleGattAttributes.Lookup (uuid, unknownServiceString)); currentServiceData.Add (LIST_UUID, uuid); gattServiceData.Add (currentServiceData); List <Dictionary <String, String>> gattCharacteristicGroupData = new List <Dictionary <String, String>>(); IList <BluetoothGattCharacteristic> gattCharacteristics = gattService.Characteristics; List <BluetoothGattCharacteristic> charas = new List<BluetoothGattCharacteristic> (); // Loops through available Characteristics. foreach (BluetoothGattCharacteristic gattCharacteristic in gattCharacteristics) { charas.Add (gattCharacteristic); Dictionary <String, String> currentCharaData = new Dictionary <String, String>(); uuid = gattCharacteristic.Uuid.ToString(); currentCharaData.Add ( LIST_NAME, SampleGattAttributes.Lookup(uuid, unknownCharaString)); currentCharaData.Add (LIST_UUID, uuid); gattCharacteristicGroupData.Add (currentCharaData); } mGattCharacteristics.Add (charas); gattCharacteristicData.Add (gattCharacteristicGroupData); } SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter ( this, (IList<IDictionary<String, Object>>) gattServiceData, Android.Resource.Layout.SimpleExpandableListItem2, new String[] {LIST_NAME, LIST_UUID}, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }, (IList<IList<IDictionary<String, Object>>>) gattCharacteristicData, Android.Resource.Layout.SimpleExpandableListItem2, new String[] {LIST_NAME, LIST_UUID}, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 } ); mGattServicesList.Adapter = (IListAdapter) gattServiceAdapter; }
// Demonstrates how to iterate through the supported GATT Services/Characteristics. // In this sample, we populate the data structure that is bound to the ExpandableListView // on the UI. public void DisplayGattServices(IList <BluetoothGattService> gattServices) { if (gattServices == null) { return; } String uuid = null; String unknownServiceString = Resources.GetString(Resource.String.unknown_service); String unknownCharaString = Resources.GetString(Resource.String.unknown_characteristic); List <Dictionary <String, Object> > gattServiceData = new List <Dictionary <String, Object> > (); List <List <Dictionary <String, String> > > gattCharacteristicData = new List <List <Dictionary <String, String> > > (); mGattCharacteristics = new List <List <BluetoothGattCharacteristic> > (); // Loops through available GATT Services. foreach (BluetoothGattService gattService in gattServices) { Dictionary <String, Object> currentServiceData = new Dictionary <String, Object>(); uuid = gattService.Uuid.ToString(); currentServiceData.Add( LIST_NAME, SampleGattAttributes.Lookup(uuid, unknownServiceString)); currentServiceData.Add(LIST_UUID, uuid); gattServiceData.Add(currentServiceData); List <Dictionary <String, String> > gattCharacteristicGroupData = new List <Dictionary <String, String> >(); IList <BluetoothGattCharacteristic> gattCharacteristics = gattService.Characteristics; List <BluetoothGattCharacteristic> charas = new List <BluetoothGattCharacteristic> (); // Loops through available Characteristics. foreach (BluetoothGattCharacteristic gattCharacteristic in gattCharacteristics) { charas.Add(gattCharacteristic); Dictionary <String, String> currentCharaData = new Dictionary <String, String>(); uuid = gattCharacteristic.Uuid.ToString(); currentCharaData.Add( LIST_NAME, SampleGattAttributes.Lookup(uuid, unknownCharaString)); currentCharaData.Add(LIST_UUID, uuid); gattCharacteristicGroupData.Add(currentCharaData); } mGattCharacteristics.Add(charas); gattCharacteristicData.Add(gattCharacteristicGroupData); } SimpleExpandableListAdapter gattServiceAdapter = new SimpleExpandableListAdapter( this, (IList <IDictionary <String, Object> >)gattServiceData, Android.Resource.Layout.SimpleExpandableListItem2, new String[] { LIST_NAME, LIST_UUID }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }, (IList <IList <IDictionary <String, Object> > >)gattCharacteristicData, Android.Resource.Layout.SimpleExpandableListItem2, new String[] { LIST_NAME, LIST_UUID }, new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 } ); mGattServicesList.Adapter = (IListAdapter)gattServiceAdapter; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public android.view.View onCreateView(android.view.LayoutInflater inflater, @Nullable android.view.ViewGroup container, @Nullable android.os.Bundle savedInstanceState) public override View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_device_category_list, container, false); IList<IDictionary<string, string>> groupData = new List<IDictionary<string, string>>(); IList<IList<IDictionary<string, string>>> childData = new List<IList<IDictionary<string, string>>>(); string[] deviceCategory = Resources.getStringArray(R.array.device_categories); string[] posPrinterChildren = Resources.getStringArray(R.array.pos_printer_children); for (int i = 0; i < deviceCategory.Length; i++) { IDictionary<string, string> groupMap = new Dictionary<string, string>(); groupData.Add(groupMap); groupMap[KEY_TITLE] = deviceCategory[i]; groupMap[KEY_SUBTITLE] = ""; if (deviceCategory[i].Equals(getString([email protected]_printer))) { IList<IDictionary<string, string>> children = new List<IDictionary<string, string>>(); for (int j = 0; j < posPrinterChildren.Length; j++) { IDictionary<string, string> childMap = new Dictionary<string, string>(); children.Add(childMap); childMap[KEY_TITLE] = posPrinterChildren[j]; childMap[KEY_SUBTITLE] = ""; } childData.Add(children); } else { IList<IDictionary<string, string>> children = new List<IDictionary<string, string>>(); childData.Add(children); } } string[] from = new string[] {KEY_TITLE, KEY_SUBTITLE}; int[] to = new int[] {android.R.id.text1, android.R.id.text2}; ExpandableListAdapter adapter = new SimpleExpandableListAdapter(Activity, groupData, android.R.layout.simple_expandable_list_item_1, from, to, childData, android.R.layout.simple_expandable_list_item_2, from, to); expandableListView = (ExpandableListView) view; expandableListView.OnGroupClickListener = this; expandableListView.OnChildClickListener = this; expandableListView.Adapter = adapter; return view; }