Ejemplo n.º 1
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            scrollView   = view.FindViewById <ScrollView>(Resource.Id.scrollView);
            recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);

            noContentTextView = view.FindViewById <TextView>(Resource.Id.noContent);

            fab = view.FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.AttachToRecyclerView(recyclerView);
            fab.Click += (s, e) => parentActivity.StartActivity(new Intent(Application.Context, typeof(UploadActivity)));

            swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            swipeRefreshLayout.SetColorSchemeColors(Color.IndianRed, Color.LimeGreen, Color.AliceBlue, Color.LightGoldenrodYellow);
            swipeRefreshLayout.Refresh += (s, e) => getPosts(0);

            ((ToolbarActivity)parentActivity).ToolBar.Click += (s, e) => scrollView.ScrollTo(0, 0);

            viewManager = new LinearLayoutManager(Context);
            var scrollListener = new EndlessScrollListener(viewManager);

            recyclerView.HasFixedSize           = true;
            recyclerView.NestedScrollingEnabled = false;
            recyclerView.SetLayoutManager(viewManager);
            recyclerView.AddOnScrollListener(scrollListener);

            getPosts(0);
            //scrollListener.OnEndReach += (e) => getPosts(e);
        }
Ejemplo n.º 2
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();
             * }
             */
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

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

            SetActionBar(mToolbar);
            ActionBar.Title = "Festivities";

            festivities = new ObservableCollection <Model.Festivity>();
            festivities.Add(new Model.Festivity(1, DateTime.Now, 0.1, 0.25, null));

            FestivityAdapter festivityAdapter = new FestivityAdapter(this, festivities);

            RecyclerView festivitiesRecyclerView = FindViewById <RecyclerView>(Resource.Id.festivities_recycler_view);

            festivitiesRecyclerView.SetLayoutManager(new LinearLayoutManager(this));
            festivitiesRecyclerView.SetAdapter(festivityAdapter);

            ItemTouchHelper.Callback callback = new ItemTouchHelperCallback(festivityAdapter);
            itemTouchHelper = new ItemTouchHelper(callback);
            itemTouchHelper.AttachToRecyclerView(festivitiesRecyclerView);

            //festivityAdapter.ItemClick += OnItemClick;

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

            fab.AttachToRecyclerView(festivitiesRecyclerView);
            fab.Click += (sender, args) =>
            {
                Intent intent = new Intent(this, typeof(FestivityActivity));
                StartActivity(intent);
            };
        }