示例#1
0
        private async void LoginSbmit_Click(object sender, EventArgs e)
        {
            EditText usernameTxt = FindViewById <EditText>(Resource.Id.usernameTxt);
            EditText passwordTxt = FindViewById <EditText>(Resource.Id.passwordTxt);

            var userlogin = new LoginModel
            {
                Username = usernameTxt.Text,
                Password = passwordTxt.Text
            };

            //var result = ApiCallService.CreateRequest(userlogin, Constants.ApiUrl + "user/login");
            //Task<HttpWebResponse> result = ApiCallService.CreateRequestAsync(userlogin, Constants.ApiUrl + "getuserid");
            var result = ApiCallService.CreateRequestAsync(userlogin, Constants.ApiUrl + "login/getuserid");
            var r      = await result;

            // Will block until the task is completed...
            //HttpWebResponse result = response.GetAwaiter().GetResult();
            //HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse;
            //var r = await result;

            using (var reader = new StreamReader(r.GetResponseStream()))
            {
                //Stream responseStream = response.GetResponseStream();
                //string responseStr = reader.ReadToEnd();
                //Console.WriteLine(responseStr);
                ////return XmlUtils.Deserialize<TResponse>(reader);

                string responseStr = reader.ReadToEnd();
                var    user        = JsonConvert.DeserializeObject <UserModel>(responseStr);
                //var user = JsonConvert.DeserializeObject<LoginViewModel>(responseStr);

                Context        mContext = Application.Context;
                AppPreferences ap       = new AppPreferences(mContext);

                //string key = "123123";
                ap.saveUserIdKey(user.UserId.ToString());
                //ap.saveUserIdKey(user.id.ToString());

                StartActivity(typeof(MainActivity));
            }

            //Context mContext = Application.Context;
            //AppPreferences ap = new AppPreferences(mContext);
            //ap.saveUserIdKey((5).ToString());

            //StartActivity(typeof(MainActivity));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Reservation);
            // Create your application here

            _mContext = Android.App.Application.Context;
            _ap       = new AppPreferences(_mContext);
            _userId   = _ap.getUserIdKey();

            ReservationService reservationService = new ReservationService();

            _reservationListView            = FindViewById <ListView>(Resource.Id.reservationLv);
            _reservationListView.ChoiceMode = ChoiceMode.Single;
            _reservationListView.Adapter    = new ReservationAdapter(this, reservationService.GetReservations());

            RegisterForContextMenu(_reservationListView);
            _reservationListView.ItemClick += _reservationListView_ItemClick;
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            _mContext = Android.App.Application.Context;
            _ap       = new AppPreferences(_mContext);
            _userId   = _ap.getUserIdKey();

            if (string.IsNullOrEmpty(_userId))
            {
                Console.WriteLine("please login");
                StartActivity(typeof(LoginActivity));
            }



            Button launchBtn = FindViewById <Button>(Resource.Id.launchButton);

            launchBtn.Click += delegate
            {
                LaunchNotification("sample notif", "something happened");
            };

            Button reservationBtn = FindViewById <Button>(Resource.Id.reservationBtn);

            reservationBtn.Click += ReservationBtn_Click;

            Button mapBtn = FindViewById <Button>(Resource.Id.mapBtn);

            mapBtn.Click += MapBtn_Click;

            Button logoutBtn = FindViewById <Button>(Resource.Id.logoutBtn);

            logoutBtn.Click += LogoutBtn_Click;

            //Timer
        }
示例#4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Map);
            // Create your application here



            //layMapAction = FindViewById<LinearLayout>(Resource.Id.layMapAction);
            //layDescription = FindViewById<LinearLayout>(Resource.Id.layDescription);

            _mContext = Android.App.Application.Context;
            _ap       = new AppPreferences(_mContext);
            _userId   = Convert.ToInt32(_ap.getUserIdKey());

            InitializeLocationManager();
            //if (_currentLocation == null)
            //{
            //    Toast.MakeText(this.ApplicationContext, "Can't determine the current address. Try again in a few minutes.", ToastLength.Short).Show();
            //}
            SetUpMap();
        }