예제 #1
0
        private void BtnSubmitDistress_Click(object sender, EventArgs e)
        {
            _mContext = Android.App.Application.Context;
            _ap       = new AppPreferences(_mContext);
            string key = _ap.getUserIdKey();

            if (string.IsNullOrEmpty(key))
            {
                Toast.MakeText(this.ApplicationContext, "Please login", ToastLength.Short).Show();
                StartActivity(typeof(LoginActivity));
            }

            var model = new DisasterLocationModel
            {
                UserId      = new Guid(key),
                Lat         = Convert.ToDecimal(pos.Latitude),
                Lng         = Convert.ToDecimal(pos.Longitude),
                Description = txtDescription.Text,
                Status      = DisasterLocationStatusEnum.Unresponded,
                DatePosted  = DateTime.Now
            };

            var result = ApiCallService.CreateRequest(model, Constants.ApiUrl + "disasterlocation/adddisaster");

            using (var reader = new StreamReader(result.GetResponseStream()))
            {
                string responseStr = reader.ReadToEnd();
                //var user = JsonConvert.DeserializeObject<UserModel>(responseStr);

                Toast.MakeText(this.ApplicationContext, "Distress sent", ToastLength.Short).Show();
                StartActivity(typeof(DistressActivity));
            }
        }
예제 #2
0
        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);
            string key = _ap.getUserIdKey();

            _loginNavButton    = FindViewById <Button>(Resource.Id.loginNav);
            _registerNavButton = FindViewById <Button>(Resource.Id.registerNav);
            _newsNavButton     = FindViewById <Button>(Resource.Id.newsNav);
            _mapNavButton      = FindViewById <Button>(Resource.Id.mapNav);
            _logOutNavButton   = FindViewById <Button>(Resource.Id.logoutNav);
            _distressNavButton = FindViewById <Button>(Resource.Id.distressNav);

            if (string.IsNullOrEmpty(key))
            {
                _loginNavButton.Visibility    = ViewStates.Visible;
                _registerNavButton.Visibility = ViewStates.Visible;
                _newsNavButton.Visibility     = ViewStates.Gone;
                _mapNavButton.Visibility      = ViewStates.Gone;
                _distressNavButton.Visibility = ViewStates.Gone;
                _logOutNavButton.Visibility   = ViewStates.Gone;
            }
            else
            {
                _loginNavButton.Visibility    = ViewStates.Gone;
                _registerNavButton.Visibility = ViewStates.Gone;
                _newsNavButton.Visibility     = ViewStates.Visible;
                _mapNavButton.Visibility      = ViewStates.Visible;
                _distressNavButton.Visibility = ViewStates.Visible;
                _logOutNavButton.Visibility   = ViewStates.Visible;
            }


            _loginNavButton.Click    += LoginNavButton_Click;
            _registerNavButton.Click += RegisterNavButton_Click;
            _newsNavButton.Click     += NewsNavButton_Click;
            _mapNavButton.Click      += MapNavButton_Click;
            _distressNavButton.Click += _distressNavButton_Click;
            _logOutNavButton.Click   += LogOutNavButton_Click;
        }
예제 #3
0
        private void PostSubmit_Click(object sender, EventArgs e)
        {
            EditText titleTxt   = FindViewById <EditText>(Resource.Id.titleTxt);
            EditText messageTxt = FindViewById <EditText>(Resource.Id.messageTxt);

            Context        mContext = Android.App.Application.Context;
            AppPreferences ap       = new AppPreferences(mContext);
            string         key      = ap.getUserIdKey();
            Guid           userId   = Guid.Empty;

            try
            {
                userId = new Guid(key);
            }
            catch (Exception)
            {
                Toast.MakeText(this.ApplicationContext, "Please login", ToastLength.Short).Show();
            }

            var model = new NewsModel
            {
                UserId     = userId,
                Title      = titleTxt.Text,
                Message    = messageTxt.Text,
                DatePosted = DateTime.Now
            };

            var result = ApiCallService.CreateRequest(model, Constants.ApiUrl + "news/postnews");

            using (var reader = new StreamReader(result.GetResponseStream()))
            {
                string responseStr = reader.ReadToEnd();
                if (responseStr == String.Empty)
                {
                    Toast.MakeText(this.ApplicationContext, "Post failed!", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(this.ApplicationContext, "Post success!", ToastLength.Short).Show();
                    StartActivity(typeof(NewsActivity));
                }
            }
        }
예제 #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Distress);
            // Create your application here

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

            _disressListView            = FindViewById <ListView>(Resource.Id.disressListView);
            _disressListView.ChoiceMode = ChoiceMode.Single;
            _disressListView.Adapter    = new DistressAdapter(this, GetDistress());


            RegisterForContextMenu(_disressListView);
            _disressListView.ItemClick += DisressListView_ItemClick;

            _btnAllDistress = FindViewById <Button>(Resource.Id.btnAllDistress);
            _btnMyResponse  = FindViewById <Button>(Resource.Id.btnMyResponse);

            _btnAllDistress.Click += _btnAllDistress_Click;
            _btnMyResponse.Click  += _btnMyResponse_Click;
        }