Ejemplo n.º 1
0
        public async Task <bool> GetWorkshops(Boolean blnOnline = true)
        {
            try
            {
//				if (blnOnline == true)
//				{
                WrkSets = await RESTClass.GetWorkshopList("?active=true");

//				}
//				else
//				{
//					WrkSets = new List<WorkshopSets> {};
//
//					WrkSets.Add(new WorkshopSets(1, "Cannot connect to server... Try again later", "01/02/2015"));
//					WrkSets.Add(new WorkshopSets(2, "Offline WritingSkills", "01/02/2015"));
//					WrkSets.Add(new WorkshopSets(3, "Offline Study + Reading skills", "01/02/2015"));
//					WrkSets.Add(new WorkshopSets(4, "Offline Presentation + Speaking Skills", "01/02/2015"));
//				}

                // create our adapter
                taskList = new Adapters.TaskListAdapter(this, WrkSets);

                //Hook up our adapter to our ListView
                lvWorkShops.Adapter = taskList;

                return(true);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this)
                .SetMessage(e.Message + "\n" + e.StackTrace)
                .SetTitle("Application Error")
                .Show();
                return(false);
            }
        }
Ejemplo n.º 2
0
        protected async override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.Search);
                List <string>       WorkshopList;
                List <WorkshopSets> WrkSets;
                EditText            txtsearch      = FindViewById <EditText>(Resource.Id.txtsearch);
                Spinner             searchWorkshop = FindViewById <Spinner>(Resource.Id.ddpworkshop);
                ExpandableListView  ddpSearchList  = FindViewById <ExpandableListView> (Resource.Id.ddpSearch);
                ImageButton         btnsearch      = FindViewById <ImageButton>(Resource.Id.imgsearch);
                ListView            workshoplist   = FindViewById <ListView>(Resource.Id.lvlWorkShops);
                string search;


                WorkshopList = new List <string>();
                WorkshopList.Add("Session");
                WorkshopList.Add("Workshop");
                WorkshopList.Add("Programs");
                ArrayAdapter <String> adapter = new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleDropDownItem1Line, WorkshopList);
                searchWorkshop.Adapter = adapter;

                btnsearch.Click += async delegate
                {
                    try
                    {
                        search = txtsearch.Text;
                        string searchBy;
                        searchBy = searchWorkshop.SelectedItem.ToString();

                        progressDialog = ProgressDialog.Show(this, "", "Searching...");

                        if (searchBy == "Session")
                        {
                            //string WorkshopSetId = Intent.GetStringExtra(search);
                            _WorkshopSessions = await RESTClass.GetWorkshopSessions("?workshopSetId=" + search);

                            //_WorkshopSessions = await RESTClass.GetWorkshopSessions("?topic=" + WorkshopSetId + "&active=true&etc.");
                        }
                        else if (searchBy == "Workshop")
                        {
                            WrkSets = await RESTClass.GetWorkshopList("?active=true");

                            taskList             = new Adapters.SearchAdapter(this, WrkSets);
                            workshoplist.Adapter = taskList;
                            //	lvWorkShops.Adapter = taskList;


                            //			new AlertDialog.Builder (this)
                            //				.SetMessage(taskList.GetId(0))
                            //				.SetTitle("Application Error")
                            //				.Show();
                        }
                        else if (searchBy == "Programs")
                        {
                            //await Ge
                        }
                        dictGroup.Clear();
                        CreateExpendableListData();

                        ddpSearchList.SetAdapter(new ExpandListSessionAdapter(this, dictGroup));
                    }
                    catch (Exception e)
                    {
                        ErrorHandling.LogError(e, this);
                    }
                    finally
                    {
                        progressDialog.Dismiss();
                        progressDialog.Dispose();
                    }
                };

                ddpSearchList.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e)
                {
                    try
                    {
                        string           itmGroup = lstKeys [e.GroupPosition];
                        WorkshopSessions itmChild = dictGroup [itmGroup];
                    }
                    catch (Exception Ex)
                    {
                        ErrorHandling.LogError(Ex, this);
                    }
                };

                ddpSearchList.GroupExpand += delegate(object sender, ExpandableListView.GroupExpandEventArgs e)
                {
                    if (lastExpandedPosition != -1 && e.GroupPosition != lastExpandedPosition)
                    {
                        ddpSearchList.CollapseGroup(lastExpandedPosition);
                    }

                    lastExpandedPosition = e.GroupPosition;
                };

                //				Button btnViewDetails = FindViewById<Button>(Resource.Id.btnViewDetails);
                //				btnViewDetails.Click += delegate {
                //					StartActivity(new Intent(this, typeof(MakeBookingListActivity)));
                //				} ;
            }
            catch (Exception e)
            {
                ErrorHandling.LogError(e, this);
            }
            finally
            {
                //				progressDialog.Dismiss();
                //				progressDialog.Dispose ();
            }
        }