Ejemplo n.º 1
0
        private void SetUpAdapter()
        {
            notifsRecycler = FindViewById <RecyclerView>(Resource.Id.nitifs_recycler);
            List <NotifsDataModel> notifsList = new List <NotifsDataModel>()
            {
                new NotifsDataModel()
                {
                    Title = "New ride request", Image = Resource.Drawable.tips, DateTime = DateTime.UtcNow
                },
                new NotifsDataModel()
                {
                    Title = "Maintenance section is due", Image = Resource.Drawable.school_bell, DateTime = DateTime.UtcNow
                },
            };

            NotifsRecyclerAdapter adapter = new NotifsRecyclerAdapter(notifsList);

            notifsRecycler.SetLayoutManager(new LinearLayoutManager(this));
            notifsRecycler.SetAdapter(adapter);
            SwipeActions sa = new SwipeActions((pos1 => { }),
                                               (pos2 =>
            {
                adapter._notificationsList.RemoveAt(pos2);
                adapter.NotifyItemRemoved(pos2);
                adapter.NotifyItemRangeChanged(pos2, adapter.ItemCount);
            }));

            sc = new SwipeControllerUtils(sa);
            ItemTouchHelper helper = new ItemTouchHelper(sc);

            helper.AttachToRecyclerView(notifsRecycler);
            notifsRecycler.AddItemDecoration(new ItemDecorator(sc));
        }
Ejemplo n.º 2
0
        private void InitAuthenticators()
        {
            _authSource = new AuthSource(_connection);

            var isCompact = _sharedPrefs.GetBoolean("pref_compactMode", false);

            _authAdapter = new AuthAdapter(_authSource, IsDark, isCompact);

            _authAdapter.ItemClick        += ItemClick;
            _authAdapter.ItemOptionsClick += ItemOptionsClick;
            _authAdapter.SetHasStableIds(true);

            _authList.SetAdapter(_authAdapter);
            _authList.HasFixedSize = true;
            _authList.SetItemViewCacheSize(20);

            var animation =
                AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fall_down);

            _authList.LayoutAnimation = animation;

            var useGrid = IsTablet();
            var layout  = new AuthListGridLayoutManager(this, useGrid ? 2 : 1);

            _authList.SetLayoutManager(layout);

            var callback    = new AuthListTouchHelperCallback(_authAdapter, useGrid);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_authList);
        }
        public DraggableCollectionViewRenderer(Context context) : base(context)
        {
            itemHelperCallback = new SimpleItemTouchHelperCallback();

            ItemTouchHelper.Callback callback = itemHelperCallback;
            mItemTouchHelper = new ItemTouchHelper(callback);
        }
Ejemplo n.º 4
0
        protected override void InitBindings()
        {
            RecyclerView.SetAdapter(new RecyclerViewAdapterBuilder <WatchedItemViewModel, RecyclerView.ViewHolder>()
                                    .WithItems(ViewModel.WatchedItems)
                                    .WithContentStretching()
                                    .WithMultipleViews()
                                    .WithGroup <WatchedItemViewModel, WatchedItemHolder>(builder =>
            {
                builder.WithResourceId(LayoutInflater, Resource.Layout.item_feed);
                builder.WithDataTemplate(WatchedItemDataTemplate);
            })
                                    .WithGroup <WatchedItemViewModel <YahooItem>, WatchedItemYahooHolder>(builder =>
            {
                builder.WithResourceId(LayoutInflater, Resource.Layout.item_feed_yahoo);
                builder.WithDataTemplate(WatchedItemYahooDataTemplate);
            })
                                    .Build());

            SwipeToRefreshLayout.ScrollingView = RecyclerView;
            SwipeToRefreshLayout.Refresh      += SwipeToRefreshLayoutOnRefresh;
            RecyclerView.SetLayoutManager(new LinearLayoutManager(Activity));
            ViewModel.WatchedItems.SetUpWithEmptyState(EmptyState);
            var touchHelper = new ItemTouchHelper(new ItemTouchHelperCallback(this));

            touchHelper.AttachToRecyclerView(RecyclerView);
        }
Ejemplo n.º 5
0
        protected override void OnElementChanged(ElementChangedEventArgs <HorizontalListView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null)
            {
                if (_dragHelper != null)
                {
                    _dragHelper.AttachToRecyclerView(null);
                    _dragHelper = null;
                }

                if (!Control.IsNullOrDisposed())
                {
                    Control.ClearOnScrollListeners();
                    var treeViewObserver = Control.ViewTreeObserver;
                    if (treeViewObserver != null)
                    {
                        treeViewObserver.PreDraw -= OnPreDraw;
                    }

                    Control.GetAdapter()?.Dispose();
                    Control.GetLayoutManager()?.Dispose();
                }
            }

            if (e.NewElement != null)
            {
                CreateView(e.NewElement);
            }
        }
Ejemplo n.º 6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.list_of_items_activity);

            var toolbar = (Toolbar)FindViewById(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            _list = (RecyclerView)FindViewById(Resource.Id.list);
            _list.SetLayoutManager(new LinearLayoutManager(this));
            _list.SetAdapter(_adapter);
            var recyclerItemClick = new RecyclerItemClickListener(ApplicationContext);

            _list.AddOnItemTouchListener(recyclerItemClick);
            recyclerItemClick.ItemClickEvent +=
                (sender, e) => { ShowPopup(_adapter.GetItem(e.Position)); };

            var callback = new SwipeTouchHelper();

            callback.ItemSwipeEvent += (sender, e) => { DeleteItem(e.Item); };

            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_list);

            var fab = (FloatingActionButton)FindViewById(Resource.Id.fab);

            fab.Click += delegate { ShowPopup(new ShoppingItem("")); };
        }
Ejemplo n.º 7
0
        protected override void OnStart()
        {
            base.OnStart();

            // Get this page view and data context
            var page      = FindViewById(Resource.Id.taskSummaryPage);
            var viewModel = BindingContext.DataContext as TasksSummaryPageViewModel;

            // Find task list container
            var recyclerView = (MvxRecyclerView)page.FindViewById(Resource.Id.taskList);

            // Allow item movements
            var callback        = new MovementRecyclerViewItemCallback(recyclerView.GetAdapter());
            var itemTouchHelper = new ItemTouchHelper(callback);

            itemTouchHelper.AttachToRecyclerView(recyclerView);
            recyclerView.SetItemAnimator(new DefaultItemAnimator());

            // When full move-over on item happens...
            callback.OnMovement += (posFrom, posTo) =>
            {
                // Set provided positons to parameter as tuple
                var parameter = new Tuple <int, int>(posFrom, posTo);

                // Reorder the task list
                viewModel.ReorderCommand.Execute(parameter);
            };

            // Launch SessionNotificationService
            DI.Container.GetInstance <SessionNotificationService>();
        }
Ejemplo n.º 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            var mainView = LayoutInflater.Inflate(Resource.Layout.Main, null, true) as LinearLayout;

            SetContentView(mainView);
            mainView.SetBackgroundColor(Color.Red);
            var recyclerView    = new RecyclerView(this);
            var recyclerAdapter = new RecyclerAdapter();

            for (int i = 0; i < 30; i++)
            {
                recyclerAdapter.Items.Add($"Entry {i}.");
            }
            recyclerView.SetAdapter(recyclerAdapter);
            var linearLayoutManager = new LinearLayoutManager(this);
            var swipeController     = new LeftRightSwipeController();
            var ith = new ItemTouchHelper(swipeController);

            ith.AttachToRecyclerView(recyclerView);
            recyclerView.SetLayoutManager(linearLayoutManager);
            recyclerView.SetBackgroundColor(Color.Orange);
            mainView.AddView(recyclerView);
        }
Ejemplo n.º 9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.ListView);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            toolbar.InflateMenu(Resource.Menu.new_counter_menu);
            SetSupportActionBar(toolbar);

            _imageView = FindViewById <ImageView>(Resource.Id.imageView);

            recyclerView = FindViewById <MvxRecyclerView>(Resource.Id.recycler_view);
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));

            var callback    = new SwipeItemTouchHelperCallback(ViewModel);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(recyclerView);


            if (ViewModel.MeasuredObjects.Count > 0)
            {
                Android.Net.Uri uri = Android.Net.Uri.Parse(ViewModel.MeasuredObjects[0].ImageUri);
                Picasso.With(Application.Context).Load(uri).Into(_imageView);
            }

            // Set our view from the "main" layout resource
        }
Ejemplo n.º 10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            _toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            if (_toolbar != null)
            {
                SetSupportActionBar(_toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);
                _toolbar.NavigationClick += delegate
                {
                    OnBackPressed();
                };
            }

            _adapter = new ContactsListAdapter(this);
            _adapter.ItemClick += OnItemClick;

            var contactsListView = FindViewById<RecyclerView>(Resource.Id.contactsListView);
            contactsListView.SetAdapter(_adapter);
            contactsListView.SetLayoutManager(new LinearLayoutManager(contactsListView.Context));

            ItemTouchHelper.Callback callback = new ContactsListCallBacks(_adapter, this);
            ItemTouchHelper itemTouchHelper = new ItemTouchHelper(callback);
            itemTouchHelper.AttachToRecyclerView(contactsListView);
            contactsListView.SetItemAnimator(new DefaultItemAnimator());
        }
Ejemplo n.º 11
0
        protected override void OnCreate(Bundle SavedInstanceState)
        {
            base.OnCreate(SavedInstanceState);
            SetContentView(Resource.Layout.card_priority);

            var preferences  = PreferenceManager.GetDefaultSharedPreferences(this);
            var key          = GetString(Resource.String.pref_card_priority);
            var cardPriority = preferences.GetString(key, FgoPreferences.DefaultCardPriority);

            // Handle simple mode and empty string
            if (cardPriority.Length == 3 || string.IsNullOrWhiteSpace(cardPriority))
            {
                cardPriority = FgoPreferences.DefaultCardPriority;
            }

            _cardScores = Card.GetCardScores(cardPriority).ToList();

            var adapter = new RecyclerListAdapter(_cardScores, this);

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.card_priority_lv);

            recyclerView.HasFixedSize = true;
            recyclerView.SetAdapter(adapter);
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));

            var callback = new ItemTouchHelperCallback(adapter);

            _itemTouchHelper = new ItemTouchHelper(callback);
            _itemTouchHelper.AttachToRecyclerView(recyclerView);
        }
Ejemplo n.º 12
0
        private void setupItemTouchHelper(MainRecyclerAdapter mainAdapter)
        {
            var callback        = new MainRecyclerViewTouchCallback(mainAdapter);
            var itemTouchHelper = new ItemTouchHelper(callback);

            itemTouchHelper.AttachToRecyclerView(mainRecyclerView);
        }
Ejemplo n.º 13
0
        public virtual void UpdateCanReorderItems()
        {
            var canReorderItems = (ItemsView as ReorderableItemsView)?.CanReorderItems == true;

            if (canReorderItems)
            {
                if (_itemTouchHelperCallback == null)
                {
                    _itemTouchHelperCallback = new SimpleItemTouchHelperCallback();
                }
                if (_itemTouchHelper == null)
                {
                    _itemTouchHelper = new ItemTouchHelper(_itemTouchHelperCallback);
                    _itemTouchHelper.AttachToRecyclerView(this);
                }
                _itemTouchHelperCallback.SetAdapter(ItemsViewAdapter as IItemTouchHelperAdapter);
            }
            else
            {
                if (_itemTouchHelper != null)
                {
                    _itemTouchHelper.AttachToRecyclerView(null);
                    _itemTouchHelper.Dispose();
                    _itemTouchHelper = null;
                }
                if (_itemTouchHelperCallback != null)
                {
                    _itemTouchHelperCallback.Dispose();
                    _itemTouchHelperCallback = null;
                }
            }
        }
Ejemplo n.º 14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.MainView);

            //save user
            _filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "ToDoUser.txt");
            File.WriteAllText(_filePath, $"{SignViewModel.UserCurrent.UserLogin}`" +
                              $"{SignViewModel.UserCurrent.UserPassword}");

            _recyclerView    = FindViewById <MvxRecyclerView>(Resource.Id.taskList);
            _itemTouchHelper = new ItemTouchHelper(new Swipe2DismissTouchHelperCallback(this));
            _itemTouchHelper.AttachToRecyclerView(_recyclerView);

            _drawerLayout = FindViewById <DrawerLayout>(Resource.Id._drawerMain);

            _navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            _navigationView.NavigationItemSelected += NavigationViewClick;

            //navigationHeader
            var headerView = _navigationView.GetHeaderView(0);

            headerView.Click += AddPhoto;

            _swipeContainer = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeContainer1);
            _swipeContainer.SetColorSchemeResources(Android.Resource.Color.HoloBlueLight, Android.Resource.Color.HoloGreenLight, Android.Resource.Color.HoloOrangeLight, Android.Resource.Color.HoloRedLight);
            _swipeContainer.Refresh += SwipeContainer_Refresh;
        }
Ejemplo n.º 15
0
Archivo: Queue.cs Proyecto: pictos/Opus
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        View view = inflater.Inflate(Resource.Layout.LonelyRecycler, container, false);

        instance = this;
        ListView = view.FindViewById <RecyclerView>(Resource.Id.recycler);
        ListView.SetLayoutManager(new LinearLayoutManager(Application.Context));
        adapter = new QueueAdapter();
        ListView.SetAdapter(adapter);
        adapter.ItemClick     += ListView_ItemClick;
        adapter.ItemLongCLick += ListView_ItemLongCLick;
        ListView.SetItemAnimator(new DefaultItemAnimator());
        ListView.AddItemDecoration(new CurrentItemDecoration(adapter));
        ListView.AddOnItemTouchListener(this);
        ListView.ScrollChange += Scroll;

        ItemTouchHelper.Callback callback = new ItemTouchCallback(adapter, true);
        itemTouchHelper = new ItemTouchHelper(callback);
        itemTouchHelper.AttachToRecyclerView(ListView);

        ListView.ScrollToPosition(MusicPlayer.CurrentID());

        if (MusicPlayer.UseCastPlayer)
        {
            Snackbar snackBar = Snackbar.Make(ListView, "Queue management with chromecast is currently in beta, expect some bugs.", (int)ToastLength.Short);
            snackBar.View.FindViewById <TextView>(Resource.Id.snackbar_text).SetTextColor(Color.White);
            snackBar.Show();
        }
        return(view);
    }
Ejemplo n.º 16
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            if (_toolbar != null)
            {
                SetSupportActionBar(_toolbar);
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                SupportActionBar.SetHomeButtonEnabled(true);
                _toolbar.NavigationClick += delegate
                {
                    OnBackPressed();
                };
            }

            _adapter            = new ContactsListAdapter(this);
            _adapter.ItemClick += OnItemClick;

            var contactsListView = FindViewById <RecyclerView>(Resource.Id.contactsListView);

            contactsListView.SetAdapter(_adapter);
            contactsListView.SetLayoutManager(new LinearLayoutManager(contactsListView.Context));

            ItemTouchHelper.Callback callback        = new ContactsListCallBacks(_adapter, this);
            ItemTouchHelper          itemTouchHelper = new ItemTouchHelper(callback);

            itemTouchHelper.AttachToRecyclerView(contactsListView);
            contactsListView.SetItemAnimator(new DefaultItemAnimator());
        }
Ejemplo n.º 17
0
 private void AttachSwipe()
 {
     using (ItemTouchHelper itemTouchHelper = new ItemTouchHelper(this))
     {
         itemTouchHelper.AttachToRecyclerView(_recyclerView);
     }
 }
Ejemplo n.º 18
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.favorites_fragment, container, false);

            string key     = Activity.ApplicationContext.GetString(Resource.String.fav_query_storage_key);
            var    storage = new FavoritesStorage <FavoriteQuery>(Activity.ApplicationContext, key);

            favQueries = storage.GetItems();

            adapter              = new CustomAdapter(Activity.ApplicationContext);
            adapter.ItemClicked += (s, item) =>
            {
                var query = favQueries.Single(x => x.Id == item.Id);
                ItemClicked?.Invoke(this, query.Query);
            };
            adapter.ItemRemoved += (s, item) =>
            {
                if (adapter.ItemCount == 0)
                {
                    recyclerView.Visibility  = ViewStates.Gone;
                    emptyTextView.Visibility = ViewStates.Visible;
                }
                storage.RemoveItem(favQueries.Single(x => x.Id == item.Id));
            };

            foreach (var query in favQueries)
            {
                adapter.Items.Add(new CustomItem()
                {
                    Id = query.Id, Name = query.Name, Description = query.Query
                });
            }

            emptyTextView = view.FindViewById <TextView>(Resource.Id.fav_list_empty);
            recyclerView  = view.FindViewById <RecyclerView>(Resource.Id.recycler_view);
            recyclerView.SetLayoutManager(new LinearLayoutManager(Activity.ApplicationContext));
            recyclerView.SetAdapter(adapter);
            recyclerView.AddItemDecoration(new ItemDecoration(Activity.ApplicationContext));
            recyclerView.HasFixedSize = true;

            // swipe to remove
            var mItemTouchHelper = new ItemTouchHelper(
                new ItemTouchCallback(0, ItemTouchHelper.Left, Activity.ApplicationContext, adapter));

            mItemTouchHelper.AttachToRecyclerView(recyclerView);

            if (adapter.ItemCount == 0)
            {
                recyclerView.Visibility  = ViewStates.Gone;
                emptyTextView.Visibility = ViewStates.Visible;
            }
            else
            {
                recyclerView.Visibility  = ViewStates.Visible;
                emptyTextView.Visibility = ViewStates.Gone;
            }

            return(view);
        }
Ejemplo n.º 19
0
        public static ItemTouchHelper AddDragAndDropSupport(this RecyclerView recyclerView, bool useLongPress = true)
        {
            var helper = new ItemTouchHelper(new DragItemTouchHelperCallback(useLongPress));

            helper.AttachToRecyclerView(recyclerView);

            return(helper);
        }
Ejemplo n.º 20
0
        private void InitAuthenticatorList()
        {
            var viewModePref = PreferenceManager.GetDefaultSharedPreferences(this)
                               .GetString("pref_viewMode", "default");

            var viewMode = viewModePref switch
            {
                "compact" => AuthenticatorListAdapter.ViewMode.Compact,
                "tile" => AuthenticatorListAdapter.ViewMode.Tile,
                _ => AuthenticatorListAdapter.ViewMode.Default
            };

            _authListAdapter = new AuthenticatorListAdapter(_authSource, _customIconSource, viewMode, IsDark)
            {
                HasStableIds = true
            };

            _authListAdapter.ItemClick       += OnAuthenticatorClick;
            _authListAdapter.MenuClick       += OnAuthenticatorOptionsClick;
            _authListAdapter.MovementStarted += delegate
            {
                _bottomAppBar.PerformHide();
            };

            _authListAdapter.MovementFinished += async delegate
            {
                RunOnUiThread(_bottomAppBar.PerformShow);
                await NotifyWearAppOfChange();
            };

            _authList.SetAdapter(_authListAdapter);

            var minColumnWidth = viewMode switch
            {
                AuthenticatorListAdapter.ViewMode.Compact => 300,
                AuthenticatorListAdapter.ViewMode.Tile => 170,
                _ => 340
            };

            var layout = new AutoGridLayoutManager(this, minColumnWidth);

            _authList.SetLayoutManager(layout);

            _authList.AddItemDecoration(new GridSpacingItemDecoration(this, layout, 8));
            _authList.HasFixedSize = true;

            var animation =
                AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fall_down);

            _authList.LayoutAnimation = animation;

            var callback    = new ReorderableListTouchHelperCallback(_authListAdapter, layout);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_authList);
        }
Ejemplo n.º 21
0
        public TaskListAdapter(RecyclerView view, Context context, List <UserTaskModel> taskList)
        {
            _context = context;
            TaskList = taskList;

            ItemTouchHelper.Callback callback        = new TaskListItemTouchHelper(this);
            ItemTouchHelper          itemTouchHelper = new ItemTouchHelper(callback);

            itemTouchHelper.AttachToRecyclerView(view);
        }
Ejemplo n.º 22
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.FirstView);

            var cardView        = FindViewById <MvxRecyclerView>(Resource.Id.recyclerView);
            var itemTouchHelper = new ItemTouchHelper(new Swipe2DismissTouchHelperCallback());

            itemTouchHelper.AttachToRecyclerView(cardView);
        }
Ejemplo n.º 23
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            _itemTouchHelper = new ItemTouchHelper(new SwipeController(0, ItemTouchHelper.Left));
            View view = inflater.Inflate(Resource.Layout.scriptviewer, container, false);

            _lst    = view.FindViewById <RecyclerView>(Resource.Id.scriptviewer);
            _runBar = view.FindViewById <RelativeLayout>(Resource.Id.runBar);
            _run    = view.FindViewById <Button>(Resource.Id.startseq);
            context = Context;

            //hide run bar
            _runBar.Animate().TranslationY(250);

            //SetRunBarVisibility(VisibilityFlags.Invisible);

            _adapter = new ScriptsAdapter(Context, ScriptList)
            {
                HasStableIds = true
            };
            _lst.SetAdapter(_adapter);

            //set the layout manager for list
            lstLayoutManager = new LinearLayoutManager(Context);
            _lst.SetLayoutManager(lstLayoutManager);

            _itemTouchHelper.AttachToRecyclerView(_lst);

            _lstMaxHeight = _lst.LayoutParameters.Height;
            _lstMinHeight = _lst.LayoutParameters.Height - _runBar.LayoutParameters.Height - _run.LayoutParameters.Height;
            //show running window after Run click
            _run.Click += delegate
            {
                if (!SelectedScripts.Any())
                {
                    Toast.MakeText(Context, "Please, choose script", ToastLength.Short).Show();
                }
                else
                {
                    ScriptCompletedCounter = 0;
                    RunScriptConnection.StartConnectionAsync(MainActivity.Ip);

                    //replace Scripts with Running
                    Fragment running = new Running();
                    FragmentManager.BeginTransaction()
                    .Replace(Resource.Id.container, running)
                    .AddToBackStack(null)
                    .Commit();

                    //hide TabLayout when running window is showed
                    MainActivity.SetTabBarVisibility(VisibilityFlags.Invisible);
                }
            };
            return(view);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.mainlist_layout);

            _sortByAll      = FindViewById <TextView>(Resource.Id.sort_all);
            _sortByApproved = FindViewById <TextView>(Resource.Id.sort_approved);
            _sortByClosed   = FindViewById <TextView>(Resource.Id.sort_closed);

            _fabButton = FindViewById <FloatingActionButton>(Resource.Id.fab);

            _recyclerView  = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _layoutManager = new LinearLayoutManager(this);
            _recyclerView.SetLayoutManager(_layoutManager);
            _adapter = new VacationsAdapter(_recyclerView);
            _recyclerView.SetAdapter(_adapter);

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(false);
            SupportActionBar.SetHomeButtonEnabled(true);

            _drawerLayout   = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            _navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            var swipeHandler    = new SwipeToDeleteCallback(0, ItemTouchHelper.Left, this, _adapter);
            var itemTouchHelper = new ItemTouchHelper(swipeHandler);

            itemTouchHelper.AttachToRecyclerView(_recyclerView);

            _drawerToggle = new MyActionBarDrawerToggle(
                this,
                _drawerLayout,
                Resource.String.openDrawer,
                Resource.String.closeDrawer
                );
            _drawerLayout.SetDrawerListener(_drawerToggle);
            _drawerToggle.SyncState();

            _sortByApproved.Click += (s, e) =>
            {
                _drawerLayout.CloseDrawers();
            };
            _sortByClosed.Click += (s, e) =>
            {
                _drawerLayout.CloseDrawers();
            };
            _sortByAll.Click += (s, e) =>
            {
                _drawerLayout.CloseDrawers();
            };
        }
Ejemplo n.º 25
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activityManageCategories);

            _preferences = new PreferenceWrapper(this);

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

            SetSupportActionBar(toolbar);

            SupportActionBar.SetTitle(Resource.String.categories);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_action_arrow_back);

            _rootLayout = FindViewById <RelativeLayout>(Resource.Id.layoutRoot);

            _addButton        = FindViewById <FloatingActionButton>(Resource.Id.buttonAdd);
            _addButton.Click += OnAddClick;

            var connection = await Database.GetSharedConnection();

            _categorySource                   = new CategorySource(connection);
            _categoryListAdapter              = new ManageCategoriesListAdapter(_categorySource);
            _categoryListAdapter.MenuClick   += OnMenuClick;
            _categoryListAdapter.HasStableIds = true;
            _categoryListAdapter.DefaultId    = _preferences.DefaultCategory;

            _categoryList     = FindViewById <RecyclerView>(Resource.Id.list);
            _emptyStateLayout = FindViewById <LinearLayout>(Resource.Id.layoutEmptyState);

            _categoryList.SetAdapter(_categoryListAdapter);
            _categoryList.HasFixedSize = true;

            var layout = new FixedGridLayoutManager(this, 1);

            _categoryList.SetLayoutManager(layout);

            var callback    = new ReorderableListTouchHelperCallback(this, _categoryListAdapter, layout);
            var touchHelper = new ItemTouchHelper(callback);

            touchHelper.AttachToRecyclerView(_categoryList);

            var decoration = new DividerItemDecoration(this, layout.Orientation);

            _categoryList.AddItemDecoration(decoration);

            var layoutAnimation = AnimationUtils.LoadLayoutAnimation(this, Resource.Animation.layout_animation_fade_in);

            _categoryList.LayoutAnimation = layoutAnimation;

            await Refresh();
        }
Ejemplo n.º 26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Main);

            ContactsRecyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_contacts);

            var uri = ContactsContract.Contacts.ContentUri;

            string[] projection =
            {
                ContactsContract.Contacts.InterfaceConsts.Id,
                ContactsContract.Contacts.InterfaceConsts.DisplayName
            };

            var cursor = ContentResolver.Query(uri, projection, null, null, null);

            var contactList = new List <string>();

            if (cursor.MoveToFirst())
            {
                do
                {
                    contactList.Add(cursor.GetString(cursor.GetColumnIndex(projection[1])));
                }while (cursor.MoveToNext());
            }

            // TODO:
            contactList.Add("John Doe");
            contactList.Add("Mark Doe");
            contactList.Add("Jane Doe");

            _contactListAdapter = new ContactsAdapter(
                contactList.Select(c => new Contact {
                Name = c
            }).ToList());
            ContactsRecyclerView.SetAdapter(_contactListAdapter);
            ContactsRecyclerView.SetLayoutManager(
                new LinearLayoutManager(this, LinearLayoutManager.Vertical, false));

            _swipeCallback = new SimpleSwipeHelperCallback();
            var swipeHelper = new ItemTouchHelper(_swipeCallback);

            swipeHelper.AttachToRecyclerView(ContactsRecyclerView);

            _swipeCallback.Swiped += OnContactSwiped;

            var intent       = new Intent(this, typeof(SmsReceiver));
            var pending      = PendingIntent.GetBroadcast(this, 0, intent, PendingIntentFlags.UpdateCurrent);
            var alarmManager = GetSystemService(AlarmService).JavaCast <AlarmManager>();

            alarmManager.Set(AlarmType.ElapsedRealtimeWakeup, SystemClock.ElapsedRealtime() + 5 * 1000, pending);
        }
Ejemplo n.º 27
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.packages_list);
            var recyclerView        = FindViewById <MvxRecyclerView>(Resource.Id.packagesRecyclerView);
            var itemTouchHelper     = new ItemTouchHelper(new SwipeToDeleteTouchHelperCallback());
            var editItemTouchHelper = new ItemTouchHelper(new SwipeToEditTouchHelperCallback());

            itemTouchHelper.AttachToRecyclerView(recyclerView);
            editItemTouchHelper.AttachToRecyclerView(recyclerView);
        }
Ejemplo n.º 28
0
        private void FnSetUpList()
        {
            FnGetListData("");
            mResourceAdapter = new ProductsItemSizesReorderableAdapter(mProductSizesList, this, this);
            rvSizes.SetLayoutManager(new LinearLayoutManager(Context, LinearLayoutManager.Vertical, false));
            rvSizes.SetAdapter(mResourceAdapter);
            rvSizes.HasFixedSize = true;

            ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(mResourceAdapter);
            _mItemTouchHelper = new ItemTouchHelper(callback);
            _mItemTouchHelper.AttachToRecyclerView(rvSizes);
        }
        /// <summary>
        /// Ons the element changed.
        /// </summary>
        /// <param name="e">E.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <SettingsView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                // Fix scrollbar visibility and flash. https://github.com/xamarin/Xamarin.Forms/pull/10893
                var recyclerView = new RecyclerView(new ContextThemeWrapper(Context, Resource.Style.settingsViewTheme), null, Resource.Attribute.settingsViewStyle);
                recyclerView.NestedScrollingEnabled = false;

                // When replaced, No animation.
                //(recyclerView.GetItemAnimator() as DefaultItemAnimator).SupportsChangeAnimations = false;

                _layoutManager = new SettingsViewLayoutManager(Context, e.NewElement);
                recyclerView.SetLayoutManager(_layoutManager);

                _divider        = Context.GetDrawable(Resource.Drawable.divider);
                _itemDecoration = new SVItemdecoration(_divider, e.NewElement);
                recyclerView.AddItemDecoration(_itemDecoration);

                SetNativeControl(recyclerView);

                Control.Focusable = false;
                Control.DescendantFocusability = DescendantFocusability.AfterDescendants;

                UpdateSeparatorColor();
                UpdateBackgroundColor();
                UpdateRowHeight();

                _adapter = new SettingsViewRecyclerAdapter(Context, e.NewElement, recyclerView);
                Control.SetAdapter(_adapter);

                _simpleCallback  = new SettingsViewSimpleCallback(e.NewElement, ItemTouchHelper.Up | ItemTouchHelper.Down, 0);
                _itemTouchhelper = new ItemTouchHelper(_simpleCallback);
                _itemTouchhelper.AttachToRecyclerView(Control);

                Element elm = Element;
                while (elm != null)
                {
                    elm = elm.Parent;
                    if (elm is Page)
                    {
                        break;
                    }
                }

                _parentPage            = elm as Page;
                _parentPage.Appearing += ParentPageAppearing;

                e.NewElement.Root.CollectionChanged += RootCollectionChanged;
            }
        }
Ejemplo n.º 30
0
        private void InitializeRecyclerView()
        {
            _chatsRecyclerView.HasFixedSize = true;
            _chatsRecyclerView.SetLayoutManager(new GuardedLinearLayoutManager(Activity));
            _chatsRecyclerView.AddItemDecoration(new LeftOffsetItemDecoration(Activity, Resource.Color.chat_divider_color, 72));
            _chatsRecyclerView.SetAdapter(new ChatObservableRecyclerViewAdapter(ViewModel.Chats,
                                                                                CreateChatViewHolder, _chatsRecyclerView.SmoothScrollToPosition));

            var swipeItemCallback    = new SwipeCallback(Activity, _chatsRecyclerView, ConfigureSwipeForViewHolder);
            var swipeItemTouchHelper = new ItemTouchHelper(swipeItemCallback);

            swipeItemTouchHelper.AttachToRecyclerView(_chatsRecyclerView);
        }
Ejemplo n.º 31
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.activity_drinks);

            //Set our toolbar
            var toolbar = FindViewById <Toolbar>(Resource.Id.app_bar);

            SetActionBar(toolbar);
            ActionBar.SetHomeButtonEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.Title = "Your Drinks";

            drinks = new ObservableCollection <Beverage>();
            drinks.Add(new Beverage("Lightbeer", 100, "bottle"));
            drinks.Add(new Beverage("Whiskey", 100, "whiskey"));
            drinks.Add(new Beverage("Vodka", 35, "vodka"));

            DrinksAdapter drinksAdapter = new DrinksAdapter(this, drinks);

            RecyclerView drinksRecyclerView = FindViewById <RecyclerView>(Resource.Id.drinks_recycler_view);

            drinksRecyclerView.SetLayoutManager(new LinearLayoutManager(this));
            drinksRecyclerView.SetAdapter(drinksAdapter);

            ItemTouchHelper.Callback callback = new ItemTouchHelperCallback(drinksAdapter);
            itemTouchHelper = new ItemTouchHelper(callback);
            itemTouchHelper.AttachToRecyclerView(drinksRecyclerView);

            //mAdapter.ItemClick += OnItemClick;

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.add_drink_fab);

            fab.AttachToRecyclerView(drinksRecyclerView);
            fab.Click += (sender, args) =>
            {
                Intent intent = new Intent(this, typeof(EditDrinkActivity));
                //StartActivityForResult(intent, ADD_DRINK);
                StartActivity(intent);
            };

            /*
             * void OnItemClick(object sender, int position)
             * {
             *  int itemNum = position + 1;
             *  Toast.MakeText(this, "This is item " + itemNum, ToastLength.Short).Show();
             * }
             */
        }
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

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

            RecyclerListAdapter adapter = new RecyclerListAdapter(this);

            RecyclerView recyclerView = FindViewById<RecyclerView>(Resource.Id.recycler_view);
            recyclerView.HasFixedSize = true;
            recyclerView.SetAdapter(adapter);
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));

            ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(adapter);
            mItemTouchHelper = new ItemTouchHelper(callback);
            mItemTouchHelper.AttachToRecyclerView(recyclerView);
        }
Ejemplo n.º 33
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Favorites);

            // toolbar setup
            var toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            favoritesListView = FindViewById<RecyclerView>(Resource.Id.FavoritesList);

            // use this setting to improve performance if you know that changes
            // in content do not change the layout size of the RecyclerView
            favoritesListView.HasFixedSize = true;
            // use a linear layout manager
            var layoutManager = new LinearLayoutManager(this);
            layoutManager.Orientation = (int)Orientation.Vertical;
            favoritesListView.SetLayoutManager(layoutManager);



            _favoritesService = SimpleIoc.Default.GetInstance<IFavoritesService>();
            _favorites = await _favoritesService.GetFavoritesAsync();

       
            // specify an adapter (see also next example)
            mAdapter = new FavoriteListAdapter(this, _favorites, this);
            favoritesListView.SetAdapter(mAdapter);
            favoritesListView.ChildViewRemoved += FavoritesListView_ChildViewRemoved;
            var callback = new SimpleItemTouchHelperCallback((IItemTouchHelperAdapter)mAdapter);
            _itemTouchHelper = new ItemTouchHelper(callback);
            _itemTouchHelper.AttachToRecyclerView(favoritesListView);

            _placeHolder = FindViewById<TextView>(Resource.Id.placeHolder);
            _placeHolderAnimation = AnimationUtils.LoadAnimation(this, Resource.Animation.placeholder);
            if (_favorites.Count == 0)
            {
                await Task.Delay(200);
                _placeHolder.StartAnimation(_placeHolderAnimation);
                _placeHolder.Visibility = ViewStates.Visible;
            }
        }
        private void SetupRecyclerView ()
        {
            // Touch listeners.
            itemTouchListener = new ItemTouchListener (recyclerView, this);
            recyclerView.AddOnItemTouchListener (itemTouchListener);

            var touchCallback = new SwipeDismissCallback (ItemTouchHelper.Up | ItemTouchHelper.Down, ItemTouchHelper.Left, this);
            var touchHelper = new ItemTouchHelper (touchCallback);
            touchHelper.AttachToRecyclerView (recyclerView);

            // Decorations.
            dividerDecoration = new DividerItemDecoration (Activity, DividerItemDecoration.VerticalList);
            shadowDecoration = new ShadowItemDecoration (Activity);
            recyclerView.AddItemDecoration (dividerDecoration);
            recyclerView.AddItemDecoration (shadowDecoration);

            recyclerView.GetItemAnimator ().SupportsChangeAnimations = false;
        }
Ejemplo n.º 35
0
        private void SetupRecyclerView (LogTimeEntriesViewModel viewModel)
        {
            // Touch listeners.
            itemTouchListener = new ItemTouchListener (recyclerView, this);
            recyclerView.AddOnItemTouchListener (itemTouchListener);

            // Scroll listener
            recyclerView.AddOnScrollListener (
                new ScrollListener ((LinearLayoutManager)recyclerView.GetLayoutManager (), viewModel));

            var touchCallback = new SwipeDismissCallback (ItemTouchHelper.Up | ItemTouchHelper.Down, ItemTouchHelper.Left, this);
            var touchHelper = new ItemTouchHelper (touchCallback);
            touchHelper.AttachToRecyclerView (recyclerView);

            // Decorations.
            dividerDecoration = new DividerItemDecoration (Activity, DividerItemDecoration.VerticalList);
            shadowDecoration = new ShadowItemDecoration (Activity);
            recyclerView.AddItemDecoration (dividerDecoration);
            recyclerView.AddItemDecoration (shadowDecoration);
            recyclerView.GetItemAnimator ().SupportsChangeAnimations = false;
        }