示例#1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.RoomsList);

            rooms = SQLiteDb.GetRooms(this).ToList();

            expandableListView = FindViewById <ExpandableListView>(Resource.Id.roomsExpandableListView);

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

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Zgłoś zagrożenie";

            adapter = new RoomsListAdapter(this, rooms);
            expandableListView.SetAdapter(adapter);

            expandableListView.ChildClick += (o, e) =>
            {
                var    roomName  = adapter.GetChild(e.GroupPosition, e.ChildPosition).ToString();
                var    floorName = adapter.GetGroup(e.GroupPosition).ToString();
                var    intent    = new Intent(this, typeof(WriteReportDataActivity));
                Bundle extras    = new Bundle();
                extras.PutString("choosenFloor", floorName);
                extras.PutString("choosenRoom", roomName);
                intent.PutExtras(extras);
                StartActivity(intent);
                Finish();
            };
        }
示例#2
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;
        }
示例#3
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();
            };
        }
示例#4
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;
                    }
                };
            }
        }
示例#5
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView;

            if (view == null)
            {
                view = activity.LayoutInflater.Inflate(Resource.Layout.alarmsItem_layout, null);
            }

            var      alarm = alarms[position];
            var      rooms = SQLiteDb.GetRooms(activity);
            TextView text1 = view.FindViewById <TextView>(Resource.Id.alarmsItemTextView1);

            text1.Text = alarm.Name + " - " + rooms.FirstOrDefault(r => r.Id == alarm.RoomId).Name;


            TextView text2 = view.FindViewById <TextView>(Resource.Id.alarmsItemTextView2);

            text2.Text = alarm.NotifyDate.Date.ToShortDateString() + " - " + alarm.NotifyDate.TimeOfDay.ToString();
            Button button = view.FindViewById <Button>(Resource.Id.alarmsItemButton);

            button.SetBackgroundColor(Android.Graphics.Color.White);
            button.SetTextColor(Android.Graphics.Color.DarkRed);
            button.Click += (o, e) =>
            {
                var alarmsHistoryActivity = (AlarmsHistoryActivity)activity;
                alarmsHistoryActivity.ClickItemButton(alarm);
            };
            view.Click += (o, e) =>
            {
                var alarmsHistoryActivity = (AlarmsHistoryActivity)activity;
                alarmsHistoryActivity.ClickItem(alarm);
            };
            if (!loaded.Loaded) //powiększało czcionkę cały czas
            {
                loaded.Text1Size = text1.TextSize;
                loaded.Text2Size = text2.TextSize;
                loaded.Loaded    = true;
            }
            if (DateTime.Now.Subtract(alarm.NotifyDate).TotalHours < 24)
            {
                view.SetBackgroundColor(Android.Graphics.Color.DarkRed);
                text1.SetTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.White));
                text1.SetTextSize(Android.Util.ComplexUnitType.Px, (float)(loaded.Text1Size * 1.2));
                text2.SetTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.White));
                text2.SetTextSize(Android.Util.ComplexUnitType.Px, (float)(loaded.Text2Size * 1.2));
                button.Visibility = ViewStates.Visible;
            }
            else
            {
                view.SetBackgroundColor(Android.Graphics.Color.White);
                text1.SetTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Black));
                text1.SetTextSize(Android.Util.ComplexUnitType.Px, (float)(loaded.Text1Size));
                text2.SetTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Black));
                text2.SetTextSize(Android.Util.ComplexUnitType.Px, (float)(loaded.Text2Size));
                button.Visibility = ViewStates.Gone;
            }


            return(view);
        }