protected override void OnPause()
        {
            base.OnPause();
            visibleContext = null;
            UnregisterReceiver(chatReceiver);

            isAppVisible = false;

            c.Log(LocalClassName.Split(".")[1] + " OnPause");
        }
        protected override void OnResume()
        {
            base.OnResume();
            visibleContext = this;
            RegisterReceiver(chatReceiver, new IntentFilter("balintfodor.locationconnection.ChatReceiver"));

            isAppVisible = true;
            if (!(this is ListActivity))             //we need to exclude ListActivity, because we need to show the GettingLocation label
            {
                if (!locationUpdating && c.IsLocationEnabled() && (c.IsLoggedIn() && Session.UseLocation == true || !c.IsLoggedIn()))
                {
                    StartLocationUpdates();
                }
            }

            c.Log(LocalClassName.Split(".")[1] + " OnResume");

            if (!ListActivity.initialized)             //When opening app, Android sometimes resumes an Activity while the static variables are cleared out, resulting in error
            {
                c.Log(LocalClassName.Split(".")[1] + " Not initialized");

                c.ReportErrorSilent("Initialization error");

                Intent i = new Intent(this, typeof(ListActivity));                 //current activity has to go through OnResume, therefore we cannot handle initialization errors in OnCreate
                StartActivity(i);
            }

            if (!(snack is null) && snack.IsShown)
            {
                snack.Dismiss();
            }

            if (!(Session.SnackMessage is null))             //ChatList: for the situation when the user is deleted, while the other is on their page, and now want to load the chat.
            {
                if (this is ChatOneActivity)
                {
                    RunOnUiThread(() =>
                    {
                        c.SnackStr(Session.SnackMessage.Replace("[name]", Session.CurrentMatch.TargetName));
                    });
                    Session.SnackMessage = null;
                }
                else
                {
                    RunOnUiThread(() =>
                    {
                        c.SnackStr(Session.SnackMessage);
                    });
                    Session.SnackMessage = null;
                }
            }
        }
        public static BaseActivity visibleContext;         //needed for location callback. In SettingsActivity location updates may restart, but LoadListStartup is not called when returning to ListActivity, resulting in the "Getting location..." message to hang.

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            c   = new CommonMethods(this);
            res = Resources;
            if (c.IsLoggedIn())
            {
                CheckIntent();
            }
            chatReceiver = new ChatReceiver();

            if (fusedLocationProviderClient is null)
            {
                fusedLocationProviderClient = LocationServices.GetFusedLocationProviderClient(this);
            }
            c.Log(LocalClassName.Split(".")[1] + " OnCreate");
        }
Beispiel #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try {
                base.OnCreate(savedInstanceState);

                //c.CW("OnCreate savedInstanceState is null " + (savedInstanceState is null));

                //Test reset

                /*
                 * ListActivity.initialized = false;
                 * savedInstanceState = new Bundle();
                 * savedInstanceState.PutString("Session", c.SerializeSession());
                 *
                 * ListActivity.initialized = false;
                 * Type type = typeof(Session);
                 * FieldInfo[] fieldInfo = type.GetFields();
                 * foreach (FieldInfo field in fieldInfo)
                 * {
                 *      field.SetValue(null, null);
                 * }
                 */

                if (!ListActivity.initialized && !(savedInstanceState is null))
                {
                    c.Log("ProfileEditActivity not initialized, restoring");

                    ListActivity.initialized       = true;
                    IntentData.profileViewPageType = Constants.ProfileViewType_Self;
                    GetScreenMetrics(true);
                    c.LoadSettings(false);
                    c.DeSerializeSession(savedInstanceState.GetString("Session"));
                    imageEditorFrameBorderWidth = savedInstanceState.GetInt("imageEditorFrameBorderWidth");
                }
                else if (!ListActivity.initialized && savedInstanceState is null)
                {
                    c.Log(LocalClassName.Split(".")[1] + " Not initialized");

                    c.ReportErrorSilent("Initialization error");

                    Intent i = new Intent(this, typeof(ListActivity));
                    i.SetFlags(ActivityFlags.ReorderToFront);
                    StartActivity(i);
                }

                if (Settings.DisplaySize == 1)
                {
                    SetContentView(Resource.Layout.activity_profileedit_normal);
                }
                else
                {
                    SetContentView(Resource.Layout.activity_profileedit_small);
                }

                //ProfilePage start

                MainScroll         = FindViewById <TouchScrollView>(Resource.Id.MainScroll);
                MainLayout         = FindViewById <ConstraintLayout>(Resource.Id.MainLayout);
                Email              = FindViewById <EditText>(Resource.Id.Email);
                Username           = FindViewById <EditText>(Resource.Id.Username);
                CheckUsername      = FindViewById <Button>(Resource.Id.CheckUsername);
                Name               = FindViewById <EditText>(Resource.Id.Name);
                ImagesUploaded     = FindViewById <ImageFrameLayout>(Resource.Id.ImagesUploaded);
                Images             = FindViewById <Button>(Resource.Id.Images);
                ImagesProgressText = FindViewById <TextView>(Resource.Id.ImagesProgressText);
                LoaderCircle       = FindViewById <ImageView>(Resource.Id.LoaderCircle);
                ImagesProgress     = FindViewById <ProgressBar>(Resource.Id.ImagesProgress);
                Description        = FindViewById <EditText>(Resource.Id.Description);

                UseLocationSwitch   = FindViewById <Switch>(Resource.Id.UseLocationSwitch);
                LocationShareAll    = FindViewById <Switch>(Resource.Id.LocationShareAll);
                LocationShareLike   = FindViewById <Switch>(Resource.Id.LocationShareLike);
                LocationShareMatch  = FindViewById <Switch>(Resource.Id.LocationShareMatch);
                LocationShareFriend = FindViewById <Switch>(Resource.Id.LocationShareFriend);
                LocationShareNone   = FindViewById <Switch>(Resource.Id.LocationShareNone);

                DistanceShareAll    = FindViewById <Switch>(Resource.Id.DistanceShareAll);
                DistanceShareLike   = FindViewById <Switch>(Resource.Id.DistanceShareLike);
                DistanceShareMatch  = FindViewById <Switch>(Resource.Id.DistanceShareMatch);
                DistanceShareFriend = FindViewById <Switch>(Resource.Id.DistanceShareFriend);
                DistanceShareNone   = FindViewById <Switch>(Resource.Id.DistanceShareNone);

                ImageEditorFrame       = FindViewById <View>(Resource.Id.ImageEditorFrame);
                ImageEditorFrameBorder = FindViewById <View>(Resource.Id.ImageEditorFrameBorder);
                ImageEditor            = FindViewById <ScaleImageView>(Resource.Id.ImageEditor);
                ImageEditorControls    = FindViewById <LinearLayout>(Resource.Id.ImageEditorControls);
                ImageEditorCancel      = FindViewById <ImageButton>(Resource.Id.ImageEditorCancel);
                ImageEditorOK          = FindViewById <ImageButton>(Resource.Id.ImageEditorOK);
                TopSeparator           = FindViewById <View>(Resource.Id.TopSeparator);

                //ProfilePage end

                Women = FindViewById <Switch>(Resource.Id.Women);
                Men   = FindViewById <Switch>(Resource.Id.Men);

                EditAccountData             = FindViewById <TextView>(Resource.Id.EditAccountData);
                EditChangePassword          = FindViewById <TextView>(Resource.Id.EditChangePassword);
                EditLocationSettings        = FindViewById <TextView>(Resource.Id.EditLocationSettings);
                EditMoreOptions             = FindViewById <TextView>(Resource.Id.EditMoreOptions);
                EditAccountDataSection      = FindViewById <ConstraintLayout>(Resource.Id.EditAccountDataSection);
                EditChangePasswordSection   = FindViewById <ConstraintLayout>(Resource.Id.EditChangePasswordSection);
                EditLocationSettingsSection = FindViewById <ConstraintLayout>(Resource.Id.EditLocationSettingsSection);

                EditOldPassword     = FindViewById <EditText>(Resource.Id.EditOldPassword);
                EditNewPassword     = FindViewById <EditText>(Resource.Id.EditNewPassword);
                EditConfirmPassword = FindViewById <EditText>(Resource.Id.EditConfirmPassword);

                Save   = FindViewById <Button>(Resource.Id.Save);
                Cancel = FindViewById <Button>(Resource.Id.Cancel);

                DeactivateAccount = FindViewById <Button>(Resource.Id.DeactivateAccount);
                DeleteAccount     = FindViewById <Button>(Resource.Id.DeleteAccount);

                ImagesUploaded.numColumns  = 3;                //it does not get passed in the layout file
                ImagesUploaded.tileSpacing = 2;
                ImagesUploaded.SetTileSize();

                c.view = MainLayout;
                rc     = new RegisterCommonMethods(this);
                imm    = (InputMethodManager)GetSystemService(InputMethodService);

                Women.Click += Women_Click;
                Men.Click   += Men_Click;

                EditAccountData.Click      += EditAccountData_Click;
                EditChangePassword.Click   += EditChangePassword_Click;
                EditLocationSettings.Click += EditLocationSettings_Click;
                EditMoreOptions.Click      += EditMoreOptions_Click;

                Save.Click              += Save_Click;
                Cancel.Click            += Cancel_Click;
                DeactivateAccount.Click += DeactivateAccount_Click;
                DeleteAccount.Click     += DeleteAccount_Click;
            }
            catch (Exception ex)
            {
                c.ReportErrorSilent(ex.Message + System.Environment.NewLine + ex.StackTrace);
            }
        }