protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); mDrawerLayout = FindViewById<DrawerLayout> (Resource.Id.myDrawer); progressBar = FindViewById<ProgressBar> (Resource.Id.loadingProgressBar); leftDrawerLinearLayoutId = (LinearLayout)FindViewById (Resource.Id.left_drawer); azureAdap = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleListItem1); //Start Expandable mListExView = FindViewById<ExpandableListView> (Resource.Id.expandListView); tempListView = FindViewById<ListView> (Resource.Id.lstViewTemp); //setMasterParent (); //setChild (); adapter = new myListViewAdap (NewParentItems); adapter.setInflater ((LayoutInflater)GetSystemService (Context.LayoutInflaterService), this); mListExView.SetAdapter (adapter); //End Expandable mDrawerToggle = new ActionBarDrawerToggle (this, mDrawerLayout, Resource.Drawable.ic_navigation_drawer, Resource.String.open_drawer, Resource.String.close_drawer); mDrawerLayout.SetDrawerListener (mDrawerToggle); ActionBar.SetDisplayHomeAsUpEnabled (true); ActionBar.SetHomeButtonEnabled (true); ActionBar.SetDisplayShowTitleEnabled (true); //Declaration of Image button and other buttons ImageButton imgBtnPlus = (ImageButton)FindViewById (Resource.Id.buttonNewPanel); Button btnCancel = (Button)FindViewById (Resource.Id.CancelPanel); Button btnSavePanel = (Button)FindViewById (Resource.Id.SavePanel); TableRow tRowSaveCancel = (TableRow)FindViewById (Resource.Id.tRowSaveCancel); //Row of save Button EditText txtidofNewPanel = (EditText)(FindViewById (Resource.Id.txtOfNewPanel)); spinMasterPanel = FindViewById<Spinner> (Resource.Id.spinnerExistingMasterPanel); //Code to add default value in the spinner First = new List<string> (); First.Add ("Select Parent Panel"); spinnerArrayAdapter = new ArrayAdapter<string> (this, Android.Resource.Layout.SimpleSpinnerItem, First); spinnerArrayAdapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem); spinMasterPanel.Adapter = spinnerArrayAdapter; //End appendSpinner (spinMasterPanel, parentItems, spinnerArrayAdapter, First); //Calling spinner to append more parent. imgBtnPlus.Click += (object sender, EventArgs e) => { if (SetTag == 1) { imgBtnPlus.SetImageResource (Resource.Drawable.Multsign); txtidofNewPanel.Visibility = ViewStates.Visible; tRowSaveCancel.Visibility = ViewStates.Visible; spinMasterPanel.Visibility = ViewStates.Visible; SetTag = 0; } else if (SetTag == 0) { imgBtnPlus.SetImageResource (Resource.Drawable.plussign); txtidofNewPanel.Visibility = ViewStates.Gone; tRowSaveCancel.Visibility = ViewStates.Gone; spinMasterPanel.Visibility = ViewStates.Gone; SetTag = 1; } }; btnCancel.Click += delegate { imgBtnPlus.SetImageResource (Resource.Drawable.plussign); tRowSaveCancel.Visibility = ViewStates.Gone; txtidofNewPanel.Visibility = ViewStates.Gone; spinMasterPanel.Visibility = ViewStates.Gone; }; #region SavePanelCLickActivity btnSavePanel.Click += (object sender, EventArgs e) => { imgBtnPlus.SetImageResource (Resource.Drawable.plussign); tRowSaveCancel.Visibility = ViewStates.Gone; txtidofNewPanel.Visibility = ViewStates.Gone; spinMasterPanel.Visibility = ViewStates.Gone; string newPanelText = txtidofNewPanel.Text.Trim (); if (newPanelText != "") { string spinnerItem = spinMasterPanel.SelectedItem.ToString (); // Selected item in the spinner if (spinnerItem != "Select Parent Panel") { child = new List<string> (); child.Add (newPanelText); if (NewParentItems.ContainsKey (spinnerItem)) { NewParentItems [spinnerItem].AddRange (child); dictPanelItemsForMail [spinnerItem].AddRange (child); } else { NewParentItems [spinnerItem] = child; dictPanelItemsForMail [spinnerItem] = child; } } else { child = new List<string> (); NewParentItems [newPanelText] = child; dictPanelItemsForMail [newPanelText] = child; appendSpinner (spinMasterPanel, newListForSpin, spinnerArrayAdapter, First); } child = new List<string> (); childItems.Add (child); myListViewAdap adapterNew = new myListViewAdap (NewParentItems); adapterNew.setInflater ((LayoutInflater)GetSystemService (Context.LayoutInflaterService), this); mListExView.SetAdapter (adapter); //Inflate Expandable Adapter txtidofNewPanel.Text = ""; InputMethodManager inputmanager = (InputMethodManager)GetSystemService (Context.InputMethodService); inputmanager.HideSoftInputFromWindow (txtidofNewPanel.WindowToken, HideSoftInputFlags.None); // To hide the keyboard spinMasterPanel.SetSelection (0, true); } }; #endregion SavePanelActivityEnd // Code to hide keyboard on spinner touch spinMasterPanel.Touch += (object sender, View.TouchEventArgs e) => { InputMethodManager inputmanager = (InputMethodManager)GetSystemService (Context.InputMethodService); inputmanager.HideSoftInputFromWindow (spinMasterPanel.WindowToken, HideSoftInputFlags.None); spinMasterPanel.PerformClick (); }; // code to handle ChildClick Event mListExView.ChildClick += mListExView_ChildClick; connectMaster (1); }
async Task SyncAsync (int flag) { try { //await client.SyncContext.PushAsync (); //await panelMasterItemStoreTable.PullAsync ("PanelItem",panelMasterItemStoreTable.CreateQuery()); //string z = "har"; //await panelItemStoreTable.PullAsync ("PanelMaster12" , panelItemStoreTable.CreateQuery()); listofMasterPanel = await panelMasterItemStoreTable.Where(j=>j.UserID== _userId) .Select (j => j.Id + ',' + j.PanelName).ToListAsync (); listofPanelItem = await panelItemStoreTable.OrderByDescending (j => j.MasterPanelID).Where(j=>j.UserID== _userId) .Select (i => i.MasterPanelID + ',' + i.PanelName + ':' + i.Id ).ToListAsync (); newListForSpin.Clear(); NewParentItems.Clear (); dictPanelItemsForMail.Clear (); foreach (string panelItem in listofPanelItem) { lenPanelItemTillName = panelItem.IndexOf (','); lenPanelItemTillId = panelItem.IndexOf (':'); string newItem = panelItem.Substring (0, lenPanelItemTillName); newPanelItem = panelItem.Substring (lenPanelItemTillName + 1, (lenPanelItemTillId - lenPanelItemTillName) - 1); foreach (string masteritem in listofMasterPanel) { if (lenPanelItemTillName == 0) { child = new List<string> (); NewParentItems [newPanelItem] = child; dictPanelItemsForMail [newPanelItem] = child; break; } lenMasterItem = masteritem.IndexOf (','); string newMasterItem = masteritem.Substring (0, lenMasterItem); if (newItem.Equals (newMasterItem)) { newMasterItem = masteritem.Substring (lenMasterItem + 1, (masteritem.Length - lenMasterItem) - 1); child = new List<string> (); childNewMail = new List<string> (); childNewMail.Add (panelItem); child.Add (newPanelItem); if (NewParentItems.ContainsKey (newMasterItem)) { NewParentItems [newMasterItem].AddRange (child); dictPanelItemsForMail [newMasterItem].AddRange (childNewMail); } else { NewParentItems [newMasterItem] = child; dictPanelItemsForMail [newMasterItem] = childNewMail; } } } } foreach( var z in NewParentItems.Keys) { if(NewParentItems[z].Count !=0) newListForSpin.Add(z); } if(NewParentItems.Count != 0) { appendSpinner (spinMasterPanel, newListForSpin, spinnerArrayAdapter, First); adapter = new myListViewAdap (NewParentItems); adapter.setInflater ((LayoutInflater)GetSystemService (Context.LayoutInflaterService), this); mListExView.SetAdapter (adapter); } progressBar.Visibility = ViewStates.Gone; } catch (MobileServiceInvalidOperationException e) { Console.WriteLine (e); } if(flag==0) mDrawerLayout.OpenDrawer (leftDrawerLinearLayoutId); }