private void SearchBoxOnQueryTextChange(object sender, SearchView.QueryTextChangeEventArgs queryTextChangeEventArgs)
        {
            SearchableTreeNode stnResult = SampleManager.Current.FullTree.Search(sample => SampleManager.Current.SampleSearchFunc(sample, queryTextChangeEventArgs.NewText));

            if (stnResult != null)
            {
                _filteredSampleCategories = stnResult.Items.OfType <SearchableTreeNode>().ToList();
                if (!_arCompatible)
                {
                    _filteredSampleCategories.RemoveAll(category => category.Name == "Augmented reality");
                }
            }
            else
            {
                _filteredSampleCategories = new List <SearchableTreeNode>();
            }

            _categoriesListView.SetAdapter(new CategoriesAdapter(this, _filteredSampleCategories));

            // Expand all entries; makes it easier to see search results.
            for (int index = 0; index < _filteredSampleCategories.Count; index++)
            {
                _categoriesListView.ExpandGroup(index);
            }
        }
 private void ExpandirTodosOsGruposDoListView()
 {
     for (int group = 0; group <= _adapter.GroupCount - 1; group++)
     {
         _listViewGastos.ExpandGroup(group);
     }
 }
Exemple #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            this.SetContentView(Resource.Layout.activity_control);

            if (SupportActionBar != null && selectedControl != null)
            {
                SupportActionBar.Title = selectedControl.ControlName();
            }

            this.expList = (ExpandableListView)this.FindViewById(Resource.Id.expListView);
            MoveIndicatorImage();

            ExamplesAdapter ea = new ExamplesAdapter(selectedControl.Examples());

            this.expList.SetAdapter(ea);

            for (int i = 0; i < ea.GroupCount; i++)
            {
                expList.ExpandGroup(i);
            }

            this.expList.ChildClick += (object sender, ExpandableListView.ChildClickEventArgs e) => {
                ExampleActivity.selectedExampleFragment = (Android.Support.V4.App.Fragment)ea.GetChild(e.GroupPosition, e.ChildPosition);
                Intent exampleIntent = new Intent(this, typeof(ExampleActivity));
                this.StartActivity(exampleIntent);
                e.Handled = true;
            };
        }
        /// <summary>
        /// Called when the collapse state of a group has changed.
        /// If the group is an ArtistAlbum then check whether or not the parent Artist should be shown as expanded or collapsed
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="groupPosition"></param>
        protected override void GroupCollapseStateChanged(ExpandableListView parent, int groupPosition)
        {
            if (Groups[groupPosition] is ArtistAlbum artistAlbum)
            {
                // Find the Artist associated with this ArtistAlbum
                int artistPosition = FindArtistPosition(groupPosition);

                // If the ArtistAlbum is now expanded then check if all the other ArtistAlbums are also expanded
                // If the ArtistAlbum is now collapsed then collapse the Artist
                if (parent.IsGroupExpanded(groupPosition) == true)
                {
                    // Need to check all of the ArtistAlbum entries associated with the Artist. If they are all expanded then expand the Artist as well
                    if (CheckAllArtistAlbums(artistPosition, (artistAlbumIndex) => parent.IsGroupExpanded(artistAlbumIndex)) == true)
                    {
                        // Add this to the record of which groups are expanded
                        adapterModel.ExpandedGroups.Add(artistPosition);

                        // Now expand the group
                        parent.ExpandGroup(artistPosition);
                    }
                }
                else
                {
                    // If the parent is expanded then collapse it
                    if (parent.IsGroupExpanded(artistPosition) == true)
                    {
                        adapterModel.ExpandedGroups.Remove(artistPosition);

                        // Now collapse the group
                        parent.CollapseGroup(artistPosition);
                    }
                }
            }
        }
        public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
        {
            ExpandableListView mExpandableListView = (ExpandableListView)parent;

            mExpandableListView.ExpandGroup(groupPosition);
            HeaderViewHolder headerViewHolder;
            var user = GetGroup(groupPosition).Cast2 <UserCompany>();

            if (convertView == null)
            {
                LayoutInflater layoutInflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
                convertView = layoutInflater.Inflate(Resource.Layout.activity_user_list_item_header, null);

                headerViewHolder = new HeaderViewHolder();
                headerViewHolder.txtCompanyName = (TextView)convertView.FindViewById(Resource.Id.userListCompanyName);

                convertView.Tag = headerViewHolder;
            }
            else
            {
                headerViewHolder = (HeaderViewHolder)convertView.Tag;
            }

            headerViewHolder.txtCompanyName.Typeface = Typeface.DefaultBold;
            headerViewHolder.txtCompanyName.Text     = user.CompanyName;

            return(convertView);
        }
Exemple #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            MobileAds.Initialize(this, "ca-app-pub-5131184764831509~8873327557");
            ShowBannerAd();
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(this);
            ISharedPreferencesEditor editor = prefs.Edit();

            day    = DataProvider.getdayInfo(this);
            length = day.Length - 1;

            mButton        = FindViewById <Button>(Resource.Id.button1);
            mButton.Click += (sender, e) =>
            {
                editor.Clear();
                editor.Apply();

                Intent I = new Intent(this, typeof(MainActivity));
                StartActivity(I);
                Finish();
            };
            DatePickerChangeHandler datePickerChangeHandler = new DatePickerChangeHandler(this);

            DP    = FindViewById <DatePicker>(Resource.Id.datePicker1);
            DTNow = DateTime.Now;
            DP.Init(DTNow.Year, DTNow.Month - 1, DTNow.Day, datePickerChangeHandler);


            IndexofDay = DTNow.Month == 9 ? (DTNow.Day - 1) % length : DTNow.Month == 10 ? (DTNow.Day + 1) % length : DTNow.Month == 11 ? (DTNow.Day + 4) % length : DTNow.Month == 12 ? (DTNow.Day + 6) % length : length;


            myHeader = DataProvider.getInfo(this);
            myChild  = new List <string>();
            myChild.Add(day[IndexofDay]);
            mExListView = FindViewById <ExpandableListView>(Resource.Id.EListView);
            adapter     = new EListViewAdapter(this, myHeader, myChild);
            mExListView.SetAdapter(adapter);
            mExListView.ExpandGroup(0);


            mExListView.ChildClick += (sender, e) =>
            {
                if (prefs.Contains("QKG 3") || prefs.Contains("QKG 4"))
                {
                    ChildData = DataProvider.getChildInfo(myHeader[day[IndexofDay]][e.ChildPosition], day[IndexofDay], this);
                }
                else
                {
                    ChildData = DataProvider.getChildInfo(myHeader[day[IndexofDay]][e.ChildPosition], this);
                }
                RegisterForContextMenu(mExListView);
                OpenContextMenu(mExListView);
            };
        }
Exemple #7
0
        public void setOnDateChangedListener(int monthOfYear, int dayOfMonth)
        {
            IndexofDay = monthOfYear + 1 == 9 ? (dayOfMonth - 1) % length : monthOfYear + 1 == 10 ? (dayOfMonth + 1) % length : monthOfYear + 1 == 11 ? (dayOfMonth + 4) % length : monthOfYear + 1 == 12 ? (dayOfMonth + 6) % length : length;
            List <string> searchedClass = new List <string>();

            searchedClass.Add(day[IndexofDay]);
            adapter = new EListViewAdapter(this, myHeader, searchedClass);
            mExListView.SetAdapter(adapter);
            mExListView.ExpandGroup(0);
        }
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            try
            {
                SetContentView(Resource.Layout.UserProfile);

                //get data from API
                AppPreferences appPref = new AppPreferences();
                string         uri     = Values.ApiRootAddress + "UserProfile/GetBasicDetails?compId=" + appPref.GetValue(User.CompId) + "&empNo=" + appPref.GetValue(User.EmployeeNo);

                Toast.MakeText(this, Values.LoadingMsg, ToastLength.Short).Show();

                dynamic json = await new DataApi().GetAsync(uri);

                if (IsJsonObject(json))
                {
                    JsonValue          basicDetailsData    = json["BasicDetails"];
                    JsonValue          qualificationsData  = json["Qualifications"];
                    JsonValue          profCredentialsData = json["ProfessionalCredentials"];
                    JsonValue          employeeTypeData    = json["EmployeeType"];
                    JsonValue          reportToData        = json["ReportTo"];
                    ExpandableListView expListView         = FindViewById <ExpandableListView>(Resource.Id.expdLstVw1);

                    //Bind list
                    List <string> parentList = GenerateParents();
                    Dictionary <string, List <string> > childDictionaryList = GenerateChildItems(parentList, basicDetailsData, qualificationsData, profCredentialsData, employeeTypeData, reportToData);
                    MyExpandableListAdapter             listAdapter         = new MyExpandableListAdapter(this, parentList, childDictionaryList);
                    expListView.SetAdapter(listAdapter);
                    expListView.ExpandGroup(0); expListView.ExpandGroup(1); expListView.ExpandGroup(2); expListView.ExpandGroup(3); expListView.ExpandGroup(4);
                }
                else
                {
                    Toast.MakeText(this, (string)json, ToastLength.Long).Show();
                }
            }
            catch (Exception ex)
            {
                ex.Log();
                Toast.MakeText(this, Values.ErrorMsg, ToastLength.Long).Show();
            }
        }
Exemple #9
0
        public void OnGroupClicked(object sender, global::Android.Widget.ExpandableListView.GroupClickEventArgs e)
        {
            if (e.GroupPosition == _previousGroup)
            {
                _navDrawerListview.CollapseGroup(e.GroupPosition);
                _previousGroup = -1;
            }
            else
            {
                _navDrawerListview.ExpandGroup(e.GroupPosition);
            }

            OnNavigationItemSelected(NAV_DRAWER_GROUP_RESOURCES[e.GroupPosition].Resource1, -1, _drawer);
        }
        public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
        {
            HeaderItemHolder   headerHolder;
            View               header = convertView;
            ExpandableListView menuExpandableListView = (ExpandableListView)parent;

            if (header == null)
            {
                header       = _context.LayoutInflater.Inflate(Resource.Layout.CustomMenuHeaderRow, null);
                headerHolder = new HeaderItemHolder(header.FindViewById <ImageView>(Resource.Id.MenuHeader_ImageView), header.FindViewById <TextView>(Resource.Id.MenuHeader_TextView), header.FindViewById <ImageView>(Resource.Id.MenuHeaderIndicator_ImageView));
                header.Tag   = headerHolder;
            }
            else
            {
                headerHolder = (HeaderItemHolder)header.Tag;
            }


            if (groupPosition < _menuictionary.Keys.Count)
            {
                headerHolder.MenuHeaderIndicator_ImageView.Touch += (s, e) =>
                {
                    switch (_menuictionary.ElementAt(groupPosition).Key.Expanded)
                    {
                    case true:
                        menuExpandableListView.CollapseGroup(groupPosition);
                        _menuictionary.ElementAt(groupPosition).Key.Expanded = false;
                        headerHolder.MenuHeaderIndicator_ImageView.SetImageResource(Resource.Drawable.ic_down);
                        break;

                    case false:
                        menuExpandableListView.ExpandGroup(groupPosition);
                        _menuictionary.ElementAt(groupPosition).Key.Expanded = true;
                        headerHolder.MenuHeaderIndicator_ImageView.SetImageResource(Resource.Drawable.ic_up);
                        break;

                    default:
                        break;
                    }
                };
            }

            return(header);
        }
Exemple #11
0
 private void Expand()
 {
     try
     {
         if (_activitiesWeek != null)
         {
             for (var a = 0; a < GlobalData.ActivitiesForWeek.Count; a++)
             {
                 _activitiesWeek.ExpandGroup(a);
             }
         }
     }
     catch (Exception e)
     {
         Log.Error(TAG, "Expand: Exception - " + e.Message);
         if (GlobalData.ShowErrorDialog)
         {
             ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorActivitiesCollapse), "ActivitiesActivity.Expand");
         }
     }
 }
Exemple #12
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle)
        {
            View view = inflater.Inflate(Resource.Layout.JumpNotes, container, false);

            view.FindViewById <TextView>(Resource.Id.jumpCommentsIntro).Text = string.Join(GetString(Resource.String.JumpSeparator), jump);
            ExpandableListView listOutput = view.FindViewById <ExpandableListView>(Resource.Id.jumpNotesListView);
            var adapter = new FormationsWithNotesAdapter(this.Activity, listOutput, FSNotesHandler.Notes, this.jump, null, true);

            listOutput.SetAdapter(adapter);
            for (int i = 0; i < adapter.GroupCount; i++)
            {
                listOutput.ExpandGroup(i);
            }
            TextView timeLeftField = view.FindViewById <TextView>(Resource.Id.jumpTimeLeft);

            Button jumpTimerOperButton = view.FindViewById <Button>(Resource.Id.jumpTimerOperButton);
            var    timer = new JumpTimer(timeLeftField, context);

            timeLeftField.Text = timer.formatRemainingTime(FSNotesHandler.JUMPTIME_MS / 1000);
            bool isStarted = false;

            //muuta nappi taustaltaa värikkääskis!!!!
            jumpTimerOperButton.Click += delegate
            {
                if (isStarted)
                {
                    timer.Cancel();
                    jumpTimerOperButton.Text = "Start timer";
                    timer.initTime();
                }
                else
                {
                    timer.Start();
                    jumpTimerOperButton.Text = "Stop timer";
                }
                isStarted = !isStarted;
            };
            return(view);
        }
Exemple #13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            expListView = FindViewById <ExpandableListView>(Resource.Id.RosterListview);

            DataAccess.Initialize();
            GetListData();

            listAdapter = new RosterDataAdapter(this, listDataHeader, listDataChild);
            expListView.SetAdapter(listAdapter);

            expListView.ExpandGroup(0);
            expListView.ExpandGroup(1);
            expListView.ExpandGroup(2);

            expListView.ChildClick += delegate(object sender, ExpandableListView.ChildClickEventArgs e)
            {
                var groupPosition = e.GroupPosition;
                var childPosition = e.ChildPosition;

                if (groupPosition == 2) //roster
                {
                    var player = listAdapter.GetChildObj(groupPosition, childPosition);

                    listAdapter.DeleteChild(groupPosition, childPosition);
                    player = listAdapter.AddChild(groupPosition - 1, player);

                    Player.UpdatePlayer(player);
                }
                else if (groupPosition == 1) //bench
                {
                    var player = listAdapter.GetChildObj(groupPosition, childPosition);

                    listAdapter.DeleteChild(groupPosition, childPosition);
                    player = listAdapter.AddChild(groupPosition - 1, player);

                    Player.UpdatePlayer(player);
                }
                else //game
                {
                    var player = listAdapter.GetChildObj(groupPosition, childPosition);

                    if (!player.isGoalkeeper)
                    {
                        listAdapter.DeleteChild(groupPosition, childPosition);
                        player = listAdapter.AddChild(groupPosition + 1, player);

                        Player.UpdatePlayer(player);
                    }
                }
                listAdapter.NotifyDataSetChanged();
            };

            expListView.ItemLongClick += delegate(object sender, AdapterView.ItemLongClickEventArgs e)
            {
                var listPosition  = expListView.GetExpandableListPosition(e.Position);
                var groupPosition = ExpandableListView.GetPackedPositionGroup(listPosition);
                var childPosition = ExpandableListView.GetPackedPositionChild(listPosition);

                if (groupPosition == 1 || groupPosition == 0)
                {
                    var player = listAdapter.GetChildObj(groupPosition, childPosition);

                    listAdapter.DeleteChild(groupPosition, childPosition);
                    player = listAdapter.AddChild(2, player);

                    Player.UpdatePlayer(player);
                }
                listAdapter.NotifyDataSetChanged();
            };

            homeScoreMinus = FindViewById <ImageButton>(Resource.Id.home_score_minus);
            homeScore      = FindViewById <TextView>(Resource.Id.home_score);
            homeScorePlus  = FindViewById <ImageButton>(Resource.Id.home_score_plus);
            matchTime      = FindViewById <TextView>(Resource.Id.match_time);
            awayScoreMinus = FindViewById <ImageButton>(Resource.Id.away_score_minus);
            awayScore      = FindViewById <TextView>(Resource.Id.away_score);
            awayScorePlus  = FindViewById <ImageButton>(Resource.Id.away_score_plus);

            if (savedInstanceState != null)
            {
                homeScoreVal = savedInstanceState.GetInt("home_score");
                awayScoreVal = savedInstanceState.GetInt("away_score");

                homeScore.Text = homeScoreVal.ToString();
                awayScore.Text = awayScoreVal.ToString();
            }

            homeScoreMinus.Click += (sender, e) => {
                if (homeScoreVal > 0)
                {
                    homeScoreVal--;
                    homeScore.Text = homeScoreVal.ToString();
                }
            };

            homeScorePlus.Click += (sender, e) =>
            {
                homeScoreVal++;
                homeScore.Text = homeScoreVal.ToString();
            };

            awayScoreMinus.Click += (sender, e) =>
            {
                if (awayScoreVal > 0)
                {
                    awayScoreVal--;
                    awayScore.Text = awayScoreVal.ToString();
                }
            };

            awayScorePlus.Click += (sender, e) =>
            {
                awayScoreVal++;
                awayScore.Text = awayScoreVal.ToString();
            };

            var bottomMenu = FindViewById <Toolbar>(Resource.Id.toolbar_bottom);

            bottomMenu.InflateMenu(Resource.Menu.Bottom_Menu);
            bottomMenu.MenuItemClick += (sender, e) =>
            {
                if (e.Item.ItemId == Resource.Id.menuAddPlayer)
                {
                    var intent = new Intent(this, typeof(AddPlayerActivity));
                    StartActivity(intent);
                    Finish();
                }
                else if (e.Item.ItemId == Resource.Id.menuResetGame)
                {
                    var builder = new AlertDialog.Builder(this);

                    builder.SetMessage(Resources.GetString(Resource.String.reset_game));
                    builder.SetNegativeButton(Resources.GetString(Resource.String.no), (s, ee) => { });
                    builder.SetPositiveButton(Resources.GetString(Resource.String.yes), (s, ee) =>
                    {
                        StopMatchClock();
                        ResetMatchClock();
                        ResetScores();
                        ResetListData();
                        listAdapter.NotifyDataSetChanged();
                    });

                    builder.Create().Show();
                }
                else if (e.Item.ItemId == Resource.Id.menuStartMatchClock)
                {
                    StartMatchClock();
                }
                else if (e.Item.ItemId == Resource.Id.menuStopMatchClock)
                {
                    StopMatchClock();
                }
                else if (e.Item.ItemId == Resource.Id.menuResetMatchClock)
                {
                    var builder = new AlertDialog.Builder(this);

                    builder.SetMessage(Resources.GetString(Resource.String.reset_match_clock));
                    builder.SetNegativeButton(Resources.GetString(Resource.String.no), (s, ee) => { });
                    builder.SetPositiveButton(Resources.GetString(Resource.String.yes), (s, ee) =>
                    {
                        ResetMatchClock();
                    });

                    builder.Create().Show();
                }
                else if (e.Item.ItemId == Resource.Id.menuResetScores)
                {
                    var builder = new AlertDialog.Builder(this);

                    builder.SetMessage(Resources.GetString(Resource.String.reset_scores));
                    builder.SetNegativeButton(Resources.GetString(Resource.String.no), (s, ee) => { });
                    builder.SetPositiveButton(Resources.GetString(Resource.String.yes), (s, ee) =>
                    {
                        ResetScores();
                    });

                    builder.Create().Show();
                }
            };
        }
Exemple #14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.main_layout);
            rnd     = new System.Random();
            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetTitle(Resource.String.Projects);
            SetSupportActionBar(toolbar);

            //Enable support action bar to display hamburger
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu_white_18dp);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
            View           v        = inflater.Inflate(Resource.Layout.drawer_header, null);

            TVUserFullName = v.FindViewById <TextView>(Resource.Id.user_full_name);
            TVUserFullName.SetBackgroundColor(Android.Graphics.Color.Argb(200, rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)));

            TVUserFullName.Text = RedMineManager.currUser.firstname + " " + RedMineManager.currUser.lastname ?? "Firstname Lastname";
            navigationView.AddHeaderView(v);
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_my_issues:
                    Intent i0 = new Intent(this, typeof(IssueActivity.IssueActivity));
                    i0.PutExtra("Kind", "My Issues");
                    StartActivity(i0);
                    break;

                case Resource.Id.nav_projects:
                    if (RedMineManager.currUser.status == 1)
                    {
                        Intent i4 = new Intent(this, typeof(MainActivity));
                        StartActivity(i4);
                    }
                    else
                    {
                        Toast.MakeText(this, Resources.GetString(Resource.String.PermissionError), ToastLength.Short).Show();
                    }
                    break;

                case Resource.Id.settings:
                    Intent i = new Intent(this, typeof(SettingsActivity.SettingsActivity));
                    i.PutExtra("Domen", RedMineManager.client.BaseUrl.ToString());
                    StartActivity(i);
                    break;

                case Resource.Id.administration:
                    if (RedMineManager.currUser.status == 1)
                    {
                        Intent i2 = new Intent(this, typeof(VerifiedUserActivity));
                        StartActivity(i2);
                    }
                    else
                    {
                        Toast.MakeText(this, Resources.GetString(Resource.String.PermissionError), ToastLength.Short).Show();
                    }
                    break;

                case Resource.Id.log_out:
                    LoginActivity.CredentialsStore.Delete();
                    Intent i3 = new Intent(this, typeof(LoginActivity.LoginActivity));
                    Finish();
                    StartActivity(i3);
                    break;

                case Resource.Id.exit:
                    Finish();
                    break;
                }
                drawerLayout.CloseDrawers();
            };

            LinearLayout LLControls = FindViewById <LinearLayout>(Resource.Id.right_controls);
            Thread       load       = new Thread(() =>
            {
                LVProjects = FindViewById <ExpandableListView>(Resource.Id.list_projects);
                SetData();
                RunOnUiThread(() =>
                {
                    ImageView BNewProject = new ImageView(this);
                    BNewProject.SetImageResource(Resource.Drawable.ic_add_white_18dp);
                    if (RedMineManager.currUser.status != 1)
                    {
                        BNewProject.Visibility = ViewStates.Gone;
                    }
                    LLControls.AddView(BNewProject);
                    BNewProject.Click += delegate
                    {
                        Intent i = new Intent(this, typeof(NewProjectActivity));
                        i.PutExtra("IsNew", true);
                        StartActivityForResult(i, 0);
                    };

                    LVProjects.GroupClick += (object sender, ExpandableListView.GroupClickEventArgs e) =>
                    {
                        if (mAdapter.GetChildrenCount(e.GroupPosition) == 0)
                        {
                            Intent i = new Intent(this, typeof(OneProjectActivity));
                            i.PutExtra("Kind", "Project Issues");
                            i.PutExtra("ProjectId", (int)mAdapter.GetGroup(e.GroupPosition));
                            StartActivity(i);
                        }
                        else
                        if (!LVProjects.IsGroupExpanded(e.GroupPosition))
                        {
                            LVProjects.ExpandGroup(e.GroupPosition);
                        }
                        else
                        {
                            LVProjects.CollapseGroup(e.GroupPosition);
                        }
                    };

                    LVProjects.ChildClick += (object sender, ExpandableListView.ChildClickEventArgs e) =>
                    {
                        Intent i = new Intent(this, typeof(OneProjectActivity));
                        i.PutExtra("Kind", "Project Issues");
                        i.PutExtra("ProjectId", (int)mAdapter.GetChild(e.GroupPosition, e.ChildPosition));
                        StartActivity(i);
                    };
                });
            });

            load.Start();

            SwipeRefreshLayout refresh = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh);

            refresh.SetDistanceToTriggerSync(50);
            refresh.SetColorSchemeResources(Resource.Color.colorAccent, Resource.Color.colorPrimary);
            refresh.Refresh += delegate
            {
                Thread t = new Thread(() =>
                {
                    SetData();
                    RunOnUiThread(() =>
                    {
                        Recreate();
                        refresh.Refreshing = false;
                    });
                });
                t.Start();
            };
        }
Exemple #15
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.NearbyConnection, container, false);

            AvalibleDeviceslistview = (ExpandableListView)view.FindViewById(Resource.Id.Nearby_Devices1);
            AvalibleDeviceslistview.SetAdapter(MainActivity.Adapter);
            switchScan  = view.FindViewById <Switch>(Resource.Id.switchScan);
            switchBroad = view.FindViewById <Switch>(Resource.Id.switchBroadcast);
            M_SERVICE   = (MainActivity)Activity;
            RegisterForContextMenu(AvalibleDeviceslistview);


            switchScan.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e)
            {
                if (e.IsChecked)
                {
                    Toast.MakeText((Activity), " Starting Scanning ", ToastLength.Short).Show();
                    ScanOption.Builder discBuilder = new ScanOption.Builder();
                    Policy             policy      = Policy.PolicyStar;
                    discBuilder.SetPolicy(policy);
                    MainActivity.mDiscoveryEngine.StartScan(MainActivity.MyServiceID, new ScanCallBack((MainActivity)Activity), discBuilder.Build()).AddOnSuccessListener(new TaskListener(Activity.ApplicationContext, "StartScanning")).AddOnFailureListener(new TaskListener(Activity.ApplicationContext, "StartScanning"));
                    Log.Debug(MainActivity.TAG, "ScanOption.Builder : Policy :" + policy.ToString());
                }
                else
                {
                    Toast.MakeText(Activity.ApplicationContext, " Stopping Scanning ", ToastLength.Short).Show();
                    MainActivity.mDiscoveryEngine.StopScan();
                }
            };

            switchBroad.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e)
            {
                if (e.IsChecked)
                {
                    Toast.MakeText((Activity), " Starting Broadcasting ", ToastLength.Short).Show();
                    BroadcastOption.Builder advBuilder = new BroadcastOption.Builder();
                    Policy policy = Policy.PolicyStar;
                    advBuilder.SetPolicy(policy);
                    MainActivity.mDiscoveryEngine.StartBroadcasting(MainActivity.MyEndPoint, MainActivity.MyServiceID, new ConnCallBack((MainActivity)Activity), advBuilder.Build()).AddOnSuccessListener(new TaskListener(Activity.ApplicationContext, "StartBroadcasting")).AddOnFailureListener(new TaskListener(Activity.ApplicationContext, "StartBroadcasting"));
                    Log.Debug(MainActivity.TAG, "BroadcastOption.Builder : Policy :" + policy.ToString());
                }
                else
                {
                    Toast.MakeText(Activity.ApplicationContext, " Stopping Broadcasting ", ToastLength.Short).Show();
                    MainActivity.mDiscoveryEngine.StopBroadcasting();
                }
            };

            AvalibleDeviceslistview.GroupClick += delegate(object sender, ExpandableListView.GroupClickEventArgs e)
            {
                if (!MainActivity.AvaliableDevicesList.ElementAt(e.GroupPosition).Status)
                {
                    MainActivity.InitiateConnection(MainActivity.AvaliableDevicesList.ElementAt(e.GroupPosition));
                }
                else if (AvalibleDeviceslistview.IsGroupExpanded(e.GroupPosition))
                {
                    AvalibleDeviceslistview.CollapseGroup(e.GroupPosition);
                }
                else
                {
                    AvalibleDeviceslistview.ExpandGroup(e.GroupPosition);
                }
            };

            return(view);
        }