コード例 #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            Log.Error("InResult", "Inainte de if");
            if (requestCode == 215)
            {
                if (Utils.CheckIfLocationIsEnabled())
                {
                    StartForegroundService(_loacationServiceIntent);
                    if (int.Parse(Utils.GetDefaults("UserType")) == 4 || int.Parse(Utils.GetDefaults("UserType")) == 3)
                    {
                        StartForegroundService(_smartBandServiceIntent);
                    }
                }
                else
                {
                    Toast.MakeText(Application.Context, "Locatie dezactivata", ToastLength.Long).Show();
                }
            }

            if (resultCode == Result.Ok)
            {
                if (requestCode == 466)
                {
                    var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
                    navigationView.SetNavigationItemSelectedListener(this);
                    View   headerView = navigationView.GetHeaderView(0);
                    var    profileIW  = headerView.FindViewById <CircleImageView>(Resource.Id.menu_profile_image);
                    string avt        = Utils.GetDefaults("Avatar");

                    Glide.With(this).Load(avt)
                    .Apply(RequestOptions.SignatureOf(new ObjectKey(ProfileActivity.ImageUpdated))).Into(profileIW);

                    var lbName = headerView.FindViewById <TextView>(Resource.Id.lbNume);
                    lbName.Text = Utils.GetDefaults("Name");
                }
            }
        }
コード例 #2
0
        private void LoadModelInView(string avatar, string name, string email, string gender, string birthdate, bool updated)
        {
            if (updated)
            {
                ImageUpdated = DateTime.Now.Millisecond.ToString();
            }

            Glide.With(this)
            .Load(avatar)
            .Apply(RequestOptions.SignatureOf(new ObjectKey(ImageUpdated)))
            .Into(ciwProfileImage);

            Log.Error("ProfileActivity Glide ImgKey", ImageUpdated);


            tvName.Text  = name;
            tvEmail.Text = email;
            SetGender(gender);
            if (convertDateToStringFormat(birthdate) != null)
            {
                tvDateOftBirth.Text = convertDateToStringFormat(birthdate);
            }
            else
            {
                tvDateOftBirth.Text = birthdate;
            }

            tvAge.Text = GetAge(birthdate) + " ani";


            if (int.Parse(Utils.GetDefaults("UserType")) == 2)
            {
                var rlCWAfectiuni = FindViewById <RelativeLayout>(Resource.Id.cw_diseases);
                rlCWAfectiuni.Visibility = ViewStates.Gone;
            }
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            createSimpleChannelForServices();
            createNonstopChannelForServices();


            if (string.IsNullOrEmpty(Utils.GetDefaults("Token")) ||
                string.IsNullOrEmpty(Utils.GetDefaults("UserType")))
            {
                var intent = new Intent(this, typeof(LoginActivity));
                StartActivity(intent);
            }

            bool ok = int.TryParse(Utils.GetDefaults("UserType"), out int type);

            if (!ok)
            {
                _ = ClearStorage();
                StartActivity(typeof(LoginActivity));
                Finish();
                return;
            }

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

            SetSupportActionBar(toolbar);
            var drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            var toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open,
                                                   Resource.String.navigation_drawer_close);

            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);

            navigationView.SetNavigationItemSelectedListener(this);
            View   headerView       = navigationView.GetHeaderView(0);
            var    profileImageView = headerView.FindViewById <CircleImageView>(Resource.Id.menu_profile_image);
            string avatar           = Utils.GetDefaults("Avatar");

            _loacationServiceIntent = new Intent(this, typeof(LocationService));
            _webSocketServiceIntent = new Intent(this, typeof(WebSocketService));
            _smartBandServiceIntent = new Intent(this, typeof(SmartBandService));
            //_medicationServerServiceIntent = new Intent(this, typeof(MedicationServerService));
            IMenu menuNav = navigationView.Menu;

            //Consiliere de activitate ------
            if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.ActivityRecognition) == Permission.Denied)
            {
                RequestPermissions(new string[] { Manifest.Permission.ActivityRecognition }, 2);
                Log.Error("StepCounter Permission", "DENIDED");
            }
            else
            {
                Log.Error("StepCounter Permission", "ACCEPTED");
            }

            _stepCounterServiceIntent = new Intent(this, typeof(TrackerActivityService));
            StartForegroundService(_stepCounterServiceIntent);


            switch (type)
            {
            case 1:
                menuNav.FindItem(Resource.Id.nav_asistenta).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_devices).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_monitorizare).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_devices_asistent).SetVisible(false);

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, new QrCodeGenerator()).AddToBackStack(null).Commit();
                Title = "Generare cod QR";

                StartForegroundService(_webSocketServiceIntent);

                break;

            case 2:                     // asistent
                menuNav.FindItem(Resource.Id.nav_monitorizare).SetVisible(true);
                menuNav.FindItem(Resource.Id.nav_QRCode).SetVisible(false);
                menuNav.FindItem(Resource.Id.harta).SetVisible(false);
                menuNav.FindItem(Resource.Id.chat).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_devices).SetVisible(false);
                menuNav.FindItem(Resource.Id.medicatie).SetVisible(false);
                menuNav.FindItem(Resource.Id.games).SetVisible(false);
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, new AsistentForm()).AddToBackStack(null).Commit();
                Title = "Asistenta sociala";
                StartForegroundService(_webSocketServiceIntent);
                break;

            case 3:                     // pacient
                menuNav.FindItem(Resource.Id.nav_asistenta).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_monitorizare).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_devices_asistent).SetVisible(false);

                createAlarmMedicationChannel();


                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, new HealthDevicesFragment()).AddToBackStack(null)
                .Commit();
                Title = "Dispozitive de masurare";
                StartForegroundService(_webSocketServiceIntent);
                //StartService(_medicationServerServiceIntent);
                //StartService(_medicationServiceIntent);

                break;

            case 4:                     // self registered
                menuNav.FindItem(Resource.Id.nav_asistenta).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_monitorizare)?.SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_monitorizare).SetVisible(false);
                menuNav.FindItem(Resource.Id.nav_devices_asistent).SetVisible(false);
                menuNav.FindItem(Resource.Id.games).SetVisible(false);

                createAlarmMedicationChannel();

                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, new FindUsersFragment()).AddToBackStack(null).Commit();
                Title = "Cauta prieteni";
                StartForegroundService(_webSocketServiceIntent);

                break;
            }


            Log.Error("MainActivityDevicesRoot", "checking intent");
            var intentDevicesRoot = Intent;

            if (intentDevicesRoot != null && intentDevicesRoot.HasExtra(DevicesManagementActivity.DevicesRoot))
            {
                int userType = intentDevicesRoot.GetIntExtra(DevicesManagementActivity.DevicesRoot, -1);
                Log.Error("MainActivityDevicesRoot", "intent not null and has extra " + userType);

                if (userType != -1)
                {
                    switch (userType)
                    {
                    case 2:
                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.fragment_container, new AsistentHealthDevicesFragment())
                        .AddToBackStack(null).Commit();

                        break;

                    case 3:
                    case 4:
                        SupportFragmentManager.BeginTransaction()
                        .Replace(Resource.Id.fragment_container, new HealthDevicesFragment()).AddToBackStack(null)
                        .Commit();
                        break;
                    }
                    Title = "Dispozitive de masurare";
                }
            }
            else
            {
                Log.Error("MainActivityDevicesRoot", "intent is null or no extra");
            }


            if (!Utils.CheckIfLocationIsEnabled())
            {
                _ = new AlertDialog.Builder(this).SetMessage("Locatia nu este activata").SetPositiveButton("Activare",
                                                                                                           (sender, args) => {
                    StartActivityForResult(new Intent(Android.Provider.Settings.ActionLocationSourceSettings), 215);
                }).SetNegativeButton("Anulare", (sender, args) => { }).Show();
            }
            else
            {
                StartForegroundService(_loacationServiceIntent);
                if (int.Parse(Utils.GetDefaults("UserType")) == 4 || int.Parse(Utils.GetDefaults("UserType")) == 3 &&
                    !string.IsNullOrEmpty(Utils.GetDefaults(GetString(Resource.String.smartband_device))))
                {
                    StartForegroundService(_smartBandServiceIntent);
                }
            }

            Log.Error("LoginActivity Glide ImgKey", ProfileActivity.ImageUpdated);

            Glide.With(this).Load(avatar).Apply(RequestOptions.SignatureOf(new ObjectKey(ProfileActivity.ImageUpdated)))
            .Into(profileImageView);

            var lbNume = headerView.FindViewById <TextView>(Resource.Id.lbNume);

            lbNume.Text             = Utils.GetDefaults("Name");
            profileImageView.Click += delegate {
                StartActivityForResult(new Intent(this, typeof(ProfileActivity)), 466);
            };

            if (Intent.GetBooleanExtra("FromChat", false))
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, new ConversationsFragment()).AddToBackStack(null).Commit();
                Title = "Conversatii active";
            }

            if (Intent.GetBooleanExtra("FromMedicine", false))
            {
                StartActivity(new Intent(this, typeof(MedicineBaseActivity)));
                Log.Error("MAIN ACTIVITY", "on back pressed");
                Title = "Medicatie";
            }

            if (Intent.GetBooleanExtra("FromSmartband", false))
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, new HealthDevicesFragment()).AddToBackStack(null).Commit();
                Title = "Dispozitive de masurare";
            }

            if (Intent.HasExtra("extra_health_device"))
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.fragment_container, new HealthDevicesFragment()).AddToBackStack(null).Commit();
            }
        }
コード例 #4
0
        public async void LoadModel()
        {
            var dialog = new ProgressBarDialog("Asteptati", "Se incarca datele...", this, false);

            dialog.Show(); try
            {
                Log.Error("UpdateProfileActivity ERR load model", "load picture");
                Glide.With(this)
                .Load(personView.Avatar)
                .Apply(RequestOptions.SignatureOf(new ObjectKey(ProfileActivity.ImageUpdated)))
                .Into(ciwProfileImage);

                etName.Text = personView.Name;
                SetGender(personView.Gender);

                birthdate            = getDateString(personView.Birthdate);
                personView.Birthdate = getDateString(personView.Birthdate);

                tvBirthDate.Text = personView.Birthdate;

                Log.Error("UpdateProfileActivity ERR load model", "start getting diseases");
                personalData = await ProfileStorage.GetInstance().read();

                Log.Error("UpdateProfileActivity ERR load model", "after read data from db");


                if (personalData == null)
                {
                    Log.Error("UpdateProfileActivity ERR load model", "something went wrong");
                    Toast.MakeText(this, "S-a intampinat o eroare.", ToastLength.Long).Show();
                    // return;
                }
                else
                {
                    Log.Error("UpdateProfileActivity ERR load model", " else ");

                    if (personalData.listOfPersonalDiseases == null)
                    {
                        Log.Error("UpdateProfileActivity ERR load model", "list is null");
                        personalData.listOfPersonalDiseases = new List <PersonalDisease>();
                    }
                    Log.Error("UpdateProfileActivity ERR load model", "set disease count to TV " + personalData.listOfPersonalDiseases.Count);
                    btnLabelDiseases.Text = "Afecțiuni curente:" + personalData.listOfPersonalDiseases.Count;
                }

                if (int.Parse(Utils.GetDefaults("UserType")) == 2)
                {
                    FindViewById <ImageView>(Resource.Id.iw_icon).Visibility            = ViewStates.Gone;
                    FindViewById <TextView>(Resource.Id.tv_labelDiseases).Visibility    = ViewStates.Gone;
                    FindViewById <AppCompatButton>(Resource.Id.btn_diseases).Visibility = ViewStates.Gone;
                }


                RunOnUiThread(() => dialog.Dismiss());
            }
            catch (Exception e)
            {
                Log.Error("UpdateProfileActivity ERR 1", e.Message);
                RunOnUiThread(() => dialog.Dismiss());
            }
        }