// This override is called only once during the activity's lifecycle, when it is created.
		protected override async void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			// instantiate adapter
			var acquaintanceCollectionAdapter = new AcquaintanceCollectionAdapter();

			// load the items
			await acquaintanceCollectionAdapter.LoadAcquaintances();

			// instantiate the layout manager
			var layoutManager = new LinearLayoutManager(this);

			// set the content view
			SetContentView(Resource.Layout.Main);

			// setup the action bar
			SetSupportActionBar(FindViewById<Toolbar>(Resource.Id.toolbar));

			// ensure that the system bar color gets drawn
			Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

			// set the title of both the activity and the action bar
			Title = SupportActionBar.Title = "Acquaintances";

			// instantiate/inflate the RecyclerView
			var recyclerView = (RecyclerView)FindViewById(Resource.Id.acquaintanceRecyclerView);

			// set RecyclerView's layout manager 
			recyclerView.SetLayoutManager(layoutManager);

			// set RecyclerView's adapter
			recyclerView.SetAdapter(acquaintanceCollectionAdapter);
		}
Esempio n. 2
0
        // This override is called only once during the activity's lifecycle, when it is created.
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // instantiate adapter
            _Adapter = new AcquaintanceCollectionAdapter();

            // load the items
            await _Adapter.LoadAcquaintances();

            // instantiate the layout manager
            var layoutManager = new LinearLayoutManager(this);

            // set the content view
            SetContentView(Resource.Layout.AcquaintanceList);

            // setup the action bar
            SetSupportActionBar(FindViewById <Toolbar>(Resource.Id.toolbar));

            // ensure that the system bar color gets drawn
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);

            // set the title of both the activity and the action bar
            Title = SupportActionBar.Title = "Acquaintances";

            // instantiate/inflate the RecyclerView
            var recyclerView = (RecyclerView)FindViewById(Resource.Id.acquaintanceRecyclerView);

            // set RecyclerView's layout manager
            recyclerView.SetLayoutManager(layoutManager);

            // set RecyclerView's adapter
            recyclerView.SetAdapter(_Adapter);
        }
Esempio n. 3
0
        async Task LoadAcquaintances()
        {
            _SwipeRefreshLayout.Refreshing = true;

            try
            {
                // load the items
                await _Adapter.LoadAcquaintances();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"Error getting acquaintances: {ex.Message}");

                //set alert for executing the task
                var alert = new Android.App.AlertDialog.Builder(this);

                alert.SetTitle("Error getting acquaintances");

                alert.SetMessage("Ensure you have a network connection, and that a valid backend service URL is present in the app settings.");

                alert.SetNegativeButton("OK", (senderAlert, args) => {
                    // an empty delegate body, because we just want to close the dialog and not take any other action
                });

                //run the alert in UI thread to display in the screen
                RunOnUiThread(() => {
                    alert.Show();
                });
            }
            finally
            {
                _SwipeRefreshLayout.Refreshing = false;
            }
        }
Esempio n. 4
0
        async protected override void OnRestart()
        {
            base.OnRestart();

            await _Adapter.LoadAcquaintances();
        }