Beispiel #1
0
        private async Task GetRoomData(View view)
        {
            //// Init toolbar
            //var toolbar = FindViewById<Toolbar>(Resource.Id.app_bar);
            //SetSupportActionBar(toolbar);
            //SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            //SupportActionBar.SetDisplayShowHomeEnabled(true);

            //Lấy obj house đã lưu trước đó
            House objHouse_Result = AppInstance.houseData;

            //Nếu house trước đó == NULL, thì gọi lại API GetHouse
            if (objHouse_Result == null)
            {
                List <House> lstHouse = await APIManager.GetHouseByHouseId(houseId);

                objHouse_Result = lstHouse[0];
                lstRoom         = objHouse_Result.rooms;
            }
            else
            {
                lstRoom = objHouse_Result.rooms;
            }

            if (objHouse_Result != null)
            {
                houseId = objHouse_Result.houseId;

                //view.Title = objHouse_Result.name ?? "houseName not available";

                var grdHouse = view.FindViewById <GridView>(Resource.Id.grdHouse);
                grdHouse.Adapter    = new RoomAdapter(Activity, lstRoom);
                grdHouse.ItemClick += GrdHouse_ItemClick;
            }
        }
        private async Task GetHouseData(View view)
        {
            User user = AppInstance.user;

            if (user.houses != null && user.houses.Count > 0)
            {
                List <House> lstHouse = await APIManager.GetHouseByHouseId(user.houses[0].houseId);

                //House objHouse = await APIManager.GetHouseByHouseId(lstHouse[0].houseId);
                //lstHouse.Clear();
                //lstHouse.Add(objHouse);

                var grdHouse = view.FindViewById <GridView>(Resource.Id.grdHouse);
                grdHouse.Adapter    = new HouseAdapter(Activity, lstHouse);
                grdHouse.ItemClick += GrdHouse_ItemClick;
            }
        }
Beispiel #3
0
        //private async Task GetRoomData(string houseId)
        //{
        //    House objHouse = await APIManager.GetHouseByHouseId(houseId);

        //    if (objHouse != null)
        //    {
        //        lstRoom = objHouse.rooms;
        //        var grdHouse = FindViewById<GridView>(Resource.Id.grdHouse);
        //        grdHouse.Adapter = new RoomAdapter(this, lstRoom);
        //        grdHouse.ItemClick += GrdHouse_ItemClick;
        //    }
        //}

        #endregion

        #region Event

        protected override async void OnResume()
        {
            base.OnResume();

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

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

            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);

            //Lấy obj house đã lưu trước đó
            House objHouse_Result = AppInstance.houseData;

            //Nếu house trước đó ==NULL, thì gọi lại API GetHouse
            if (objHouse_Result == null)
            {
                houseId = Intent.GetStringExtra("houseId") ?? "houseId not available";

                objHouse_Result = await APIManager.GetHouseByHouseId(houseId);
            }
            else
            {
                lstRoom = objHouse_Result.rooms;
            }

            if (objHouse_Result != null)
            {
                houseId = objHouse_Result.houseId;
                Title   = objHouse_Result.name ?? "houseName not available";

                var grdHouse = FindViewById <GridView>(Resource.Id.grdHouse);
                grdHouse.Adapter    = new RoomAdapter(this, lstRoom);
                grdHouse.ItemClick += GrdHouse_ItemClick;
            }
        }