/// <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); } } } }
/// <summary> /// Override the base method in order to process Artist groups differently /// </summary> /// <param name="parent"></param> /// <param name="clickedView"></param> /// <param name="groupPosition"></param> /// <param name="id"></param> /// <returns></returns> public override bool OnGroupClick(ExpandableListView parent, View clickedView, int groupPosition, long id) { bool retVal = true; if (Groups[groupPosition] is Artist artist) { // If the Artist group is collapsed then expand all the ArtistAlbum groups that are collapsed // If the Artist group is expanded then collapse all the ArtistAlbum groups that are expanded bool expandGroup = !parent.IsGroupExpanded(groupPosition); // Expand or collapse all of the ArtistAlbums associated with the Artist PerformActionOnArtistAlbums(groupPosition, (artistAlbumIndex) => { if (parent.IsGroupExpanded(artistAlbumIndex) != expandGroup) { base.OnGroupClick(parent, clickedView, artistAlbumIndex, id); } }); } else { retVal = base.OnGroupClick(parent, clickedView, groupPosition, id); } return(retVal); }
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(); }; }
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); }