Beispiel #1
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.action_filter:
            {
                ShowFilterDialog(filter =>
                    {
                        currentFilter = filter;

                        var items = FilterRoutes(routes).ToList();
                        if (items.Count > 0)
                        {
                            if (listView.Adapter is SmartAdapter <RouteInfo> )
                            {
                                routesAdapter.Items = items;
                            }
                            else
                            {
                                listView.Adapter = (routesAdapter = new SmartAdapter <RouteInfo>(this, Resource.Layout.route_dropdown_item, ViewHolders.ItemHolders.RouteItemBindings)
                                {
                                    Items = items
                                });
                            }
                        }
                        else
                        {
                            listView.Adapter = new ArrayAdapter <string>(this, global::Android.Resource.Layout.SimpleListItem1, new string[] { "No routes match selected filters!" });
                        }
                    });
            }
            break;
            }
            return(base.OnOptionsItemSelected(item));
        }
        public ManageWalletsActivity() : base(Resource.Layout.manage_wallet_layout)
        {
            OnLoaded += async delegate
            {
                //
                AllowBackNavigation();

                createOnly = Intent.GetBooleanExtra("createOnly", false);

                //
                FindViewById <FloatingActionButton>(Resource.Id.fab_add_wallet).Click += OnAddWallet;
                listView   = FindViewById <ListView>(Resource.Id.wallets_listview);
                emptyFrame = FindViewById <ViewGroup>(Resource.Id.empty_frame);
                //
                itemsAdapter     = new SmartAdapter <WalletInfo>(this, Resource.Layout.user_wallet_item_layout, ViewHolders.ItemHolders.WalletItemBindings);
                listView.Adapter = itemsAdapter;

                //
                swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh_root);
                swipeRefreshLayout.SetColorSchemeColors(AvatarDisplay.DefaultColors.Take(4).Select(t => t.ToArgb()).ToArray());
                swipeRefreshLayout.Refresh += async delegate
                {
                    await RefreshView();
                };


                //
                AddWalletDialogFragment.OnCreated       += OnWalletCreated;
                AddWalletDialogFragment.OnUpdated       += OnWalletUpdate;
                ViewHolders.ItemHolders.OnWalletRemoved += OnWalletRemoved;

                await RefreshView(false, true);
            };
        }
Beispiel #3
0
        public BusRoutesActivity() : base(Resource.Layout.bus_routes_layout)
        {
            OnLoaded += async delegate
            {
                AllowBackNavigation();

                var intent = Intent;
                bus = JsonConvert.DeserializeObject <BusInfo>(intent.GetStringExtra("bus"));
                SupportActionBar.Title = $"Routes - ({bus.Name})";

                //
                swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh_root);
                swipeRefreshLayout.SetDefaultColorScheme();
                swipeRefreshLayout.Refresh += async(s, e) =>
                {
                    if (isBusy)
                    {
                        return;
                    }

                    using (Busy(true))
                    {
                        await LoadRoutes();
                    }
                };

                //
                listView = FindViewById <ListView>(Resource.Id.routes_list_view);


                fabAddRoute = FindViewById <FloatingActionButton>(Resource.Id.fab_add_route);

                if (intent.GetBooleanExtra("allow_add", false))
                {
                    fabAddRoute.Click += OnAddRoute;
                }
                else
                {
                    //  Hide add button
                    fabAddRoute.Visibility = ViewStates.Gone;
                }

                //
                routesAdapter    = new SmartAdapter <RouteInfo>(this, Resource.Layout.route_dropdown_item, ViewHolders.ItemHolders.RouteItemBindings);
                listView.Adapter = routesAdapter;

                //
                await LoadRoutes();
            };
        }