Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EscapeRoute);

            // Create your application here

            goLeft  = FindViewById <Button>(Resource.Id.goLeftButton);
            goRight = FindViewById <Button>(Resource.Id.goRightButton);

            nextStep     = FindViewById <ImageButton>(Resource.Id.nextStepButton);
            previousStep = FindViewById <ImageButton>(Resource.Id.previousStepButton);

            routeTextView = FindViewById <TextView>(Resource.Id.routeTextView);

            choosenRoom  = Intent.GetStringExtra("choosenRoom");
            choosenFloor = Intent.GetStringExtra("choosenFloor");
            room         = SQLiteDb.GetRooms(this).FirstOrDefault(r => r.Name == choosenRoom && r.Floor == choosenFloor);
            var alarmId = Intent.GetIntExtra("alarmId", 1);

            alarm = SQLiteDb.GetAlarms(this).GetAwaiter().GetResult().FirstOrDefault(a => a.Id == alarmId);
            var route = new EscapeRoutes();

            viewPager = FindViewById <ViewPager>(Resource.Id.escapeRoutesViewPager);

            if (room.Side != "left" && room.Side != "right")
            {
                escapeRoutesList = route.GetEscapeRoutes(room.Side);
                ShowRoute();
            }
            else
            {
                goLeft.Click  += GoLeft_Click;
                goRight.Click += GoRight_Click;
                AskForWay();
            }

            previousStep.Click += PreviousStep_Click;
            nextStep.Click     += NextStep_Click;

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.escapeRouteToolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title    = choosenRoom + " - Ewakuacja";
            SupportActionBar.Subtitle = alarm.Name + " - " + SQLiteDb.GetRooms(this).FirstOrDefault(r => r.Id == alarm.RoomId).Name;
        }
Пример #2
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AlarmsHistory);
            var width = Resources.DisplayMetrics.WidthPixels - (int)(20 * Resources.DisplayMetrics.Density);

            newAlarmsButton = FindViewById <Button>(Resource.Id.newAlarmsButton);
            newAlarmsButton.SetWidth(width / 2);
            newAlarmsButton.Click += NewAlarmsButton_Click;
            archivedAlarmsButton   = FindViewById <Button>(Resource.Id.archivedAlarmsButton);
            archivedAlarmsButton.SetWidth(width / 2);
            archivedAlarmsButton.Click += ArchivedAlarmsButton_Click;

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.alarmsToolbar);

            alarmsSearchView = FindViewById <EditText>(Resource.Id.alarmsSearchEditText);
            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Alarmy";
            //Toolbar tabsToolbar = FindViewById<Toolbar>(Resource.Id.tabsToolbar);
            rooms      = SQLiteDb.GetRooms(this).ToList();
            alarmsList = SQLiteDb.GetAlarms(this).GetAwaiter().GetResult().OrderByDescending(a => a.NotifyDate).ToList();

            alarmsSearchView.TextChanged += AlarmsSearchView_TextChanged;;

            alarmsListView            = FindViewById <ListView>(Resource.Id.alarmsListView);
            alarmsListView.ItemClick += AlarmsListView_ItemClick;

            await LoadList(false);

            var floatingButton = FindViewById <FloatingActionButton>(Resource.Id.alarmsHistoryFAB);

            floatingButton.Click += (o, e) =>
            {
                var intent = new Intent(this, typeof(ReportEmergencyActivity));
                StartActivity(intent);
                Finish();
            };
        }
Пример #3
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            width = Resources.DisplayMetrics.WidthPixels;
            var alarmId = Intent.GetIntExtra("alarmId", 1);

            alarm = SQLiteDb.GetAlarms(this).GetAwaiter().GetResult().FirstOrDefault(a => a.Id == alarmId);
            var room = SQLiteDb.GetRooms(this).FirstOrDefault(r => r.Id == alarm.Id);

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ChatLayout);
            messagesListView = FindViewById <ListView>(Resource.Id.messagesListView);
            var newMessageLinearLayout = FindViewById <LinearLayout>(Resource.Id.newMessageLinearLayout);

            if (alarm.Archived == true)
            {
                newMessageLinearLayout.Visibility = ViewStates.Gone;
            }

            loggedUser = SQLiteDb.GetUser();
            LoadMessages(alarmId);
            newMessageEditText = FindViewById <EditText>(Resource.Id.newMessageEditText);
            newMessageEditText.SetWidth(Convert.ToInt32(width * 0.85));
            newMessageEditText.TextChanged += NewMessageEditText_TextChanged;

            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            string title = alarm.Name;

            if (title.Length > 17)
            {
                title = alarm.Name.Substring(0, 17) + "...";
            }
            SupportActionBar.Title = title;
            // Create your application here

            if (loggedUser.Email != "failed")
            {
                var userName         = loggedUser.UserName;
                var hubConnection    = new HubConnection("https://pwszalarmwebapi.azurewebsites.net");
                var messagesHubProxy = hubConnection.CreateHubProxy("MessagesHub");

                messagesHubProxy.On <int, int, string, string, DateTime>("sendMessageToClients", (id, alarmId, userName, message, messageTime) =>
                {
                    if (messagesList.FirstOrDefault().UserName == "failed" && messagesList.FirstOrDefault().Message == "failed")
                    {
                        messagesList.Clear();
                    }
                    this.RunOnUiThread(() =>
                    {
                        var messageObj = new Messages
                        {
                            Id          = id,
                            AlarmId     = alarmId,
                            UserName    = userName,
                            Message     = message,
                            MessageTime = messageTime
                        };
                        messagesList.Add(messageObj);
                        DisplayMessages();
                    });
                });
                try
                {
                    await hubConnection.Start();
                }
                catch (Exception ex)
                {
                    SQLiteDb.ShowAlert(this, "Błąd", ex.Message);
                }

                //Sending message
                var sendImageButton = FindViewById <ImageButton>(Resource.Id.sendMessageImageButton);
                sendImageButton.Click += async(o, e) =>
                {
                    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    var message            = newMessageEditText.Text;
                    if (!string.IsNullOrEmpty(message))
                    {
                        await messagesHubProxy.Invoke("SendMessage", new object[] { alarmId, userName, message });
                    }
                    message = null;
                    newMessageEditText.Text = message;
                };
                newMessageEditText.EditorAction += (sender, e) =>
                {
                    if (e.ActionId == ImeAction.Done)
                    {
                        sendImageButton.PerformClick();
                    }
                    else
                    {
                        e.Handled = false;
                    }
                };
            }
        }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.MainPage);
            Instance = this;
            var width = Convert.ToInt32(Resources.DisplayMetrics.WidthPixels * 0.96);

            var alarms = await SQLiteDb.GetAlarms(this);

            Alarm alarm = new Alarm();

            if (alarms.Count() > 0)
            {
                alarm = alarms.Last();
            }
            if (alarm != null)
            {
                var floatingButton = FindViewById <FloatingActionButton>(Resource.Id.mainPageFloatingActionButton);
                this.RunOnUiThread(() =>
                {
                    if (DateTime.Now.Subtract(alarm.NotifyDate).TotalHours > 24)
                    {
                        floatingButton.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        floatingButton.Visibility = ViewStates.Visible;
                    }
                });

                floatingButton.Click += (o, e) =>
                {
                    var intent = new Intent(this, typeof(AlarmActivity));
                    intent.PutExtra("alarmId", alarm.Id);
                    StartActivity(intent);
                };
            }

            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            var notificationsAlways  = prefs.GetBoolean("settingsNotifications", true);

            if (notificationsAlways)
            {
                await UpdateLocationAsync(false);

                await WebApiDataController.SetSendNotificationsAsync(true);
            }
            else
            {
                await UpdateLocationAsync(true);
            }

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

            planButton.Click += (o, e) =>
            {
                var intent = new Intent(this, typeof(BuildingPlansActivity));
                StartActivity(intent);
            };
            Button reportButton = FindViewById <Button>(Resource.Id.reportButton);

            reportButton.Click += (o, e) =>
            {
                SQLiteDb.LoadRoomsToDB(this);
                var intent = new Intent(this, typeof(ReportEmergencyActivity));
                StartActivity(intent);
            };
            Button threatsButton = FindViewById <Button>(Resource.Id.threatsButton);

            threatsButton.Click += (o, e) =>
            {
                SQLiteDb.LoadAlarmsToDb(this).GetAwaiter();
                var intent = new Intent(this, typeof(AlarmsHistoryActivity));
                StartActivity(intent);
            };
            Button settingsButton = FindViewById <Button>(Resource.Id.settingsButton);

            settingsButton.Click += (o, e) =>
            {
                var intent = new Intent(this, typeof(SettingsActivity));
                StartActivity(intent);
                Finish();
            };
        }