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

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            ISharedPreferences prefs = Application.Context.GetSharedPreferences("TEST_PREF", FileCreationMode.Private);


            // Tracking Users
            EditText userIdEditText = FindViewById <EditText>(Resource.Id.userIdEditText);

            userId = prefs.GetString("userid", "");
            userIdEditText.Text = userId;

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

            if (userId.Equals(""))
            {
                loginButton.Text = "LOGIN";
            }
            else
            {
                loginButton.Text = "LOGOUT";
            }

            loginButton.Click += delegate
            {
                if (loginButton.Text.Equals("LOGIN"))
                {
                    userId = userIdEditText.Text.ToString();

                    if (!userId.Equals(""))
                    {
                        ISharedPreferencesEditor editor = prefs.Edit();
                        editor.PutString("userid", userId);
                        editor.Apply();

                        loginButton.Text = "LOGOUT";

                        // Login
                        WebEngage.Get().User().Login(userId);
                    }
                }
                else
                {
                    ISharedPreferencesEditor editor = prefs.Edit();
                    editor.PutString("userid", "");
                    editor.Apply();

                    loginButton.Text = "LOGIN";

                    userIdEditText.Text = "";

                    // Logout
                    WebEngage.Get().User().Logout();
                }
            };


            // System user attributes
            EditText emailEditText = FindViewById <EditText>(Resource.Id.emailEditText);
            Button   emailButton   = FindViewById <Button>(Resource.Id.emailButton);

            emailButton.Click += delegate
            {
                string email = emailEditText.Text.ToString();
                if (!email.Equals(""))
                {
                    WebEngage.Get().User().SetEmail(email);
                    Toast.MakeText(this.ApplicationContext, "Email set successfully", ToastLength.Long).Show();
                }
            };

            Spinner genderSpinner = FindViewById <Spinner>(Resource.Id.genderSpinner);
            var     adapter       = ArrayAdapter.CreateFromResource(
                this, Resource.Array.gender_array, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            genderSpinner.Adapter = adapter;

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

            genderButton.Click += delegate
            {
                int    spinnerPosition = genderSpinner.SelectedItemPosition;
                Gender gender          = Gender.Male;
                if (spinnerPosition == 0)
                {
                    gender = Gender.Male;
                }
                else if (spinnerPosition == 1)
                {
                    gender = Gender.Female;
                }
                else if (spinnerPosition == 2)
                {
                    gender = Gender.Other;
                }
                WebEngage.Get().User().SetGender(gender);

                Toast.MakeText(this.BaseContext, "Gender set successfully", ToastLength.Long).Show();
            };

            //WebEngage.Get().User().SetBirthDate("1994-04-29");
            //WebEngage.Get().User().SetFirstName("John");
            //WebEngage.Get().User().SetLastName("Doe");
            //WebEngage.Get().User().SetCompany("WebEngage");
            //WebEngage.Get().User().SetPhoneNumber("+551155256325");
            //WebEngage.Get().User().SetHashedPhoneNumber("e0ec043b3f9e198ec09041687e4d4e8d");
            //WebEngage.Get().User().SetHashedEmail("144e0424883546e07dcd727057fd3b62");

            // Channels
            //WebEngage.Get().User().SetOptIn(Channel.Whatsapp, true);
            //WebEngage.Get().User().SetOptIn(Channel.Email, true);
            //WebEngage.Get().User().SetOptIn(Channel.Sms, true);
            //WebEngage.Get().User().SetOptIn(Channel.Push, true);
            //WebEngage.Get().User().SetOptIn(Channel.InApp, true);

            // Custom user attributes
            //WebEngage.Get().User().SetAttribute("age", (Java.Lang.Integer)23);
            //WebEngage.Get().User().SetAttribute("premium", (Boolean)true);
            //WebEngage.Get().User().SetAttribute("last_seen", new Date("2018-12-25"));

            //IDictionary<string, Object> customAttributes = new Dictionary<string, Object>();
            //customAttributes.Add("Twitter Email", "*****@*****.**");
            //customAttributes.Add("Subscribed", true);
            //WebEngage.Get().User().SetAttributes(customAttributes);

            //WebEngage.Get().User().DeleteAttribute("age");
            //WebEngage.Get().SetLocationTrackingStrategy(LocationTrackingStrategy.AccuracyCity);
            //WebEngage.Get().User().SetLocation(12.23, 12.45);

            //IList<Object> brandAffinity = new List<Object>
            //{
            //    "Hugo Boss",
            //    "Armani Exchange",
            //    "GAS",
            //    "Brooks Brothers"
            //};
            //WebEngage.Get().User().SetAttribute("Brand affinity", brandAffinity);

            //JavaDictionary<string, Object> address = new JavaDictionary<string, Object>
            //{
            //    { "Flat", "Z-62" },
            //    { "Building", "Pennant Court" },
            //    { "Locality", "Penn Road" },
            //    { "City", "Wolverhampton" },
            //    { "State", "West Midlands" },
            //    { "PIN", "WV30DT" }
            //};
            //IDictionary<string, Object> customAttributes = new Dictionary<string, Object>();
            //customAttributes.Add("Address", address);
            //WebEngage.Get().User().SetAttributes(customAttributes);


            // Tracking Events
            EditText eventEditText = FindViewById <EditText>(Resource.Id.eventEditText);

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

            trackButton.Click += delegate
            {
                string eventName = eventEditText.Text;
                if (!eventName.Equals(""))
                {
                    WebEngage.Get().Analytics().Track(eventName, new Analytics.Options().SetHighReportingPriority(false));
                    Toast.MakeText(this.BaseContext, "Event tracked successfully", ToastLength.Long).Show();
                }
            };

            // Tracking Event with Attributes
            //IDictionary<string, Object> attributes = new Dictionary<string, Object>
            //{
            //    { "id", "~123" },
            //    { "price", 100 },
            //    { "discount", true }
            //};
            //WebEngage.Get().Analytics().Track("Product Viewed", attributes, new Analytics.Options().SetHighReportingPriority(false));

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

            shopButton.Click += delegate
            {
                // Tracking Complex Events
                IDictionary <string, Object> product1 = new JavaDictionary <string, Object>();
                product1.Add("SKU Code", "UHUH799");
                product1.Add("Product Name", "Armani Jeans");
                product1.Add("Price", 300.49);

                JavaDictionary <string, Object> detailsProduct1 = new JavaDictionary <string, Object>();
                detailsProduct1.Add("Size", "L");
                product1.Add("Details", detailsProduct1);

                IDictionary <string, Object> product2 = new JavaDictionary <string, Object>();
                product2.Add("SKU Code", "FBHG746");
                product2.Add("Product Name", "Hugo Boss Jacket");
                product2.Add("Price", 507.99);

                JavaDictionary <string, Object> detailsProduct2 = new JavaDictionary <string, Object>();
                detailsProduct2.Add("Size", "L");
                product2.Add("Details", detailsProduct2);

                IDictionary <string, Object> deliveryAddress = new JavaDictionary <string, Object>();
                deliveryAddress.Add("City", "San Francisco");
                deliveryAddress.Add("ZIP", "94121");

                JavaDictionary <string, Object> orderPlacedAttributes = new JavaDictionary <string, Object>();
                JavaList <Object> products = new JavaList <Object>();
                products.Add(product1);
                products.Add(product2);

                JavaList <string> coupons = new JavaList <string>();
                coupons.Add("BOGO17");

                orderPlacedAttributes.Add("Products", products);
                orderPlacedAttributes.Add("Delivery Address", deliveryAddress);
                orderPlacedAttributes.Add("Coupons Applied", coupons);

                WebEngage.Get().Analytics().Track("Order Placed", orderPlacedAttributes, new Analytics.Options().SetHighReportingPriority(false));

                Toast.MakeText(this.BaseContext, "Order Placed successfully", ToastLength.Long).Show();
            };

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

            locationButton.Click += delegate
            {
                requestLocationPermission();
            };

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

            nextButton.Click += delegate
            {
                StartActivity(typeof(NextActivity));
            };
        }
Esempio n. 2
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.ListOfSpecialists);
                dialogsTV           = FindViewById <TextView>(Resource.Id.dialogsTV);
                message_indicatorIV = FindViewById <ImageView>(Resource.Id.message_indicatorIV);
                inputMethodManager  = Application.GetSystemService(Context.InputMethodService) as InputMethodManager;
                InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                searchET                = FindViewById <EditText>(Resource.Id.searchET);
                expert_data             = Application.Context.GetSharedPreferences("experts", FileCreationMode.Private);
                edit_expert             = expert_data.Edit();
                loginRegFragment        = new LoginRegFragment();
                fragmentManager         = this.FragmentManager;
                offset                  = 100;
                headerTV                = FindViewById <TextView>(Resource.Id.headerTV);
                typesTV                 = FindViewById <TextView>(Resource.Id.typesTV);
                headerTV.Text           = expert_data.GetString("spec_name", String.Empty);;
                typesTV.Text            = expert_data.GetString("spec_type", String.Empty);
                recyclerView            = FindViewById <RecyclerView>(Resource.Id.recyclerView);
                recyclerViewDropdown    = FindViewById <RecyclerView>(Resource.Id.recyclerViewDropdown);
                linearLayout7644        = FindViewById <RelativeLayout>(Resource.Id.linearLayout7644);
                activityIndicator       = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                activityIndicatorSearch = FindViewById <ProgressBar>(Resource.Id.activityIndicatorSearch);
                nothingIV               = FindViewById <ImageView>(Resource.Id.nothingIV);
                backRelativeLayout      = FindViewById <RelativeLayout>(Resource.Id.backRelativeLayout);
                nothingTV               = FindViewById <TextView>(Resource.Id.nothingTV);
                searchLL                = FindViewById <LinearLayout>(Resource.Id.searchLL);
                search_recyclerView     = FindViewById <RecyclerView>(Resource.Id.search_recyclerView);
                bottomLayout            = FindViewById <RelativeLayout>(Resource.Id.bottomLayout);
                upper_layout            = FindViewById <RelativeLayout>(Resource.Id.upper_layout);
                back_button             = FindViewById <ImageButton>(Resource.Id.back_button);
                dropdownBn              = FindViewById <Button>(Resource.Id.dropdownBn);
                searchBn                = FindViewById <Button>(Resource.Id.searchBn);
                sortBn                  = FindViewById <Button>(Resource.Id.sortBn);
                filterBn                = FindViewById <Button>(Resource.Id.filterBn);
                close_searchBn          = FindViewById <ImageButton>(Resource.Id.close_searchBn);
                navbarLL                = FindViewById <RelativeLayout>(Resource.Id.navbarLL);
                tintLL                  = FindViewById <LinearLayout>(Resource.Id.tintLL);
                //sorting
                sortLL        = FindViewById <LinearLayout>(Resource.Id.sortLL);
                by_distanceLL = FindViewById <RelativeLayout>(Resource.Id.by_distanceLL);
                by_ratingLL   = FindViewById <RelativeLayout>(Resource.Id.by_ratingLL);
                by_distanceIV = FindViewById <ImageView>(Resource.Id.by_distanceIV);
                by_ratingIV   = FindViewById <ImageView>(Resource.Id.by_ratingIV);
                by_distanceTV = FindViewById <TextView>(Resource.Id.by_distanceTV);
                by_ratingTV   = FindViewById <TextView>(Resource.Id.by_ratingTV);
                //sorting ENDED
                show_on_mapBn = FindViewById <Button>(Resource.Id.show_on_mapBn);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                activityIndicatorSearch.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                layoutManager         = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);
                layoutManagerDropdown = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);
                search_layoutManager  = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);
                recyclerView.SetLayoutManager(layoutManager);
                recyclerViewDropdown.SetLayoutManager(layoutManagerDropdown);
                search_recyclerView.SetLayoutManager(search_layoutManager);
                SpecializationMethods specializationMethods = new SpecializationMethods();

                profileLL = FindViewById <LinearLayout>(Resource.Id.profileLL);
                dialogsLL = FindViewById <LinearLayout>(Resource.Id.dialogsLL);

                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                headerTV.SetTypeface(tf, TypefaceStyle.Bold);
                typesTV.SetTypeface(tf, TypefaceStyle.Normal);
                dropdownBn.SetTypeface(tf, TypefaceStyle.Normal);
                searchET.SetTypeface(tf, TypefaceStyle.Normal);
                searchBn.SetTypeface(tf, TypefaceStyle.Normal);
                show_on_mapBn.SetTypeface(tf, TypefaceStyle.Bold);
                filterBn.SetTypeface(tf, TypefaceStyle.Normal);
                sortBn.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.specialistsTV).SetTypeface(tf, TypefaceStyle.Normal);
                dialogsTV.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.profileTV).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textVsiew1).SetTypeface(tf, TypefaceStyle.Normal);
                by_distanceTV.SetTypeface(tf, TypefaceStyle.Normal);
                by_ratingTV.SetTypeface(tf, TypefaceStyle.Normal);
                nothingTV.SetTypeface(tf, TypefaceStyle.Normal);

                dialogsLL.Click += (s, e) =>
                {
                    if (userMethods.UserExists())
                    {
                        edit_dialog = dialog_data.Edit();
                        edit_dialog.PutString("come_from", "Came directly from bottom");
                        edit_dialog.Apply();
                        StartActivity(typeof(ChatListActivity));
                    }
                    else
                    {
                        showFragment();
                    }
                };
                profileLL.Click += (s, e) =>
                {
                    if (userMethods.UserExists())
                    {
                        StartActivity(typeof(UserProfileActivity));
                    }
                    else
                    {
                        showFragment();
                    }
                };

                searchET.Visibility       = ViewStates.Gone;
                backRelativeLayout.Click += (s, e) =>
                {
                    OnBackPressed();
                };
                back_button.Click += (s, e) =>
                {
                    OnBackPressed();
                };


                searchBn.Click += (s, e) =>
                {
                    close_searchBn.Visibility = ViewStates.Visible;
                    searchET.Visibility       = ViewStates.Visible;
                    searchBn.Visibility       = ViewStates.Gone;
                    dropdownBn.Visibility     = ViewStates.Gone;
                    headerTV.Visibility       = ViewStates.Gone;
                    typesTV.Visibility        = ViewStates.Gone;

                    searchET.RequestFocus();
                    showKeyboard();
                };


                sortBn.Click += (s, e) =>
                {
                    tintLL.Visibility = ViewStates.Visible;
                    sortLL.Visibility = ViewStates.Visible;
                };

                by_distanceLL.Click += By_distance_Click;
                by_distanceIV.Click += By_distance_Click;
                by_distanceTV.Click += By_distance_Click;
                by_ratingLL.Click   += By_rating_Click;
                by_ratingIV.Click   += By_rating_Click;
                by_ratingTV.Click   += By_rating_Click;

                if (expert_data.GetInt("sort_meth", 1) == 1)
                {
                    by_distanceIV.Visibility = ViewStates.Visible;
                    by_ratingIV.Visibility   = ViewStates.Gone;
                }
                else
                {
                    by_distanceIV.Visibility = ViewStates.Gone;
                    by_ratingIV.Visibility   = ViewStates.Visible;
                }



                var sort_type = expert_data.GetInt("sort_meth", 1);
                var specs     = await specializationMethods.ExpertsList(
                    expert_data.GetString("spec_id", String.Empty),
                    pref.GetString("latitude", String.Empty),
                    pref.GetString("longitude", String.Empty),
                    expert_data.GetInt("sort_meth", 1),
                    expert_data.GetString("expert_city_id", String.Empty),
                    expert_data.GetString("distance_radius", String.Empty),
                    expert_data.GetBoolean("has_reviews", false)//, this
                    );

                activityIndicator.Visibility = ViewStates.Gone;
                try
                {
                    if (specs != "null" && !String.IsNullOrEmpty(specs))
                    {
                        var deserialized_experts = JsonConvert.DeserializeObject <RootObjectExpert>(specs.ToString());
                        if (!String.IsNullOrEmpty(deserialized_experts.notify_alerts.msg_cnt_new.ToString()) && deserialized_experts.notify_alerts.msg_cnt_new.ToString() != "0")
                        {
                            message_indicatorIV.Visibility = ViewStates.Visible;
                            dialogsTV.Text = GetString(Resource.String.dialogs) + " (" + deserialized_experts.notify_alerts.msg_cnt_new + ")";
                        }
                        else
                        {
                            message_indicatorIV.Visibility = ViewStates.Gone;
                            dialogsTV.Text = GetString(Resource.String.dialogs);
                        }
                        listOfSpecialistsAdapter = new ListOfSpecialistsAdapter(deserialized_experts.experts, this, tf);
                        recyclerView.SetAdapter(listOfSpecialistsAdapter);
                        //Toast.MakeText(this, "десериализовано. адаптер задан", ToastLength.Short).Show();
                    }
                }
                catch { }

                show_on_mapBn.Click += (s, e) =>
                {
                    edit_expert.PutString("latitude", pref.GetString("latitude", String.Empty));
                    edit_expert.PutString("longitude", pref.GetString("longitude", String.Empty));
                    edit_expert.PutString("spec_id", expert_data.GetString("spec_id", String.Empty));
                    edit_expert.PutString("specs", specs);
                    edit_expert.PutString("spec_name", expert_data.GetString("spec_name", String.Empty));
                    edit_expert.PutString("spec_type", expert_data.GetString("spec_type", String.Empty));
                    edit_expert.PutBoolean("has_subcategory", expert_data.GetBoolean("has_subcategory", false));
                    edit_expert.Apply();
                    StartActivity(typeof(SpecialistsOnMapActivity));
                };

                dropdown_closed   = true;
                dropdownBn.Click += (s, e) =>
                                    dropdownClick();
                linearLayout7644.Click += (s, e) =>
                {
                    if (dropdownBn.Visibility == ViewStates.Visible)
                    {
                        dropdownClick();
                    }
                };
                bool types_visible = false;

                if (typesTV.Visibility == ViewStates.Visible)
                {
                    types_visible = true;
                }

                ScrollDownDetector downDetector   = new ScrollDownDetector();
                ScrollUpDetector   upDetector     = new ScrollUpDetector();
                var margin_top_value              = navbarLL.LayoutParameters.Height;
                LinearLayout.LayoutParams ll_down = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                LinearLayout.LayoutParams ll_up   = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                ll_down.SetMargins(0, 0, 0, 0);
                ll_up.SetMargins(0, margin_top_value, 0, 0);
                System.Timers.Timer timer  = new System.Timers.Timer();
                System.Timers.Timer timer2 = null;
                downDetector.Action = () =>
                {
                    if (dropdown_closed)
                    {
                        timer          = new System.Timers.Timer();
                        timer.Interval = 500;
                        timer.Start();
                        timer.Elapsed += (s, e) =>
                        {
                            timer.Stop();
                            timer = null;
                        };
                        if (timer2 == null)
                        {
                            upper_layout.LayoutParameters = ll_down;
                        }
                    }
                };
                upDetector.Action = () =>
                {
                    timer2 = new System.Timers.Timer();
                    if (dropdown_closed)
                    {
                        if (timer == null)
                        {
                            timer2.Interval = 500;
                            timer2.Start();
                            timer2.Elapsed += (s, e) =>
                            {
                                timer2.Stop();
                                timer2 = null;
                            };
                            upper_layout.LayoutParameters = ll_up;
                        }
                    }
                };
                recyclerView.AddOnScrollListener(downDetector);
                recyclerView.AddOnScrollListener(upDetector);
                filterBn.Click += (s, e) =>
                {
                    StartActivity(typeof(FilterActivity));
                };

                searchET.EditorAction += (object sender, EditText.EditorActionEventArgs e) =>
                {
                    imm.HideSoftInputFromWindow(searchET.WindowToken, 0);
                };

                searchET.TextChanged += async(s, e) =>
                {
                    if (!String.IsNullOrEmpty(searchET.Text))
                    {
                        nothingIV.Visibility               = ViewStates.Gone;
                        nothingTV.Visibility               = ViewStates.Gone;
                        searchLL.Visibility                = ViewStates.Visible;
                        close_searchBn.Visibility          = ViewStates.Visible;
                        activityIndicatorSearch.Visibility = ViewStates.Visible;
                        search_recyclerView.Visibility     = ViewStates.Gone;
                        activityIndicatorSearch.Visibility = ViewStates.Visible;
                        var search_content = await specializationMethods.SearchCategory(searchET.Text);

                        if (!search_content.ToLower().Contains("пошло не так".ToLower()) && !search_content.Contains("null"))
                        //try
                        {
                            search_recyclerView.Visibility = ViewStates.Visible;
                            deserialized_search            = JsonConvert.DeserializeObject <List <SearchCategory> >(search_content.ToString());
                            List <SearchDisplaying> searchDisplayings = new List <SearchDisplaying>();
                            foreach (var item in deserialized_search)
                            {
                                if (item.hasSubcategory)
                                {
                                    searchDisplayings.Add(new SearchDisplaying {
                                        id = item.id, name = item.name, iconUrl = item.iconUrl, isRoot = true, hasSubcategory = true, rootId = item.id
                                    });
                                    if (item.subcategories != null)
                                    {
                                        foreach (var item1 in item.subcategories)
                                        {
                                            if (item1.hasSubcategory)
                                            {
                                                searchDisplayings.Add(new SearchDisplaying {
                                                    id = item1.id, name = item1.name, iconUrl = null, isRoot = false, hasSubcategory = true, rootId = item.id
                                                });
                                                if (item1.subcategories != null)
                                                {
                                                    foreach (var item2 in item1.subcategories)
                                                    {
                                                        if (item2.hasSubcategory)
                                                        {
                                                            searchDisplayings.Add(new SearchDisplaying {
                                                                id = item2.id, name = item2.name, iconUrl = null, isRoot = false, hasSubcategory = true, rootId = item.id
                                                            });
                                                            if (item2.subcategories != null)
                                                            {
                                                                foreach (var item3 in item2.subcategories)
                                                                {
                                                                    if (item3.subcategories != null)
                                                                    {
                                                                        searchDisplayings.Add(new SearchDisplaying {
                                                                            id = item3.id, name = item3.name, iconUrl = null, isRoot = false, hasSubcategory = true, rootId = item.id
                                                                        });
                                                                        foreach (var item4 in item3.subcategories)
                                                                        {
                                                                            searchDisplayings.Add(new SearchDisplaying {
                                                                                id = item4.id, name = item4.name, iconUrl = null, isRoot = false, hasSubcategory = true, rootId = item.id
                                                                            });
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        searchDisplayings.Add(new SearchDisplaying {
                                                                            id = item3.id, name = item3.name, iconUrl = null, isRoot = false, hasSubcategory = false, rootId = item.id
                                                                        });
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            searchDisplayings.Add(new SearchDisplaying {
                                                                id = item2.id, name = item2.name, iconUrl = null, isRoot = false, hasSubcategory = false, rootId = item.id
                                                            });
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                searchDisplayings.Add(new SearchDisplaying {
                                                    id = item1.id, name = item1.name, iconUrl = null, isRoot = false, hasSubcategory = false, rootId = item.id
                                                });
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    searchDisplayings.Add(new SearchDisplaying {
                                        id = item.id, name = item.name, iconUrl = item.iconUrl, isRoot = true, hasSubcategory = false, rootId = item.id
                                    });
                                }
                            }

                            specialistsCategorySearchAdapter = new SpecialistsCategorySearchAdapter(searchDisplayings, this, tf);
                            specialistsCategorySearchAdapter.NotifyDataSetChanged();
                            search_recyclerView.SetAdapter(specialistsCategorySearchAdapter);

                            specialistsCategorySearchAdapter.NotifyDataSetChanged();
                            nothingIV.Visibility = ViewStates.Gone;
                            nothingTV.Visibility = ViewStates.Gone;
                        }
                        else
                        {
                            search_recyclerView.Visibility = ViewStates.Gone;
                            nothingIV.Visibility           = ViewStates.Visible;
                            nothingTV.Visibility           = ViewStates.Visible;
                        }

                        activityIndicatorSearch.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        close_searchBn.Visibility = ViewStates.Gone;
                        searchLL.Visibility       = ViewStates.Visible;
                        close_searchBn.Visibility = ViewStates.Gone;
                        searchLL.Visibility       = ViewStates.Visible;
                        searchLL.Visibility       = ViewStates.Gone;
                    }
                };
                tintLL.Click += (s, e) =>
                {
                    tintLL.Visibility = ViewStates.Gone;
                    recyclerViewDropdown.Visibility = ViewStates.Gone;
                    tintLL.Visibility = ViewStates.Gone;
                    dropdown_closed   = true;
                    sortLL.Visibility = ViewStates.Gone;
                    dropdownBn.SetBackgroundResource(Resource.Drawable.dropdown);
                };
                refresher = FindViewById <SwipyRefreshLayout>(Resource.Id.refresher);
                refresher.SetColorScheme(Resource.Color.lightBlueColor,
                                         Resource.Color.buttonBackgroundColor);
                refresher.Direction = SwipyRefreshLayoutDirection.Bottom;

                refresher.Refresh += async delegate
                {
                    var specs_updated = await specializationMethods.ExpertsList(
                        expert_data.GetString("spec_id", String.Empty),
                        pref.GetString("latitude", String.Empty),
                        pref.GetString("longitude", String.Empty),
                        expert_data.GetInt("sort_meth", 1),
                        expert_data.GetString("expert_city_id", String.Empty),
                        expert_data.GetString("distance_radius", String.Empty),
                        expert_data.GetBoolean("has_reviews", false),//, this
                        offset
                        );

                    try
                    {
                        if (!String.IsNullOrEmpty(specs_updated) && specs_updated.Length > 10)
                        {
                            var deserialized_updated_specs = JsonConvert.DeserializeObject <RootObjectExpert>(specs_updated);
                            ListOfSpecialistsAdapter.experts_static.InsertRange(offset, deserialized_updated_specs.experts);
                            if (!String.IsNullOrEmpty(deserialized_updated_specs.notify_alerts.msg_cnt_new.ToString()) && deserialized_updated_specs.notify_alerts.msg_cnt_new.ToString() != "0")
                            {
                                message_indicatorIV.Visibility = ViewStates.Visible;
                                dialogsTV.Text = GetString(Resource.String.dialogs) + " (" + deserialized_updated_specs.notify_alerts.msg_cnt_new + ")";
                            }
                            else
                            {
                                message_indicatorIV.Visibility = ViewStates.Gone;
                                dialogsTV.Text = GetString(Resource.String.dialogs);
                            }
                            listOfSpecialistsAdapter.NotifyDataSetChanged();
                            recyclerView.SmoothScrollToPosition(offset);

                            offset += 100;
                        }
                    }
                    catch { }
                    refresher.Refreshing = false;
                };
                //checking if category has subcategories to load them
                if (expert_data.GetBoolean("has_subcategory", true))
                {
                    var sub_categs = await specializationMethods.GetSubCategories(expert_data.GetString("spec_id", String.Empty));

                    var deserObj = JsonConvert.DeserializeObject <SubCategoryRootObject>(sub_categs.ToString());
                    if (!String.IsNullOrEmpty(deserObj.notify_alerts.msg_cnt_new.ToString()) && deserObj.notify_alerts.msg_cnt_new.ToString() != "0")
                    {
                        message_indicatorIV.Visibility = ViewStates.Visible;
                        dialogsTV.Text = GetString(Resource.String.dialogs) + " (" + deserObj.notify_alerts.msg_cnt_new + ")";
                    }
                    else
                    {
                        message_indicatorIV.Visibility = ViewStates.Gone;
                        dialogsTV.Text = GetString(Resource.String.dialogs);
                    }
                    deserialized_sub_categs = deserObj.subcategories;
                    if (deserialized_sub_categs == null)
                    {
                        deserialized_sub_categs = new List <SubCategory>();
                    }
                    deserialized_sub_categs.Insert(0, new SubCategory {
                        id = "-1", name = GetString(Resource.String.all_subcategs)
                    });
                    var dropDownSubcategsAdapter = new DropDownSubcategsAdapter(deserialized_sub_categs, this, tf);
                    recyclerViewDropdown.SetAdapter(dropDownSubcategsAdapter);
                    dropdownBn.Visibility = ViewStates.Visible;
                    typesTV.Visibility    = ViewStates.Visible;
                }
                else
                {
                    dropdownBn.Visibility = ViewStates.Gone;
                }
                bool was_drop_visible = false;
                if (dropdownBn.Visibility == ViewStates.Visible)
                {
                    was_drop_visible = true;
                }
                close_searchBn.Click += (s, e) =>
                {
                    searchET.Text = null;
                    imm.HideSoftInputFromWindow(searchET.WindowToken, 0);
                    searchLL.Visibility = ViewStates.Gone;
                    if (types_visible)
                    {
                        typesTV.Visibility = ViewStates.Visible;
                    }
                    if (was_drop_visible)
                    {
                        dropdownBn.Visibility = ViewStates.Visible;
                    }
                    headerTV.Visibility       = ViewStates.Visible;
                    searchET.Visibility       = ViewStates.Gone;
                    close_searchBn.Visibility = ViewStates.Gone;
                    searchBn.Visibility       = ViewStates.Visible;
                };
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }
Esempio n. 3
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences       prefs1  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor1 = prefs1.Edit();

            if (prefs1.GetString("locale", "") == "")
            {
                editor1.PutString("locale", "en");
                editor1.Apply();
            }
            string loc    = prefs1.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;
            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_workplace_parameters);

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

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;


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

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

            APIClient apiClient = new APIClient();
            ObservableCollection <Equipment> equipmentList = await apiClient.GetEquipmentsListAsync();

            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            if (prefs.GetString("searchingViewModel", "") == "")
            {
                searchingViewModel                = new SearchingViewModel();
                searchingViewModel.X              = 33;
                searchingViewModel.Y              = 33;
                searchingViewModel.Radius         = 500;
                searchingViewModel.WantedCost     = 500;
                searchingViewModel.SearchingModel = new ObservableCollection <SearchingModel>();
                for (int i = 0; i < equipmentList.Count; i++)
                {
                    SearchingModel searchingModel = new SearchingModel();
                    searchingModel.EquipmentId = equipmentList[i].Id;
                    searchingModel.Importancy  = 0;
                    searchingViewModel.SearchingModel.Add(searchingModel);
                }
            }
            else
            {
                searchingViewModel            = JsonConvert.DeserializeObject <SearchingViewModel>(prefs.GetString("searchingViewModel", ""));
                searchingViewModel.Radius     = (searchingViewModel.Radius == null) ? 500 : searchingViewModel.Radius;
                searchingViewModel.WantedCost = (searchingViewModel.WantedCost == null) ? 500 : searchingViewModel.WantedCost;
            }

            radiusEditText      = FindViewById <EditText>(Resource.Id.radius_edit_text);
            radiusEditText.Text = searchingViewModel.Radius.ToString();
            costEditText        = FindViewById <EditText>(Resource.Id.cost_edit_text);
            costEditText.Text   = searchingViewModel.WantedCost.ToString();

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            LinearLayout linearLayout = FindViewById <LinearLayout>(Resource.Id.worplace_p);
            LinearLayout.LayoutParams layoutParamsLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            layoutParamsLayout.Gravity = GravityFlags.Left;

            for (int i = 0; i < equipmentList.Count; i++)
            {
                LinearLayout newLayout = new LinearLayout(this)
                {
                    LayoutParameters = layoutParamsLayout,
                    Orientation      = Orientation.Horizontal
                };
                TextView textView = new TextView(this)
                {
                    Text = equipmentList[i].Name
                };
                textView.SetTextAppearance(Resource.Style.TextAppearance_AppCompat_Medium);
                RatingBar ratingBar = new RatingBar(this)
                {
                    NumStars         = 5,
                    Rating           = (int)(searchingViewModel.SearchingModel[i].Importancy * 5),
                    LayoutParameters = layoutParams,
                    StepSize         = 1,
                    Id = i
                };

                TextView cross = new TextView(this)
                {
                    LayoutParameters = layoutParams,
                    Id = i + 100
                };
                cross.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Mipmap.cancel, 0);

                linearLayout.AddView(textView);
                newLayout.AddView(ratingBar);
                newLayout.AddView(cross);

                linearLayout.AddView(newLayout);

                ratingBar.RatingBarChange += (o, e) => {
                    Toast.MakeText(this, "New Rating: " + ratingBar.Rating.ToString(), ToastLength.Short).Show();
                    searchingViewModel.SearchingModel[ratingBar.Id].Importancy = Math.Round(ratingBar.Rating * 0.2, 2);
                };
                cross.Click += (o, e) => {
                    searchingViewModel.SearchingModel[ratingBar.Id].Importancy = 0;
                    ratingBar.FindViewById <RatingBar>(cross.Id - 100).Rating  = 0;
                };
            }
        }
 /// <summary>
 /// Set a Boolean value in the mPreferences
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 public void PutBoolean(string key, bool value)
 {
     _editor.PutBoolean(ToKey(key), value);
     _editor.Apply();
 }
Esempio n. 5
0
        private async void Signupbtn_Click(object sender, EventArgs e)
        {
            string             nametext, mobiletext, emailtext, passtext, cnfpasstext;
            InputMethodManager inputManager = (InputMethodManager)GetSystemService(InputMethodService);

            inputManager.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);
            nametext    = name.Text;
            mobiletext  = mobile.Text;
            emailtext   = email.Text;
            passtext    = password.Text;
            cnfpasstext = conpass.Text;
            if (!checkEmpty(nametext, "Name"))
            {
                return;
            }
            else if (!checkEmpty(mobiletext, "Phone number"))
            {
                return;
            }
            else if (!checkEmpty(emailtext, "Email"))
            {
                return;
            }
            else if (!checkEmpty(passtext, "Password"))
            {
                return;
            }
            else if (!checkEmpty(cnfpasstext, "Confirm Password"))
            {
                return;
            }
            else
            {
                if (isNameVaid(nametext) && isMobileValid(mobiletext) && isEmailValid(emailtext) && areTermsAccepted() && isPassValid(passtext) && checkPassValidity(passtext, cnfpasstext))
                {
                    mLoadingDialog.Show();
                    CabsAPI        api      = new CabsAPI();
                    SignupResponse response = await api.RegisterUser(nametext, emailtext, mobiletext, passtext);

                    if (response.Code == Utils.ResponseCode.SUCCESS)
                    {
                        mLoadingDialog.Dismiss();
                        mEditor.PutString("email", emailtext);
                        mEditor.PutString("mobile", mobiletext);
                        mEditor.PutString("name", nametext);
                        mEditor.PutString("token", response.Token);
                        mEditor.PutBoolean("isLoggedIn", true);
                        mEditor.Apply();
                        mTextToSpeech = new TextToSpeech(this, this, "com.google.android.tts");
                        //  new TextToSpeech(con, this, "com.google.android.tts");
                        lang = Java.Util.Locale.Default;
                        //setting language , pitch and speed rate to the voice
                        mTextToSpeech.SetLanguage(lang);
                        mTextToSpeech.SetPitch(1f);
                        mTextToSpeech.SetSpeechRate(1f);
                        mContext = signupbtn.Context;
                        mTextToSpeech.Speak(mSucLog, QueueMode.Flush, null, null);
                        StartActivity(new Intent(this, typeof(NavigationActivity)));

                        Finish();
                    }
                    else if (response.Code == Utils.ResponseCode.MYSQL_DUPLICATES)
                    {
                        mLoadingDialog.Dismiss();
                        Toast.MakeText(this, "User with same number is already present", ToastLength.Short).Show();
                        mobile.Text = "";
                    }
                    else
                    {
                        mLoadingDialog.Dismiss();
                        Toast.MakeText(this, "Server Error Try Again!", ToastLength.Short).Show();
                    }
                }
            }
        }
Esempio n. 6
0
        private void SetTypeFace()
        {
            Typeface tf            = Typeface.CreateFromAsset(Assets, "Fonts/ROBOTO-LIGHT.TTF");
            EditText txtclientname = FindViewById <EditText>(Resource.Id.txtbarClientName);

            txtclientname.Typeface = tf;
            txtclientname.Invalidate();

            EditText txtprojectname = FindViewById <EditText>(Resource.Id.txtbarProjectname);

            txtprojectname.Typeface = tf;
            txtprojectname.Invalidate();

            EditText txtlocation = FindViewById <EditText>(Resource.Id.txtbarLocation);

            txtlocation.Typeface = tf;
            txtlocation.Invalidate();
            txtlocation.SetText(locationname, TextView.BufferType.Editable);
            EditText txtquantity = FindViewById <EditText>(Resource.Id.txtbarquantity);

            txtquantity.Typeface = tf;
            txtquantity.Invalidate();

            EditText txtUnitCost = FindViewById <EditText>(Resource.Id.txtbarunitcost);

            txtUnitCost.Typeface = tf;
            txtUnitCost.Invalidate();

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

            lblbluetoothscan.Typeface = tf;
            lblbluetoothscan.Invalidate();

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

            lblscanbarcode.Typeface = tf;
            lblscanbarcode.Invalidate();

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

            txtbaritemname.Typeface = tf;
            txtbaritemname.Invalidate();

            //Typeface tfArial = Typeface.CreateFromAsset (Assets, "Fonts/ARIALBOLD.TTF");
            EditText txtbarcodenumber = FindViewById <EditText>(Resource.Id.txtbarbarcodenumber);

            //txtbarcodenumber.Typeface = tfArial;
            //txtbarcodenumber.Invalidate ();

            txtlocation.TextChanged += delegate
            {
                editor.PutString("LocationName", txtlocation.Text);
                editor.Commit();
            };

            txtprojectname.SetText(projectname, TextView.BufferType.Editable);
            txtclientname.SetText(clientname, TextView.BufferType.Editable);

            Switch       swscanbluetooth    = FindViewById <Switch>(Resource.Id.swscanbluetooth);
            ImageView    imgscanbarcode     = FindViewById <ImageView>(Resource.Id.imgScanBarcode);
            LinearLayout llscanbarcode      = FindViewById <LinearLayout>(Resource.Id.llscanbarcode);
            LinearLayout llafterscanbarcode = FindViewById <LinearLayout>(Resource.Id.llafterscan);

            imgscanbarcode.Click += async(sender, e) =>
            {
                try
                {
                    // if (AccessBarCodeScan.Trim() == "1")
                    //  {

                    // var options = new ZXing.Mobile.MobileBarcodeScanningOptions();
                    scanner = new ZXing.Mobile.MobileBarcodeScanner(this);
                    // scanner.FlashButtonText = "On Flash";
                    // scanner.Torch(true);
                    if (IMApplication.camera != null)
                    {
                        IMApplication.camera.Release();
                        IMApplication.camera = null;
                    }

                    var result = await scanner.Scan();

                    if (result != null)
                    {
                        llafterscanbarcode.Visibility = ViewStates.Visible;
                        llscanbarcode.Visibility      = ViewStates.Gone;
                        txtbarcodenumber.SetText(result.Text, TextView.BufferType.Editable);

                        AlertVibrate = prefs.GetInt("AlertVibrate", 0);
                        AlertTone    = prefs.GetInt("AlertTone", 0);
                        // Vibrate Device
                        if (AlertVibrate == 1)
                        {
                            VibrateDevice();
                        }
                        // Play tone
                        if (AlertTone == 1)
                        {
                            PlayNitificationTone();
                        }
                    }
                    // }
                    //  else {
                    // OpenInAppPurchasePopUp();
                    //  }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Something went wrong. Please try back in few minutes.", ToastLength.Short).Show();
                }
            };

            ImageView imgScanBarcodeSmall = FindViewById <ImageView>(Resource.Id.imgScanBarcodeSmall);

            imgScanBarcodeSmall.Click += delegate
            {
                try
                {
                    llafterscanbarcode.Visibility = ViewStates.Gone;
                    llscanbarcode.Visibility      = ViewStates.Visible;
                    txtbarcodenumber.SetText("", TextView.BufferType.Editable);
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Something went wrong. Please try back in few minutes.", ToastLength.Short).Show();
                }
            };

            swscanbluetooth.CheckedChange += delegate(object sender, CompoundButton.CheckedChangeEventArgs e)
            {
                try
                {
                    bool boolchecked = e.IsChecked;
                    if (boolchecked)
                    {
                        BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter;

                        if (adapter == null)
                        {
                            Toast.MakeText(this, "No Bluetooth adapter found.", ToastLength.Long).Show();
                        }
                        if (!adapter.IsEnabled)
                        {
                            //throw new Exception("Bluetooth adapter is not enabled.");
                            Toast.MakeText(this, "Bluetooth adapter is not enabled. TurningOn Bluetooth ", ToastLength.Long).Show();
                            adapter.Enable();
                            llafterscanbarcode.Visibility = ViewStates.Visible;
                            llscanbarcode.Visibility      = ViewStates.Gone;
                            txtbarcodenumber.RequestFocus();
                        }
                        else
                        {
                            llafterscanbarcode.Visibility = ViewStates.Visible;
                            llscanbarcode.Visibility      = ViewStates.Gone;
                            txtbarcodenumber.RequestFocus();
                        }
                    }
                    else
                    {
                        llafterscanbarcode.Visibility = ViewStates.Gone;
                        llscanbarcode.Visibility      = ViewStates.Visible;
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Something went wrong. Please try back in few minutes.", ToastLength.Short).Show();
                }
            };

            _fab.Click += delegate
            {
                try
                {
                    SaveDataToLocalDataBase();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Something went wrong. Please try back in few minutes.", ToastLength.Short).Show();
                }
            };
            _fabbacktolist.Click += delegate
            {
                try
                {
                    txtquantity        = FindViewById <EditText>(Resource.Id.txtbarquantity);
                    txtUnitCost        = FindViewById <EditText>(Resource.Id.txtbarunitcost);
                    txtbarcodenumber   = FindViewById <EditText>(Resource.Id.txtbarbarcodenumber);
                    txtbaritemname     = FindViewById <EditText>(Resource.Id.txtbaritemname);
                    llscanbarcode      = FindViewById <LinearLayout>(Resource.Id.llscanbarcode);
                    llafterscanbarcode = FindViewById <LinearLayout>(Resource.Id.llafterscan);
                    txtquantity.SetText("", TextView.BufferType.Editable);
                    txtUnitCost.SetText("", TextView.BufferType.Editable);
                    txtbarcodenumber.SetText("", TextView.BufferType.Editable);
                    txtbaritemname.SetText("", TextView.BufferType.Editable);
                    llafterscanbarcode.Visibility = ViewStates.Gone;
                    llscanbarcode.Visibility      = ViewStates.Visible;
                    EditInventoryID = "";
                    editor.PutString("EditFromItemListForBarcode", "");
                    editor.Commit();
                    editor.Apply();
                    StartActivity(typeof(LocationList));
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Something went wrong. Please try back in few minutes.", ToastLength.Short).Show();
                }
            };
            if (EditInventoryID.Trim() != "")
            {
                PopulateDataFromDatabase(EditInventoryID);
            }
        }
Esempio n. 7
0
        void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            var listView = sender as ListView;
            var t        = tableItems [e.Position];

            if (t.ClientName.Trim() != "")
            {
                if (projectid != Convert.ToInt64(t.ProjectID))
                {
                    editor.PutString("LocationName", "");
                }
                editor.PutLong("ProjectID", Convert.ToInt64(t.ProjectID));
                editor.PutString("ProjectName", t.Projectname);
                editor.PutString("ClientName", t.ClientName);
                editor.PutString("EditFromItemList", "");
                editor.PutString("EditFromItemListForBarcode", "");
                editor.PutInt("FromVoiceEdit", 0);
                editor.Commit();
                // applies changes synchronously on older APIs
                editor.Apply();
                InventoryType = prefs.GetLong("InventoryType", 0);
                if (InventoryType > 0)
                {
                    ICursor c1 = db.RawQuery("SELECT * FROM " + "tbl_Inventory WHERE ProjectID = " + t.ProjectID, null);
                    try{
                        if (c1.Count > 0)
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(this);
                            builder.SetMessage("Please select from the following options");
                            builder.SetCancelable(false);
                            builder.SetPositiveButton("Location List", (object buildersender, DialogClickEventArgs ev) => {
                                StartActivity(typeof(LocationList));
                            });
                            builder.SetNegativeButton("Add Item", (object buildersender, DialogClickEventArgs ev) => {
                                this.Finish();
                                StartActivity(typeof(EntryTab));
                            });
                            AlertDialog alertdialog = builder.Create();
                            alertdialog.Show();
                        }
                        else
                        {
                            this.Finish();
                            StartActivity(typeof(EntryTab));
                        }
                    }
                    catch {
                        Toast.MakeText(this, "Something error happend. Pls try again later", ToastLength.Short).Show();
                    }
                }
                else
                {
                    ICursor c1 = db.RawQuery("SELECT * FROM " + "tbl_Inventory WHERE ProjectID = " + t.ProjectID, null);
                    try{
                        editor = prefs.Edit();
                        editor.PutLong("InventoryType", 1);
                        editor.Commit();
                        if (c1.Count > 0)
                        {
                            AlertDialog.Builder builder = new AlertDialog.Builder(this);
                            builder.SetMessage("Please select from the following options");
                            builder.SetCancelable(false);
                            builder.SetPositiveButton("Location List", (object buildersender, DialogClickEventArgs ev) => {
                                StartActivity(typeof(LocationList));
                            });
                            builder.SetNegativeButton("Add Item", (object buildersender, DialogClickEventArgs ev) => {
                                this.Finish();
                                StartActivity(typeof(EntryTab));
                            });
                            AlertDialog alertdialog = builder.Create();
                            alertdialog.Show();
                        }
                        else
                        {
                            this.Finish();
                            StartActivity(typeof(EntryTab));
                        }
                    }
                    catch {
                        Toast.MakeText(this, "Something error happend. Pls try again later", ToastLength.Short).Show();
                    }
                }
            }
            //dialog.Dismiss();
            //Android.Widget.Toast.MakeText(this, t.Projectname, Android.Widget.ToastLength.Short).Show();
        }
Esempio n. 8
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.SetTripName);


            Button okButton = FindViewById <Button>(Resource.Id.SetTripName_okButton);
            var    entry    = FindViewById <EditText>(Resource.Id.SetTripName_editText1);

            okButton.Click += (s, e) =>
            {
                var regexAlphanumeric = new System.Text.RegularExpressions.Regex("^[a-zA-Z0-9 ]*$");
                var regexNumeric      = new System.Text.RegularExpressions.Regex("^[0-9 ]*$");

                if (entry.Text.Length > 0)
                {
                    if (regexAlphanumeric.IsMatch(entry.Text))
                    {
                        if (regexNumeric.IsMatch(entry.Text[0].ToString()) == false)
                        {
                            try
                            {
                                lastSavedTripName = entry.Text;


                                var dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Trips.db");

                                var connection = new SQLiteConnection(dbPath);

                                var table = connection.Table <Trip>();

                                int count = 0;

                                foreach (var item in table)
                                {
                                    if (item.TripName == lastSavedTripName)
                                    {
                                        count++;
                                    }
                                }


                                if (count < 1)
                                {
                                    pref     = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private);
                                    prefEdit = pref.Edit();

                                    prefEdit.PutString("lastSavedTripName", lastSavedTripName);
                                    prefEdit.PutBoolean("procedeSave", true);
                                    prefEdit.Apply();

                                    base.OnBackPressed();
                                }

                                else
                                {
                                    Toast.MakeText(this, String.Format("Trip Name Already Exists"), ToastLength.Long).Show();
                                }
                            }

                            catch { Toast.MakeText(this, String.Format("Name Format Error"), ToastLength.Long).Show(); }
                        }//(regexNumeric.IsMatch(entry.Text[0].ToString()) == false)

                        else
                        {
                            Toast.MakeText(this, String.Format("First Character Cannot Be a Number"), ToastLength.Long).Show();
                        }
                    }//(regexItem.IsMatch(entry.Text))

                    else
                    {
                        Toast.MakeText(this, String.Format("Please Use Only Alpha and Numeric Characters"), ToastLength.Long).Show();
                    }
                }//if(entry.Text.Length > 0)

                else
                {
                    Toast.MakeText(this, String.Format("Trip Name Cannot be Empty"), ToastLength.Long).Show();
                }
            };
        }
Esempio n. 9
0
        public void SaveChanges()
        {
            var properties = GetType().GetProperties();

            foreach (var prop in properties)
            {
                var attribute = (PreferenceAttribute)prop.GetCustomAttributes(typeof(PreferenceAttribute), false).First();
                switch (prop.GetValue(this))
                {
                case string str:
                    edit.PutString(attribute.Key, str);
                    break;

                case ICollection <string> strs:
                    edit.PutStringSet(attribute.Key, strs);
                    break;

                case bool b:
                    edit.PutBoolean(attribute.Key, b);
                    break;

                case float f:
                    edit.PutFloat(attribute.Key, f);
                    break;

                case int i:
                    edit.PutInt(attribute.Key, i);
                    break;

                case long l:
                    edit.PutLong(attribute.Key, l);
                    break;

                case object o:
                    edit.PutString(attribute.Key, JsonConvert.SerializeObject(o));
                    break;
                }
            }
            var fields = GetType().GetFields();

            foreach (var field in fields)
            {
                var attribute = (PreferenceAttribute)field.GetCustomAttributes(typeof(PreferenceAttribute), false).First();
                switch (field.GetValue(this))
                {
                case string str:
                    edit.PutString(attribute.Key, str);
                    break;

                case ICollection <string> strs:
                    edit.PutStringSet(attribute.Key, strs);
                    break;

                case bool b:
                    edit.PutBoolean(attribute.Key, b);
                    break;

                case float f:
                    edit.PutFloat(attribute.Key, f);
                    break;

                case int i:
                    edit.PutInt(attribute.Key, i);
                    break;

                case long l:
                    edit.PutLong(attribute.Key, l);
                    break;

                case object o:
                    edit.PutString(attribute.Key, JsonConvert.SerializeObject(o));
                    break;
                }
            }
            edit.Apply();
        }
Esempio n. 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            Intent arrivalActivity = new Intent(this, typeof(ArrivalActivity));

            btnSubmit    = FindViewById <Button>(Resource.Id.btnSubmit);
            inputHours   = FindViewById <EditText>(Resource.Id.inputHours);
            inputMinutes = FindViewById <EditText>(Resource.Id.inputMinutes);
            inputLength  = FindViewById <EditText>(Resource.Id.inputLength);

            btnSubmit.Click += delegate
            {
                ISharedPreferencesEditor editor = prefs.Edit();
                editor.PutString("hours", inputHours.Text);
                editor.PutString("minutes", inputMinutes.Text);
                editor.PutString("length", inputLength.Text);

                //write key pairs to SP
                editor.Apply();
                StartActivity(arrivalActivity);
            };

            inputHours.TextChanged += delegate
            {
                try
                {
                    if (int.Parse(inputHours.Text.ToString()) > 23)
                    {
                        Toast.MakeText(this, "Hours must be equal to 23 or smaller", ToastLength.Short).Show();
                    }
                }
                catch (Exception e)
                {
                }
            };

            inputMinutes.TextChanged += delegate
            {
                try
                {
                    if (int.Parse(inputMinutes.Text.ToString()) > 59)
                    {
                        Toast.MakeText(this, "Minutes must be equal to 59 or smaller", ToastLength.Short).Show();
                    }
                }
                catch (Exception e)
                {
                }
            };

            inputLength.TextChanged += delegate
            {
                try
                {
                    if (int.Parse(inputLength.Text.ToString()) > 1500)
                    {
                        Toast.MakeText(this, "Length must be equal to 1500 or smaller", ToastLength.Short).Show();
                    }
                }
                catch (Exception e)
                {
                }
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                ISharedPreferences       sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(this);
                ISharedPreferencesEditor editorDevis       = sharedPreferences.Edit();

                base.OnCreate(savedInstanceState);

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

                SetSupportActionBar(toolbar);
                //SupportActionBar.SetDisplayHomeAsUpEnabled(true);
                //SupportActionBar.SetHomeButtonEnabled(true);
                toolbar.SetTitleTextColor(Android.Graphics.Color.Rgb(0, 250, 154));
                toolbar.SetBackgroundColor(Android.Graphics.Color.Rgb(27, 49, 71));
                toolbar.Title = "Information Bancaire";

                nombanque = FindViewById <EditText>(Resource.Id.textInputEditTextNombanque);
                Bic       = FindViewById <EditText>(Resource.Id.textInputEditTextBIC);
                IBAN      = FindViewById <EditText>(Resource.Id.textInputEditTextIBAN);

                ad1 = FindViewById <AdView>(Resource.Id.adView1banqe);
                ad2 = FindViewById <AdView>(Resource.Id.adView2banqe);

                devisespinner = FindViewById <Spinner>(Resource.Id.spinnerDevis);

                var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.Devise, Android.Resource.Layout.SimpleSpinnerItem);
                adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

                devisespinner.Adapter       = adapter;
                devisespinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);
                buttonsuivantbanque         = FindViewById <Button>(Resource.Id.buttonsuivantbbanque);

                var btnp = FindViewById <Button>(Resource.Id.buttonPrecedant);


                nombanque.Text = sharedPreferences.GetString("Nombanque", "");
                Bic.Text       = sharedPreferences.GetString("Bic", "");
                IBAN.Text      = sharedPreferences.GetString("IBAN", "");

                int d = adapter.GetPosition(sharedPreferences.GetString("Devis", ""));

                devisespinner.SetSelection(d);
                btnp.Click += delegate
                {
                    Intent intent = new Intent(this, typeof(CreationClient1));
                    editorDevis.PutString("Nom", sharedPreferences.GetString("Nom", ""));
                    editorDevis.PutString("Email", sharedPreferences.GetString("Email", ""));
                    editorDevis.PutString("Tel", sharedPreferences.GetString("Tel", ""));
                    editorDevis.PutString("Adresse", sharedPreferences.GetString("Adresse", ""));
                    editorDevis.PutString("CodePostal", sharedPreferences.GetString("CodePostal", ""));
                    editorDevis.PutString("Ville", sharedPreferences.GetString("Ville", ""));
                    editorDevis.PutString("Pays", sharedPreferences.GetString("Pays", ""));

                    editorDevis.PutString("Nombanque", nombanque.Text);
                    editorDevis.PutString("Bic", Bic.Text);
                    editorDevis.PutString("IBAN", IBAN.Text);
                    editorDevis.PutString("Devise", toast);
                    editorDevis.Apply();
                    StartActivity(intent);
                };

                buttonsuivantbanque.Click += delegate
                {
                    editorDevis.PutString("Nom", sharedPreferences.GetString("Nom", ""));
                    editorDevis.PutString("Email", sharedPreferences.GetString("Email", ""));
                    editorDevis.PutString("Tel", sharedPreferences.GetString("Tel", ""));
                    editorDevis.PutString("Adresse", sharedPreferences.GetString("Adresse", ""));
                    editorDevis.PutString("CodePostal", sharedPreferences.GetString("CodePostal", ""));
                    editorDevis.PutString("Ville", sharedPreferences.GetString("Ville", ""));
                    editorDevis.PutString("Pays", sharedPreferences.GetString("Pays", ""));

                    editorDevis.PutString("Nombanque", nombanque.Text);
                    editorDevis.PutString("Bic", Bic.Text);
                    editorDevis.PutString("IBAN", IBAN.Text);
                    editorDevis.PutString("Devise", toast);
                    editorDevis.Apply();

                    Intent intent = new Intent(this, typeof(CreationClient3));

                    StartActivity(intent);
                };
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
            }

            // Create your application here
        }
Esempio n. 12
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("OTg5ODlAMzEzNzJlMzEyZTMwUG5ONWFZZmdORDJldFd2ZUFIM0QzVWxjWWdGSFlkWW9TMTBZTytvbElzND0=");


            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            if (prefs.GetString("locale", "") == "")
            {
                editor.PutString("locale", "en");
                editor.Apply();
            }
            string loc    = prefs.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;

            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;

            //ObservableCollection<Client> lst =  await apiClient.GetClientsListAsync();

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

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

            //Button loginSendButton = FindViewById<Button>(Resource.Id.loginSendButton);

            //loginSendButton.Click += async (s, arg) =>
            //{
            //    CredentialsViewModel credentialViewModel = new CredentialsViewModel();

            //    var loginEditText = FindViewById<EditText>(Resource.Id.loginEditText);
            //    credentialViewModel.UserName = loginEditText.Text;

            //    var passwordEditText = FindViewById<EditText>(Resource.Id.passwordEditText);
            //    credentialViewModel.Password = passwordEditText.Text;

            //    apiClient = new APIClient();

            //    string token = await apiClient.Post2Async(credentialViewModel);

            //    ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            //    ISharedPreferencesEditor editor = prefs.Edit();
            //    editor.PutString("auth_token", token);
            //    editor.Apply();

            //    // var intent = new Intent(this, typeof(HomeActivity));
            //    //StartActivity(intent);
            //    TextView loginTextView = FindViewById<TextView>(Resource.Id.loginTextView);
            //    loginTextView.Text = token;


            //};
        }
Esempio n. 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Options);

            _bannerad        = BannerAdWrapper.ConstructStandardBanner(this, AdSize.LargeBanner, "ca-app-pub-6665335742989505/9551542272");
            _bannerad.Bottom = 0;
            _bannerad.CustomBuild();
            var layout = FindViewById <LinearLayout>(Resource.Id.options_LinearLayout1);

            layout.AddView(_bannerad);

            pref     = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private);
            prefEdit = pref.Edit();

            enableStops  = pref.GetBoolean("enableStops", true);
            showKMs      = pref.GetBoolean("showKMs", true);
            portraitView = pref.GetBoolean("portraitView", true);

            SetRadioButtons();

            RadioButton kilometersRadioButton   = FindViewById <RadioButton>(Resource.Id.options_KilometersRadioButton);
            RadioButton milesRadioButton        = FindViewById <RadioButton>(Resource.Id.options_MilesRadioButton);
            RadioButton enableStopsRadioButton  = FindViewById <RadioButton>(Resource.Id.options_EnableStopsRadioButton);
            RadioButton disableStopsRadioButton = FindViewById <RadioButton>(Resource.Id.options_DisableStopsRadioButton);
            RadioButton portraitRadioButton     = FindViewById <RadioButton>(Resource.Id.options_PortraitRadioButton);
            RadioButton landscapeRadioButton    = FindViewById <RadioButton>(Resource.Id.options_LandscapeRadioButton);



            kilometersRadioButton.Click += (sender, e) =>
            {
                prefEdit.PutBoolean("showKMs", true);
                prefEdit.Apply();
            };

            milesRadioButton.Click += (sender, e) =>
            {
                prefEdit.PutBoolean("showKMs", false);
                prefEdit.Apply();
            };


            enableStopsRadioButton.Click += (sender, e) =>
            {
                prefEdit.PutBoolean("enableStops", true);
                prefEdit.Apply();
                Toast.MakeText(this, "Changes Made to Stops Will Only Affect New Trips", ToastLength.Short).Show();
            };


            disableStopsRadioButton.Click += (sender, e) =>
            {
                prefEdit.PutBoolean("enableStops", false);
                prefEdit.Apply();
                Toast.MakeText(this, "Changes Made to Stops Will Only Affect New Trips", ToastLength.Short).Show();
            };


            portraitRadioButton.Click += (sender, e) =>
            {
                prefEdit.PutBoolean("portraitView", true);
                prefEdit.Apply();
                Toast.MakeText(this, "Changes Made to Screen Orientation Won't Affect Started Trips", ToastLength.Short).Show();
                prefEdit.PutBoolean("changeOrientation", true);
                prefEdit.Apply();
            };


            landscapeRadioButton.Click += (sender, e) =>
            {
                prefEdit.PutBoolean("portraitView", false);
                prefEdit.Apply();
                Toast.MakeText(this, "Changes Made to Screen Orientation Won't Affect Started Trips", ToastLength.Short).Show();
                prefEdit.PutBoolean("changeOrientation", true);
                prefEdit.Apply();
            };
        }//OnCreate()
Esempio n. 14
0
        private void ListItemClicked(int position)
        {
            Android.Support.V4.App.Fragment fragment = null;
            switch (position)
            {
            case 0:
                fragment = new HomeFragment();
                break;

            case 1:
                fragment = new ProfileFragment();
                break;

            case 2:
                fragment = new PaymentFragment();
                break;

            case 3:
                fragment = new FAQFragment();
                break;

            case 4:
                fragment = new ContactUSFragment();
                break;

            case 5:
                new Android.Support.V7.App.AlertDialog.Builder(this)
                .SetIcon(Resource.Drawable.ic_alert)
                .SetTitle("Closing Activity")
                .SetMessage("Are you sure you want to Log Out?")
                .SetPositiveButton("Yes", (c, ev) =>
                {
                    ISharedPreferences pref       = Application.Context.GetSharedPreferences("UserInfo", FileCreationMode.Private);
                    ISharedPreferencesEditor edit = pref.Edit();
                    edit.PutString("Username", String.Empty);
                    edit.PutBoolean("SignedIn", false);
                    edit.Apply();
                    var activity = (Activity)this;
                    activity.FinishAffinity();
                })
                .SetNegativeButton("No", (c, ev) => { })
                .Show();
                break;

            case 6:
                fragment = new CurrentOrderFragment();
                break;

            case 7:
                fragment = new MyOrdersFragment();
                break;

            case 8:
                fragment = new MakeARequestFragment();
                break;
            }
            if (fragment != null)
            {
                SupportFragmentManager.BeginTransaction()
                .Replace(Resource.Id.content_frame, fragment)
                .Commit();
            }
        }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.PersonalData);
                edit_city_coord_for_edit = city_coord_for_edit_prefs.Edit();
                nameET             = FindViewById <EditText>(Resource.Id.nameET);
                last_nameET        = FindViewById <EditText>(Resource.Id.last_nameET);
                patronimicET       = FindViewById <EditText>(Resource.Id.patronimicET);
                emailET            = FindViewById <EditText>(Resource.Id.emailET);
                phoneET            = FindViewById <EditText>(Resource.Id.phoneET);
                cityTV             = FindViewById <TextView>(Resource.Id.cityTV);
                saveBn             = FindViewById <Button>(Resource.Id.saveBn);
                mainRL             = FindViewById <RelativeLayout>(Resource.Id.mainRL);
                backRelativeLayout = FindViewById <RelativeLayout>(Resource.Id.backRelativeLayout);
                back_button        = FindViewById <ImageButton>(Resource.Id.back_button);
                coordinatesTV      = FindViewById <TextView>(Resource.Id.coordinatesTV);
                activityIndicator  = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                singleDataScrollView            = FindViewById <ScrollView>(Resource.Id.singleDataScrollView);
                back_button.Click              += (s, e) => { OnBackPressed(); };
                backRelativeLayout.Click       += (s, e) => { OnBackPressed(); };
                activityIndicator.Visibility    = Android.Views.ViewStates.Visible;
                singleDataScrollView.Visibility = Android.Views.ViewStates.Gone;
                saveBn.Visibility               = Android.Views.ViewStates.Gone;
                var user_data = await profileAndExpertMethodsPCL.UserProfileData(userMethods.GetUsersAuthToken());

                if (user_data == "401")
                {
                    Toast.MakeText(this, Resource.String.you_not_logined, ToastLength.Long).Show();
                    userMethods.ClearTable();
                    userMethods.ClearUsersDataTable();
                    userMethods.ClearTableNotif();
                    StartActivity(typeof(MainActivity));
                    return;
                }
                activityIndicator.Visibility    = Android.Views.ViewStates.Gone;
                singleDataScrollView.Visibility = Android.Views.ViewStates.Visible;
                saveBn.Visibility = Android.Views.ViewStates.Visible;

                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                FindViewById <TextView>(Resource.Id.headerTV).SetTypeface(tf, TypefaceStyle.Bold);
                FindViewById <TextView>(Resource.Id.removeBn).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textViesw2).SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textVssiew2).SetTypeface(tf, TypefaceStyle.Normal);
                nameET.SetTypeface(tf, TypefaceStyle.Normal);
                last_nameET.SetTypeface(tf, TypefaceStyle.Normal);
                patronimicET.SetTypeface(tf, TypefaceStyle.Normal);
                cityTV.SetTypeface(tf, TypefaceStyle.Normal);
                coordinatesTV.SetTypeface(tf, TypefaceStyle.Normal);
                saveBn.SetTypeface(tf, TypefaceStyle.Normal);
                emailET.SetTypeface(tf, TypefaceStyle.Normal);
                phoneET.SetTypeface(tf, TypefaceStyle.Normal);

                try
                {
                    var deserialized_user_data = JsonConvert.DeserializeObject <UserProfile>(user_data);
                    try
                    {
                        string[] words = deserialized_user_data.fullName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        nameET.Text       = words[0];
                        patronimicET.Text = words[1];
                        last_nameET.Text  = words[2];
                        edit_city_coord_for_edit.PutString("surname", words[2]);
                        edit_city_coord_for_edit.PutString("name", words[0]);
                        edit_city_coord_for_edit.PutString("middlename", words[1]);
                    }
                    catch { }
                    emailET.Text = userMethods.GetUsersEmail();
                    phoneET.Text = deserialized_user_data.phone;
                    cityTV.Text  = deserialized_user_data.city.name;
                    edit_city_coord_for_edit.PutString("city_id", deserialized_user_data.city.id);
                    edit_city_coord_for_edit.PutString("city_name", deserialized_user_data.city.name);
                    edit_city_coord_for_edit.PutString("lat", deserialized_user_data.coordinates.latitude);
                    edit_city_coord_for_edit.PutString("lng", deserialized_user_data.coordinates.longitude);
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data.coordinates.latitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lat", pref.GetString("latitude", String.Empty));
                        }
                    }
                    catch { }
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data.coordinates.longitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lng", pref.GetString("longitude", String.Empty));
                        }
                    }
                    catch { }
                    edit_city_coord_for_edit.PutString("phone", deserialized_user_data.phone);
                    edit_city_coord_for_edit.PutString("email", userMethods.GetUsersEmail());
                    edit_city_coord_for_edit.Apply();
                }
                catch
                {
                    deserialized_user_data_categs_empty = JsonConvert.DeserializeObject <UserProfileServiceCategoriesEmpty>(user_data);
                    try
                    {
                        string[] words = deserialized_user_data_categs_empty.fullName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        nameET.Text       = words[0];
                        patronimicET.Text = words[1];
                        last_nameET.Text  = words[2];
                        edit_city_coord_for_edit.PutString("surname", words[2]);
                        edit_city_coord_for_edit.PutString("name", words[0]);
                        edit_city_coord_for_edit.PutString("middlename", words[1]);
                    }
                    catch { }
                    emailET.Text = userMethods.GetUsersEmail();
                    phoneET.Text = deserialized_user_data_categs_empty.phone;
                    cityTV.Text  = deserialized_user_data_categs_empty.city.name;
                    edit_city_coord_for_edit.PutString("city_id", deserialized_user_data_categs_empty.city.id);
                    edit_city_coord_for_edit.PutString("city_name", deserialized_user_data_categs_empty.city.name);
                    edit_city_coord_for_edit.PutString("lat", deserialized_user_data_categs_empty.coordinates.latitude);
                    edit_city_coord_for_edit.PutString("lng", deserialized_user_data_categs_empty.coordinates.longitude);
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data_categs_empty.coordinates.latitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lat", pref.GetString("latitude", String.Empty));
                        }
                    }
                    catch { }
                    try
                    {
                        if (Convert.ToInt32(deserialized_user_data_categs_empty.coordinates.longitude) == 0)
                        {
                            edit_city_coord_for_edit.PutString("lng", pref.GetString("longitude", String.Empty));
                        }
                    }
                    catch { }
                    edit_city_coord_for_edit.PutString("phone", deserialized_user_data_categs_empty.phone);
                    edit_city_coord_for_edit.PutString("email", userMethods.GetUsersEmail());
                    edit_city_coord_for_edit.Apply();
                }
                FindViewById <RelativeLayout>(Resource.Id.cityRL).Click += (s, e) =>
                {
                    StartActivity(typeof(CountryForProfileCityActivity));
                };
                FindViewById <RelativeLayout>(Resource.Id.locationRL).Click += (s, e) =>
                {
                    StartActivity(typeof(NewProfileCoordsMapActivity));
                };
                saveBn.Click += async(s, e) =>
                {
                    if (
                        !String.IsNullOrEmpty(last_nameET.Text) &&
                        !String.IsNullOrEmpty(nameET.Text) &&
                        !String.IsNullOrEmpty(phoneET.Text) &&
                        !String.IsNullOrEmpty(patronimicET.Text) &&
                        !String.IsNullOrEmpty(emailET.Text))
                    {
                        activityIndicator.Visibility    = Android.Views.ViewStates.Visible;
                        singleDataScrollView.Visibility = Android.Views.ViewStates.Gone;
                        saveBn.Visibility = Android.Views.ViewStates.Gone;
                        var res = await profileAndExpertMethods.EditMyProfileInfo(
                            userMethods.GetUsersAuthToken(),
                            phoneET.Text,
                            emailET.Text,
                            last_nameET.Text,
                            nameET.Text,
                            patronimicET.Text,
                            city_coord_for_edit_prefs.GetString("city_id", String.Empty),
                            city_coord_for_edit_prefs.GetString("lat", String.Empty),
                            city_coord_for_edit_prefs.GetString("lng", String.Empty));

                        activityIndicator.Visibility    = Android.Views.ViewStates.Gone;
                        singleDataScrollView.Visibility = Android.Views.ViewStates.Visible;
                        saveBn.Visibility = Android.Views.ViewStates.Visible;
                        if (res.Contains("с таким email уже"))
                        {
                            Toast.MakeText(this, GetString(Resource.String.email_already_exists), ToastLength.Short).Show();
                        }
                        else if (res.Contains("или неверно заполнен те"))
                        {
                            Toast.MakeText(this, GetString(Resource.String.wrong_phone), ToastLength.Short).Show();
                        }
                        else
                        {
                            ISharedPreferences       pref = Application.Context.GetSharedPreferences("reg_data", FileCreationMode.Private);
                            ISharedPreferencesEditor edit = pref.Edit();
                            edit.PutString("surname", "");
                            edit.PutString("name", "");
                            edit.PutString("patronymic", "");
                            edit.PutString("phone", "");
                            edit.PutString("email", "");
                            edit.Apply();
                            var token = JsonConvert.DeserializeObject <SingleToken>(res).authToken;
                            userMethods.InsertUser(token, emailET.Text);

                            StartActivity(typeof(UserProfileActivity));
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, GetString(Resource.String.fill_all_entries), ToastLength.Short).Show();
                    }
                };
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }
    public void OnSharedPreferenceChanged(ISharedPreferences prefs, string key)
    {
        MainActivity parentActivity = (MainActivity)Activity;

        if (key.CompareTo(Resources.GetString(Resource.String.pref_key)) == 0)
        {
            ListPreference connectionPref = (ListPreference)FindPreference(key);
            Log.Debug(TAG, "Template PreferenceChanged: " + connectionPref.Value);
            parentActivity.localSettings.selectedFileIndex = int.Parse(connectionPref.Value);
            connectionPref.Summary = connectionPref.Entry;
            //save last template used

            /*ISharedPreferences iprefs = null;
             * iprefs.Edit();
             * iprefs = (ISharedPreferences)prefs.PutInt(SETTINGS_LAST_TEMPLATE_POS, parentActivity.localSettings.selectedFileIndex);
             * prefs.Apply();*/

            ISharedPreferencesEditor editor = (ISharedPreferencesEditor)prefs.Edit();
            editor.PutInt(SETTINGS_LAST_TEMPLATE_POS, parentActivity.localSettings.selectedFileIndex);
            editor.Apply();
        }
        else if (key.CompareTo("timeout_identification") == 0)
        {
            EditTextPreference connectionPref = (EditTextPreference)FindPreference(key);
            Log.Debug(TAG, "Identification PreferenceChanged: " + connectionPref.Text);

            int idto = parentActivity.localSettings.identificationTimeout;

            try {
                idto = int.Parse(connectionPref.Text);
                if (idto < 5000)
                {
                    idto = 5000;
                }
            }
            catch (IllegalFormatException ex)
            {
                Log.Error(TAG, "Invalid identification timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid identification timeout value", ToastLength.Long).Show();
            }
            catch (System.OverflowException ex)
            {
                Log.Error(TAG, "Invalid identification timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid identification timeout value", ToastLength.Long).Show();
            }

            connectionPref.Text = idto.ToString();
            parentActivity.localSettings.identificationTimeout = idto;
        }
        else if (key.CompareTo("timeout_processing") == 0)
        {
            EditTextPreference connectionPref = (EditTextPreference)FindPreference(key);
            Log.Debug(TAG, "Processing PreferenceChanged: " + connectionPref.Text);

            int processingTimeout = parentActivity.localSettings.processingTimeout;;

            try
            {
                processingTimeout = int.Parse(connectionPref.Text);
            }
            catch (IllegalFormatException ex)
            {
                Log.Error(TAG, "Invalid processing timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid processing timeout value", ToastLength.Long).Show();
            }
            catch (System.OverflowException ex)
            {
                Log.Error(TAG, "Invalid processing timeout exception: " + ex.Message);
                Toast.MakeText(parentActivity.ApplicationContext, "Invalid processing timeout value", ToastLength.Long).Show();
            }
            connectionPref.Text = processingTimeout.ToString();
            parentActivity.localSettings.processingTimeout = processingTimeout;
        }
        else if (key.CompareTo("ui_result_confirmation") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "result confrmation PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableResultConfirmation = connectionPref.Checked;
        }
        else if (key.CompareTo("auto_capture") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Auto capture PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableAutoCapture = connectionPref.Checked;
        }
        else if (key.CompareTo("debug") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Debug PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableDebugMode = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_audio") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Audio PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableFeedbackAudio = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_haptic") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "Haptic PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableHaptic = connectionPref.Checked;
        }
        else if (key.CompareTo("feedback_led") == 0)
        {
            CheckBoxPreference connectionPref = (CheckBoxPreference)FindPreference(key);
            Log.Debug(TAG, "LED PreferenceChanged: " + connectionPref.Checked);
            parentActivity.localSettings.enableLED = connectionPref.Checked;
        }
    }
Esempio n. 17
0
 private void GoVendorSelect()
 {
     editor.PutInt(Const.KOSU_MENU_FLAG, (int)Const.KOSU_MENU.VENDOR);
     editor.Apply();
     StartFragment(FragmentManager, typeof(TsumikaeIdouMotoFragment));
 }
Esempio n. 18
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            try
            {
                SetContentView(Resource.Layout.Filter);

                expert_data        = Application.Context.GetSharedPreferences("experts", FileCreationMode.Private);
                edit_expert        = expert_data.Edit();
                recyclerView       = FindViewById <RecyclerView>(Resource.Id.recyclerView);
                layoutManager      = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false);
                findBn             = FindViewById <Button>(Resource.Id.findBn);
                resetBn            = FindViewById <Button>(Resource.Id.resetBn);
                backRelativeLayout = FindViewById <RelativeLayout>(Resource.Id.backRelativeLayout);
                distanceRL         = FindViewById <RelativeLayout>(Resource.Id.distanceRL);
                back_button        = FindViewById <ImageButton>(Resource.Id.back_button);
                cancellationBn     = FindViewById <Button>(Resource.Id.cancellationBn);
                city_value         = FindViewById <TextView>(Resource.Id.city_value);
                distance_value     = FindViewById <TextView>(Resource.Id.distance_value);
                inform_processTV   = FindViewById <TextView>(Resource.Id.inform_processTV);
                distanceSB         = FindViewById <SeekBar>(Resource.Id.distanceSB);
                onlyWithReviewsS   = FindViewById <Switch>(Resource.Id.onlyWithReviewsS);
                activityIndicator  = FindViewById <ProgressBar>(Resource.Id.activityIndicator);
                city_chooseLL      = FindViewById <LinearLayout>(Resource.Id.city_chooseLL);
                activityIndicator.IndeterminateDrawable.SetColorFilter(Resources.GetColor(Resource.Color.buttonBackgroundColor), Android.Graphics.PorterDuff.Mode.Multiply);
                SpecializationMethods specializationMethods = new SpecializationMethods();
                recyclerView.SetLayoutManager(layoutManager);
                Typeface tf = Typeface.CreateFromAsset(Assets, "Roboto-Regular.ttf");
                FindViewById <TextView>(Resource.Id.headerTV).SetTypeface(tf, TypefaceStyle.Bold);
                resetBn.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textView1).SetTypeface(tf, TypefaceStyle.Normal);
                city_value.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textViesw1).SetTypeface(tf, TypefaceStyle.Normal);
                distance_value.SetTypeface(tf, TypefaceStyle.Normal);
                FindViewById <TextView>(Resource.Id.textVsiew1).SetTypeface(tf, TypefaceStyle.Normal);
                inform_processTV.SetTypeface(tf, TypefaceStyle.Normal);
                findBn.SetTypeface(tf, TypefaceStyle.Normal);
                cancellationBn.SetTypeface(tf, TypefaceStyle.Normal);

                backRelativeLayout.Click += (s, e) =>
                {
                    OnBackPressed();
                };
                back_button.Click += (s, e) =>
                {
                    OnBackPressed();
                };

                if (String.IsNullOrEmpty(expert_data.GetString("expert_city_name", String.Empty)))
                {
                    city_value.Text = GetString(Resource.String.not_chosen);
                }
                else
                {
                    city_value.Text = expert_data.GetString("expert_city_name", String.Empty);
                    resetBn.Enabled = true;
                    resetBn.SetTextColor(Android.Graphics.Color.White);
                }

                if (String.IsNullOrEmpty(expert_data.GetString("distance_radius", String.Empty)))
                {
                    distance_value.Text = "100 " + GetString(Resource.String.km);
                    distanceSB.Progress = 100;
                }
                else
                {
                    distance_value.Text = expert_data.GetString("distance_radius", String.Empty);
                    distanceSB.Progress = Convert.ToInt32(expert_data.GetString("distance_radius", String.Empty));
                    resetBn.Enabled     = true;
                    resetBn.SetTextColor(Android.Graphics.Color.White);
                }
                if (expert_data.GetBoolean("has_reviews", false) == false)
                {
                    onlyWithReviewsS.Checked = false;
                }
                else
                {
                    onlyWithReviewsS.Checked = true;
                    resetBn.Enabled          = true;
                    resetBn.SetTextColor(Android.Graphics.Color.White);
                }

                distanceSB.ProgressChanged += async(s, e) =>
                {
                    if (!reset_pressed)
                    {
                        resetBn.Enabled = true;
                        resetBn.SetTextColor(Android.Graphics.Color.White);
                    }
                    if (e.Progress == 0)
                    {
                        distance_value.Text = "0.5" + " " + GetString(Resource.String.km);
                    }
                    else
                    {
                        distance_value.Text = e.Progress.ToString() + " " + GetString(Resource.String.km);
                    }

                    if (e.Progress == 0)
                    {
                        edit_expert.PutString("distance_radius", "0.5");
                    }
                    else
                    {
                        edit_expert.PutString("distance_radius", e.Progress.ToString());
                    }
                    edit_expert.Apply();
                    findBn.Visibility            = ViewStates.Gone;
                    activityIndicator.Visibility = ViewStates.Visible;
                    inform_processTV.Visibility  = ViewStates.Visible;
                    inform_processTV.Text        = "Получение количества специалистов";
                    var filtered = await specializationMethods.ExpertCount(
                        expert_data.GetString("spec_id", String.Empty),
                        expert_data.GetString("expert_city_id", String.Empty),
                        expert_data.GetString("distance_radius", String.Empty),
                        expert_data.GetBoolean("has_reviews", false),
                        pref.GetString("latitude", String.Empty),
                        pref.GetString("longitude", String.Empty));

                    var deserialized_value = JsonConvert.DeserializeObject <ExpertCount>(filtered.ToString());
                    activityIndicator.Visibility = ViewStates.Gone;
                    findBn.Visibility            = ViewStates.Visible;
                    inform_processTV.Visibility  = ViewStates.Gone;
                    findBn.Text   = "Показать " + deserialized_value.count.ToString() + " специалистов";
                    reset_pressed = false;
                };

                onlyWithReviewsS.CheckedChange += async(s, e) =>
                {
                    if (!reset_pressed)
                    {
                        resetBn.Enabled = true;
                        resetBn.SetTextColor(Android.Graphics.Color.White);
                    }
                    if (onlyWithReviewsS.Checked)
                    {
                        edit_expert.PutBoolean("has_reviews", true);
                    }
                    else
                    {
                        edit_expert.PutBoolean("has_reviews", false);
                    }
                    edit_expert.Apply();
                    findBn.Visibility            = ViewStates.Gone;
                    activityIndicator.Visibility = ViewStates.Visible;
                    inform_processTV.Visibility  = ViewStates.Visible;
                    inform_processTV.Text        = "Получение количества специалитов";
                    var filtered = await specializationMethods.ExpertCount(
                        expert_data.GetString("spec_id", String.Empty),
                        expert_data.GetString("expert_city_id", String.Empty),
                        expert_data.GetString("distance_radius", String.Empty),
                        expert_data.GetBoolean("has_reviews", false),
                        pref.GetString("latitude", String.Empty),
                        pref.GetString("longitude", String.Empty)
                        );

                    var deserialized_value = JsonConvert.DeserializeObject <ExpertCount>(filtered.ToString());
                    activityIndicator.Visibility = ViewStates.Gone;
                    findBn.Visibility            = ViewStates.Visible;
                    inform_processTV.Visibility  = ViewStates.Gone;
                    findBn.Text   = "Показать " + deserialized_value.count.ToString() + " специалистов";
                    reset_pressed = false;
                };
                city_value.Click += async(s, e) =>
                {
                    findBn.Visibility            = ViewStates.Gone;
                    activityIndicator.Visibility = ViewStates.Visible;
                    inform_processTV.Visibility  = ViewStates.Visible;
                    inform_processTV.Text        = GetString(Resource.String.getting_cities);
                    var cities = await specializationMethods.GetCities();

                    city_chooseLL.Visibility = ViewStates.Visible;
                    var deserialized_cities = JsonConvert.DeserializeObject <List <City> >(cities.ToString());
                    var listOfCitiesAdapter = new CityAdapter(deserialized_cities, this, tf);
                    recyclerView.SetAdapter(listOfCitiesAdapter);
                };
                cancellationBn.Click += (s, e) =>
                {
                    city_chooseLL.Visibility    = ViewStates.Gone;
                    inform_processTV.Visibility = ViewStates.Gone;
                    findBn.Visibility           = ViewStates.Visible;
                };
                findBn.Click += (s, e) =>
                {
                    StartActivity(typeof(ListOfSpecialistsActivity));
                };
                resetBn.Click += (s, e) =>
                {
                    city_chooseLL.Visibility = ViewStates.Gone;
                    reset_pressed            = true;
                    resetBn.Enabled          = false;
                    resetBn.SetTextColor(new Color(ContextCompat.GetColor(this, Resource.Color.lightBlueColor)));
                    distanceRL.Visibility = ViewStates.Visible;
                    distance_value.Text   = "100 " + GetString(Resource.String.km);
                    distanceSB.Progress   = 100;
                    //setting values to default
                    edit_expert.PutString("expert_city_id", "");
                    edit_expert.PutString("expert_city_name", "");
                    edit_expert.PutString("distance_radius", "");
                    edit_expert.PutBoolean("has_reviews", false);
                    edit_expert.Apply();
                    city_value.Text          = GetString(Resource.String.not_chosen);
                    onlyWithReviewsS.Checked = false;
                };
            }
            catch
            {
                StartActivity(typeof(MainActivity));
            }
        }
Esempio n. 19
0
        private void getempxml(object sender, GetEmpDetailsByEmpIDCompletedEventArgs e)
        {
            try
            {
                DataSet ds       = new DataSet();
                string  innerxml = e.Result.InnerXml.ToString();
                innerxml = "<ds><table1>" + innerxml + "</table1></ds>";
                DataTable dataTable = new DataTable("table1");
                dataTable.Columns.Add("EmpID", typeof(string));
                dataTable.Columns.Add("Name", typeof(string));
                dataTable.Columns.Add("Email", typeof(string));
                dataTable.Columns.Add("Company", typeof(string));
                dataTable.Columns.Add("IsInternal", typeof(string));
                dataTable.Columns.Add("UserType", typeof(string));
                dataTable.Columns.Add("Device", typeof(string));
                dataTable.Columns.Add("UserPlan", typeof(string));
                dataTable.Columns.Add("StripeSubscriptionID", typeof(string));
                dataTable.Columns.Add("AccessFindITExport", typeof(string));
                dataTable.Columns.Add("AccessBarCodeScan", typeof(string));
                dataTable.Columns.Add("AccessExport", typeof(string));
                dataTable.Columns.Add("UploadedSize", typeof(string));
                ds.Tables.Add(dataTable);
                System.IO.StringReader xmlSR = new System.IO.StringReader(innerxml);
                ds.ReadXml(xmlSR, XmlReadMode.IgnoreSchema);
                dataTable = ds.Tables[0];
                int    empid                = Convert.ToInt16(dataTable.Rows[0]["EmpID"]);
                int    isinternal           = Convert.ToInt16(dataTable.Rows[0]["IsInternal"]);
                int    UserType             = Convert.ToInt16(dataTable.Rows[0]["UserType"]);
                string UserPlans            = Convert.ToString(dataTable.Rows[0]["UserPlan"]);
                string StripeSubscriptionID = Convert.ToString(dataTable.Rows[0]["StripeSubscriptionID"]);
                string AccessFindITExports  = Convert.ToString(dataTable.Rows[0]["AccessFindITExport"]);
                string AccessBarCodeScans   = Convert.ToString(dataTable.Rows[0]["AccessBarCodeScan"]);
                string AccessExports        = Convert.ToString(dataTable.Rows[0]["AccessExport"]);
                string UploadedSize         = Convert.ToString(dataTable.Rows[0]["UploadedSize"]);
                if (empid > 0)
                {
                    //Toast.MakeText (this, "Your successfully log in", ToastLength.Short).Show ();
                    //dialog.Hide();
                    ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(this);
                    ISharedPreferencesEditor editor = prefs.Edit();
                    //editor.Clear();
                    AccessExport = AccessExports;
                    //AccessBarCodeScan = AccessBarCodeScans;
                    AccessFindITExport = AccessFindITExports;
                    editor.PutLong("EmpID", empid);
                    editor.PutLong("IsInternal", isinternal);
                    editor.PutString("UserPlan", UserPlan);
                    editor.PutLong("UserType", UserType);
                    editor.PutString("StripeSubscriptionID", StripeSubscriptionID);
                    editor.PutString("AccessFindITExport", AccessFindITExports);
                    editor.PutString("AccessBarCodeScan", AccessBarCodeScan);
                    editor.PutString("AccessExport", AccessExports);
                    editor.PutString("UploadedSize", UploadedSize);
                    editor.Commit();
                    // applies changes synchronously on older APIs
                    editor.Apply();
                    UserPlan           = UserPlans;
                    AccessExport       = AccessExports;
                    AccessFindITExport = AccessFindITExports;
                    AccessBarCodeScan  = AccessBarCodeScans;
                    //Toast.MakeText (this, isinternal.ToString(), ToastLength.Long).Show ();
                    //EditText txtusername = FindViewById<EditText> (Resource.Id.txtUserName);
                    //txtusername.Text="";

                    //EditText txtpassword = FindViewById<EditText> (Resource.Id.txtPassword);
                    //txtpassword.Text="";

                    //StartActivity(typeof(Main));
                }
                else
                {
                    //dialog.Hide();

                    Toast.MakeText(this, "Something went wrong. Please try back in few minutes.", ToastLength.Short).Show();
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Something went wrong. Please try back in few minutes.", ToastLength.Short).Show();
            }
        }
Esempio n. 20
0
 public static void SaveUserName(string UserName, string UserId)
 {
     _edit.PutString("UserName", UserName);
     _edit.PutString("UserId", UserId);
     _edit.Apply();
 }
Esempio n. 21
0
        // 積込完了時に生成されるファイル(納品で使います。)
        private void CreateTsumiFiles()
        {
            string souko_cd      = prefs.GetString("souko_cd", "");
            string kitaku_cd     = prefs.GetString("kitaku_cd", "");
            string syuka_date    = prefs.GetString("syuka_date", "");
            string tokuisaki_cd  = prefs.GetString("tokuisaki_cd", "");
            string todokesaki_cd = prefs.GetString("todokesaki_cd", "");
            string bin_no        = prefs.GetString("bin_no", "");
            string course        = prefs.GetString("course", "");

            // CRATE TUMIKOMI FILE
            // MAIN FILE
            List <MFile> mFiles = WebService.RequestTumikomi100(souko_cd, kitaku_cd, syuka_date, bin_no, course, tokuisaki_cd, todokesaki_cd);

            new MFileHelper().InsertALL(mFiles);

            // It would be useless..
            //PsFile psFile = WebService.RequestTumikomi180();
            PsFile psFile = new PsFile {
                pass = ""
            };

            new PsFileHelper().Insert(psFile);

            // MAILBACK FILE
            List <MbFile> mbFiles = WebService.RequestTumikomi140(souko_cd, kitaku_cd, syuka_date, bin_no, course);

            new MbFileHelper().InsertAll(mbFiles);

            // SOUKO FILE
            SoFile soFile = WebService.RequestTumikomi160(souko_cd);

            new SoFileHelper().Insert(soFile);

            // VENDOR FILE
            List <MateFile> mateFile = WebService.RequestTumikomi260();

            new MateFileHelper().InsertAll(mateFile);

            // TOKUISAKI FILE
            List <TokuiFile> tokuiFile = WebService.RequestTumikomi270();

            new TokuiFileHelper().InsertAll(tokuiFile);

            Log.Debug(TAG, "CreateTsumiFiles end");

            Dictionary <string, string> param = new Dictionary <string, string>
            {
                { "pTerminalID", prefs.GetString("terminal_id", "") },
                { "pProgramID", "TUM" },
                { "pSagyosyaCD", prefs.GetString("sagyousya_cd", "") },
                { "pSoukoCD", souko_cd },
                { "pSyukaDate", syuka_date },
                { "pBinNo", bin_no },
                { "pCourse", course },
                { "pTokuisakiCD", tokuisaki_cd },
                { "pTodokesakiCD", todokesaki_cd },
                { "pHHT_No", prefs.GetString("hht_no", "") }
            };

            //配車テーブルの該当コースの各数量を実績数で更新する
            var updateResult = WebService.CallTumiKomiProc("210", param);

            if (updateResult.poRet == "0" || updateResult.poRet == "99")
            {
                editor.PutBoolean("tenpo_zan_flg", updateResult.poRet == "99" ? true : false);
                editor.Apply();

                Activity.RunOnUiThread(() =>
                {
                    //	正常登録
                    ShowDialog("報告", "積込検品が\n完了しました。", () => {
                        FragmentManager.PopBackStack(FragmentManager.GetBackStackEntryAt(0).Id, 0);
                    });
                });
            }
            else
            {
                ShowDialog("エラー", "表示データがありません", () => {});
                return;
            }
        }
Esempio n. 22
0
        public LoginPageRenderer()
        {
            var activity = this.Context as Activity;

            prefs  = PreferenceManager.GetDefaultSharedPreferences(Forms.Context);
            editor = prefs.Edit();

            // On Android:
            accounts = AccountStore.Create(Forms.Context).FindAccountsForService("Facebook");

            //se existir uma conta armazenada fazemos o login, se nao somos redirecionados para a tela de login
            if (accounts.Count() > 0)
            {
                var enumerable = accounts as IList <Account> ?? accounts.ToList();
                facebook = enumerable.First();

                VerificaUser();
            }
            else
            {
                var auth = new OAuth2Authenticator(
                    clientId: "1028244680574076",              // your OAuth2 client id
                    scope: "user_friends",                     // the scopes for the particular API you're accessing, delimited by "+" symbols
                    authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"),
                    redirectUrl: new Uri("https://www.facebook.com/connect/login_success.html"));


                auth.Completed += async(sender, eventArgs) =>
                {
                    if (eventArgs.IsAuthenticated)
                    {
                        // On Android:
                        AccountStore.Create(Forms.Context).Save(eventArgs.Account, "Facebook");

                        var parameters = new Dictionary <string, string>();
                        //parameters.Add("fields", "friends{id,name,picture{url}},id,name,picture{url}");
                        parameters.Add("fields", "id,name,picture.type(large),friends{id,name,picture.type(large){url}}");

                        //var accessToken = eventArgs.Account.Properties ["access_token"].ToString ();
                        //var expiresIn = Convert.ToDouble (eventArgs.Account.Properties ["expires_in"]);
                        //var expiryDate = DateTime.Now + TimeSpan.FromSeconds (expiresIn);

                        var request  = new OAuth2Request("GET", new Uri("https://graph.facebook.com/me"), parameters, eventArgs.Account);
                        var response = await request.GetResponseAsync();

                        var obj = JObject.Parse(response.GetResponseText());

                        var picture = obj["picture"].ToString();
                        var friends = obj["friends"].ToString();
                        var id      = obj["id"].ToString().Replace("\"", "");
                        var nome    = obj["name"].ToString().Replace("\"", "");

                        var obj_friends   = JObject.Parse(friends);
                        var lista_friends = obj_friends["data"].ToString();

                        var obj_picture  = JObject.Parse(picture);
                        var picture_data = obj_picture["data"].ToString();

                        var obj_picture2 = JObject.Parse(picture_data);
                        var picture_url  = obj_picture2["url"].ToString();

                        //adicionamos os dados do usuario recem logado no objeto
                        eu = new Usuario
                        {
                            id_usuario   = id,
                            nome_usuario = nome,
                            url_img      = picture_url,
                        };

                        var usu = JsonConvert.DeserializeObject <List <Amigos> >(lista_friends);

                        editor.PutString("usu_id_face", id);
                        editor.PutString("usu_nome", nome);
                        editor.PutString("usu_picture", picture_url);
                        // editor.Commit();    // applies changes synchronously on older APIs
                        editor.Apply();                          // applies changes asynchronously on newer APIs

                        //string token_gcm = prefs.GetString ("token_gcm","");

                        //fazemos verificaçao do play service e registro do GCM
                        VerifyPlayServices verify = new VerifyPlayServices();
                        verify.IsPlayServicesAvailable();

                        //friends.
                        await App.NavigateToLista(eu, usu);
                    }
                    else
                    {
                        await App.NavigateToLista(null, null);
                    }
                };
                activity.StartActivity(auth.GetUI(activity));
            }
        }
Esempio n. 23
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            if (prefs.GetString("locale", "") == "")
            {
                editor.PutString("locale", "en");
                editor.Apply();
            }
            string loc    = prefs.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;
            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_buildings);

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

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;


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

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

            apiClient = new APIClient();
            buildings = await apiClient.GetBuildingsListAsync();

            workplaces = await apiClient.GetWorkplacesListAsync();

            workplacesList = workplaces.ToList();

            LinearLayout linearLayout = FindViewById <LinearLayout>(Resource.Id.lay_build);

            //foreach (Building building in buildings)
            //{
            //    TextView buildTextView = new TextView(this);
            //    buildTextView.Text = "Address: " + building.Country + ", " + building.City + ", " + building.Street + ", "
            //        + building.House.ToString() + ", " + building.Flat.ToString();
            //    Landlord landlord = await apiClient.GetLandlordByIdAsync((int)building.LandlordId);
            //    buildTextView.Text += "\nLandlord: " + landlord.FirstName + " " + landlord.LastName
            //        + "\n Phone: " + landlord.Phone.ToString() + "\n Email: " + landlord.Email;
            //    linearLayout.AddView(buildTextView);
            //}

            Button          search      = FindViewById <Button>(Resource.Id.search_button);
            EditText        editCountry = FindViewById <EditText>(Resource.Id.country_edit_text);
            EditText        editCity    = FindViewById <EditText>(Resource.Id.city_edit_text);
            EditText        editStreet  = FindViewById <EditText>(Resource.Id.street_edit_text);
            EditText        editHouse   = FindViewById <EditText>(Resource.Id.house_edit_text);
            EditText        editFlat    = FindViewById <EditText>(Resource.Id.flat_edit_text);
            int             flat        = 0;
            List <Building> resultList  = new List <Building>(buildings).ToList();

            search.Click += async(s, arg) =>
            {
                linearLayout.RemoveAllViews();
                if (editCountry.Text != "")
                {
                    resultList = resultList.Where(x => x.Country == editCountry.Text).ToList();
                }
                if (editCity.Text != "")
                {
                    resultList = resultList.Where(x => x.City == editCity.Text).ToList();
                }
                if (editStreet.Text != "")
                {
                    resultList = resultList.Where(x => x.Street == editStreet.Text).ToList();
                }
                if (editHouse.Text != "")
                {
                    resultList = resultList.Where(x => x.House == editHouse.Text).ToList();
                }
                if (int.TryParse(editFlat.Text, out flat) && flat > 0)
                {
                    resultList = resultList.Where(x => x.Flat == flat).ToList();
                }

                foreach (var item in resultList)
                {
                    TextView buildTextView = new TextView(this);
                    buildTextView.Text = "Address: " + item.Country + ", " + item.City + ", " + item.Street + ", "
                                         + item.House.ToString() + ", " + item.Flat.ToString();
                    Landlord lord = await apiClient.GetLandlordByIdAsync((int)item.LandlordId);

                    buildTextView.Text += "\nLandlord: " + lord.FirstName + " " + lord.LastName
                                          + "\n Phone: " + lord.Phone.ToString() + "\n Email: " + lord.Email;
                    buildTextView.Id = (int)item.Id;
                    linearLayout.AddView(buildTextView);

                    buildTextView.Click += (s1, arg1) =>
                    {
                        List <Workplace> wokpl = workplacesList.Where(x => x.BuildingId == buildTextView.Id).ToList();
                        PopupMenu        menu  = new PopupMenu(this, buildTextView);
                        foreach (var work in wokpl)
                        {
                            menu.Menu.Add(work.Mark.ToString() + "," + work.Id.ToString());
                        }

                        menu.MenuItemClick += async(s2, arg2) =>
                        {
                            string                   workplaceString = arg2.Item.TitleFormatted.ToString();
                            int                      workplaceId     = int.Parse(workplaceString.Split(',')[1]);
                            ISharedPreferences       prefs1          = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                            ISharedPreferencesEditor editor1         = prefs1.Edit();

                            editor1.PutString("workplaceId", workplaceId.ToString());
                            editor1.Apply();

                            var intent = new Intent(this, typeof(WorkplaceActivity));
                            StartActivity(intent);
                        };
                        menu.Show();
                    };
                }
            };
        }
Esempio n. 24
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.ChuckALuckScreen);

            int match = 0;

            var numberResult1 = FindViewById <TextView> (Resource.Id.numberResult1);
            var numberResult2 = FindViewById <TextView> (Resource.Id.numberResult2);
            var numberResult3 = FindViewById <TextView> (Resource.Id.numberResult3);

            var matchText         = FindViewById <TextView> (Resource.Id.matchText);
            var errorText         = FindViewById <TextView> (Resource.Id.errorText);
            var currentAmountText = FindViewById <TextView> (Resource.Id.currentAmountText);

            var currentAmount = FindViewById <EditText> (Resource.Id.currentAmount);
            var userInput     = FindViewById <EditText> (Resource.Id.userInput);
            var betAmount     = FindViewById <EditText> (Resource.Id.betAmount);

            userInput.Text = "Input:1-6";

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

            numberResult1.TextSize = 110;
            numberResult2.TextSize = 110;
            numberResult3.TextSize = 110;
            matchText.TextSize     = 20;

            int currentAmountInt = 0;
            int betAmountInt     = 0;

            int totalAmountLost = 0;
            int totalAmountWon  = 0;
            int totalMatches    = 0;

            int[,] CALDGStats          = new int[6, 6];
            String[,] CALDGStatsString = new string[6, 6];

            for (int i = 0; i < 6; i++)
            {
                CALDGStats [i, 0] = i + 1;
            }

            ISharedPreferences       CALDGPrefs  = GetSharedPreferences(CALDG_DATA, FileCreationMode.Private);
            ISharedPreferencesEditor CALDGEditor = CALDGPrefs.Edit();

            // Roll the dice button
            diceButton.Click += delegate {
                // Check user input
                if ((Int32.TryParse(currentAmount.Text.ToString(), out currentAmountInt)) && (Int32.TryParse(betAmount.Text.ToString(), out betAmountInt)))
                {
                    if (currentAmountInt == 0 && betAmountInt == 0)
                    {
                        Toast.MakeText(this, "Fields are empty", ToastLength.Long).Show();
                    }
                    else if (currentAmountInt == 0)
                    {
                        Toast.MakeText(this, "Total Amount is 0", ToastLength.Long).Show();
                    }
                    else if (betAmountInt == 0)
                    {
                        Toast.MakeText(this, "Bet is 0", ToastLength.Long).Show();
                    }
                    else if (betAmountInt > currentAmountInt)
                    {
                        Toast.MakeText(this, "Bet is bigger than Total Amount", ToastLength.Long).Show();
                    }
                    else
                    {
                        if ((userInput.Text.ToString() == "1") || (userInput.Text.ToString() == "2") || (userInput.Text.ToString() == "3") ||
                            (userInput.Text.ToString() == "4") || (userInput.Text.ToString() == "5") || (userInput.Text.ToString() == "6"))
                        {
                            currentAmount.Enabled   = false;
                            currentAmount.Focusable = false;

                            InputMethodManager closeKeyboard = (InputMethodManager)GetSystemService(Context.InputMethodService);
                            closeKeyboard.HideSoftInputFromWindow(userInput.WindowToken, 0);

                            int userInputInt = Int32.Parse(userInput.Text.ToString());

                            errorText.Text = "";

                            int resultR1 = RandomNumber(1, 6);
                            int resultR2 = RandomNumber(1, 6);
                            int resultR3 = RandomNumber(1, 6);

                            //////////
                            int totalR = resultR1 + resultR2 + resultR3;

                            numberResult1.Text = resultR1.ToString();
                            numberResult2.Text = resultR2.ToString();
                            numberResult3.Text = resultR3.ToString();

                            if (resultR1.ToString() == userInput.Text.ToString())
                            {
                                match         += 1;
                                totalMatches  += 1;
                                matchText.Text = "MATCHES: " + match;
                            }
                            if (resultR2.ToString() == userInput.Text.ToString())
                            {
                                match         += 1;
                                totalMatches  += 1;
                                matchText.Text = "MATCHES: " + match;
                            }
                            if (resultR3.ToString() == userInput.Text.ToString())
                            {
                                match         += 1;
                                totalMatches  += 1;
                                matchText.Text = "MATCHES: " + match;
                            }
                            if (resultR1.ToString() != userInput.Text.ToString() && resultR2.ToString() != userInput.Text.ToString() &&
                                resultR3.ToString() != userInput.Text.ToString())
                            {
                                match          = 0;
                                matchText.Text = "MATCHES: " + match;
                            }
                            if (match == 0)
                            {
                                currentAmountInt  -= betAmountInt;
                                totalAmountLost   += betAmountInt;
                                currentAmount.Text = currentAmountInt.ToString();
                                if (currentAmountInt <= 0)
                                {
                                    currentAmount.Text     = "0";
                                    currentAmountText.Text = "Game Over!";
                                }
                                else
                                {
                                    currentAmountText.Text = currentAmountInt.ToString();
                                }
                            }
                            else
                            {
                                currentAmountInt      += (match * betAmountInt);
                                totalAmountWon        += (match * betAmountInt);
                                currentAmount.Text     = currentAmountInt.ToString();
                                currentAmountText.Text = currentAmountInt.ToString();
                            }

                            // Populate stats
                            for (int i = 0; i < 6; i++)
                            {
                                if (CALDGStats[i, 0] == userInputInt)
                                {
                                    // Latest Amount
                                    CALDGStats[i, 1] = currentAmountInt;
                                    // Latest Bet
                                    CALDGStats[i, 2] = betAmountInt;
                                    // Total Lost for integer user input
                                    CALDGStats[i, 3] = totalAmountLost;
                                    // Total Won for integer user input
                                    CALDGStats[i, 4] = totalAmountWon;
                                    // Total Matches
                                    CALDGStats[i, 5] = totalMatches;
                                }
                            }
                            // Store stats in shared preferences
                            int k = 0;
                            for (int i = 0; i < 6; i++)
                            {
                                for (int j = 0; j < 6; j++)
                                {
                                    CALDGStatsString[i, j] = CALDGStats[i, j].ToString();
                                    CALDGEditor.PutString("CALDGStatsString" + k, CALDGStatsString[i, j]);
                                    k++;
                                }
                            }
                            CALDGEditor.Apply();
                            match = 0;
                        }
                        else
                        {
                            errorText.Text = "Invalid Input! Try Again";
                        }
                    }
                }
                else
                {
                    Toast.MakeText(this, "Invalid Input! Try Again", ToastLength.Long).Show();
                }
            };

            // Gesture Detection
            gestureDetector = new GestureDetector(this);
        }
Esempio n. 25
0
 private void Delete(string key, ISharedPreferencesEditor editor)
 {
     editor.Remove(key);
     editor.Apply();
 }
Esempio n. 26
0
 public static void SaveFullName(string fullname)
 {
     editor = preferences.Edit();
     editor.PutString("fullname", fullname);
     editor.Apply();
 }
Esempio n. 27
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.menu_save)
            {
                int radiusValue = 0;
                int costValue   = 0;
                if (radiusEditText.Text == "" || costEditText.Text == "" || !int.TryParse(radiusEditText.Text, out radiusValue) ||
                    !int.TryParse(costEditText.Text, out costValue) || radiusValue <= 0 || costValue <= 0)
                {
                    Toast.MakeText(this, "Invalid data", ToastLength.Short).Show();
                }
                else
                {
                    searchingViewModel.Radius     = radiusValue;
                    searchingViewModel.WantedCost = costValue;

                    ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                    ISharedPreferencesEditor editor = prefs.Edit();
                    string json = JsonConvert.SerializeObject(searchingViewModel);
                    editor.PutString("searchingViewModel", json);
                    editor.Apply();
                }
                return(true);
            }
            else if (id == Resource.Id.menu_main_logout)
            {
                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                return(true);
            }
            else if (id == Resource.Id.menu_main_lang)
            {
                ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                ISharedPreferencesEditor editor = prefs.Edit();
                if (prefs.GetString("locale", "") == "en")
                {
                    editor.PutString("locale", "uk");
                }
                else
                {
                    editor.PutString("locale", "en");
                }
                editor.Apply();

                string loc    = prefs.GetString("locale", "");
                var    locale = new Java.Util.Locale(loc);
                var    config = new Android.Content.Res.Configuration {
                    Locale = locale
                };
#pragma warning disable CS0618 // Type or member is obsolete
                BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete

                //ava.Util.Locale.Default = locale;
                this.Recreate();
            }

            return(base.OnOptionsItemSelected(item));
        }
Esempio n. 28
0
        private async void OnLoginClicked(object sender, EventArgs e)
        {
            if (!IsInValidInput())
            {
                ConnectivityManager service = (ConnectivityManager)GetSystemService(ConnectivityService);
                NetworkInfo         info    = service.ActiveNetworkInfo;
                if (info != null)
                {
                    HttpClient client    = new HttpClient();
                    var        loginData = new LoginModel
                    {
                        UserName  = etUsername.Text,
                        Password  = etPassword.Text,
                        GrantType = "password"
                    };

                    try
                    {
                        HttpResponseMessage result = await client.PostAsync(CONSTANTS.LOGIN_URL, new FormUrlEncodedContent(loginData.ToDict()));

                        if (result.IsSuccessStatusCode)
                        {
                            string jsonResult = await result.Content.ReadAsStringAsync();

                            // TokenResult is a custom model class for deserialization of the Token Endpoint

                            var resultObject = JsonConvert.DeserializeObject <TokenModel>(jsonResult);


                            client.DefaultRequestHeaders.Add("Authorization", "Bearer" + resultObject.Access_Token);
                            var profile = await client.GetAsync(String.Format(CONSTANTS.GET_USERINFO_URL, resultObject.Access_Token));

                            var jsonProfile = await profile.Content.ReadAsStringAsync();

                            var user = JsonConvert.DeserializeObject <UserInfoModel>(jsonProfile);

                            user.DeviceId = prefs.GetString(CONSTANTS.DEVICEID, "");


                            var model = new DeviceIdModel
                            {
                                UserId   = user.Id,
                                DeviceId = user.DeviceId
                            };


                            await client.PostAsync(CONSTANTS.POST_DEVICEID_URL, new FormUrlEncodedContent(model.ToDict()));

                            prefEditor.PutString(CONSTANTS.AUTH_HEADER, resultObject.Access_Token);
                            prefEditor.PutString(CONSTANTS.USERID, user.Id);
                            prefEditor.PutString(CONSTANTS.USERNAME, user.Username);
                            prefEditor.PutString(CONSTANTS.EMAIL, user.Email);
                            prefEditor.PutInt(CONSTANTS.REGIONID, user.RegionId);
                            prefEditor.PutString(CONSTANTS.DEVICEID, user.DeviceId);
                            prefEditor.PutString(CONSTANTS.FULLNAME, user.Fullname);
                            prefEditor.Apply();

                            //move to discount page
                            Intent intent = new Intent(this, typeof(NavigationDrawerActivity));
                            intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask);
                            StartActivity(intent);
                        }
                        else
                        {
                            Toast.MakeText(this, result.ReasonPhrase, ToastLength.Short).Show();
                        }
                    }
                    catch (Exception ex)
                    {
                        string debugBreak = ex.ToString();
                        Toast.MakeText(this, debugBreak, ToastLength.Short).Show();
                    }
                }
                else
                {
                    Toast.MakeText(this, "Invalid inputs", ToastLength.Short).Show();
                }
            }
            else
            {
                //Snackbar snackBar = Snackbar.Make((Button)sender, "No nternet Connection", Snackbar.LengthIndefinite);
                //Show the snackbar
                // snackBar.Show();
            }
        }
Esempio n. 29
0
 public void SetValue(string key, string value)
 {
     edit.PutString(key, value);
     edit.Apply();
 }
Esempio n. 30
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view   = inflater.Inflate(Resource.Layout.fragment_nohin_kaisyu_matehan, container, false);
            prefs  = PreferenceManager.GetDefaultSharedPreferences(Context);
            editor = prefs.Edit();

            // DB helper
            nohinMateHelper = new SndNohinMateHelper();
            mateFileHelper  = new MateFileHelper();

            // コンポーネント初期化
            SetTitle("マテハン回収");
            SetFooterText("");

            _VendorNameTextView = view.FindViewById <TextView>(Resource.Id.txt_nohinKaisyuMatehan_vendorName);
            matehan1Nm          = view.FindViewById <TextView>(Resource.Id.txt_nohinKaisyuMatehan_matehan1);
            matehan2Nm          = view.FindViewById <TextView>(Resource.Id.txt_nohinKaisyuMatehan_matehan2);
            matehan3Nm          = view.FindViewById <TextView>(Resource.Id.txt_nohinKaisyuMatehan_matehan3);
            matehan4Nm          = view.FindViewById <TextView>(Resource.Id.txt_nohinKaisyuMatehan_matehan4);

            matehan1Su = view.FindViewById <BootstrapEditText>(Resource.Id.et_nohinKaisyuMatehan_matehan1);
            matehan2Su = view.FindViewById <BootstrapEditText>(Resource.Id.et_nohinKaisyuMatehan_matehan2);
            matehan3Su = view.FindViewById <BootstrapEditText>(Resource.Id.et_nohinKaisyuMatehan_matehan3);
            matehan4Su = view.FindViewById <BootstrapEditText>(Resource.Id.et_nohinKaisyuMatehan_matehan4);

            BootstrapButton _ConfirmButton = view.FindViewById <BootstrapButton>(Resource.Id.btn_nohinKaisyuMatehan_confirm);

            _ConfirmButton.Click += delegate { ConfirmMatehanKaisyu(); };

            BootstrapButton _VendorSearchButton = view.FindViewById <BootstrapButton>(Resource.Id.vendorSearch);

            _VendorSearchButton.Click += delegate {
                editor.PutBoolean("kounaiFlag", false);
                editor.Apply();
                StartFragment(FragmentManager, typeof(KosuVendorAllSearchFragment));
            };

            _VendorCdEditText           = view.FindViewById <BootstrapEditText>(Resource.Id.et_nohinKaisyuMatehan_vendorCode);
            _VendorCdEditText.KeyPress += (sender, e) => {
                if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter)
                {
                    e.Handled = true;

                    matehanList = mateFileHelper.SelectByVendorCd(_VendorCdEditText.Text);

                    if (matehanList.Count == 0)
                    {
                        ShowDialog("エラー", "ベンダーコードが存在しません。", () => { _VendorCdEditText.Text = motoVendorCd; _VendorCdEditText.RequestFocus(); });
                        return;
                    }
                    else
                    {
                        SetMateVendorInfo(_VendorCdEditText.Text);
                        motoVendorCd             = _VendorCdEditText.Text;
                        _VendorNameTextView.Text = matehanList[0].vendor_nm;

                        editor.PutString("mate_vendor_cd", _VendorCdEditText.Text);
                        editor.PutString("mate_vendor_nm", matehanList[0].vendor_nm);
                        editor.Apply();
                    }
                }
                else
                {
                    e.Handled = false;
                }
            };

            return(view);
        }