void LoadFragment(int id)
        {
            Android.App.Fragment fragment = null;
            switch (id)
            {
            case Resource.Id.homeIcon:
                fragment = HomeFragment.NewInstance("", "");
                break;

            case Resource.Id.appointmentIcon:
                fragment = AppointmentFragment.NewInstance("", "");
                break;

            case Resource.Id.preorderIcon:
                fragment = PreOrderFragment.NewInstance("", "");
                break;

            case Resource.Id.accountIcon:
                fragment = AccountFragment.NewInstance("", "");
                break;
            }

            if (fragment == null)
            {
                return;
            }

            Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
            transaction.Replace(Resource.Id.frame_container, fragment);
            transaction.AddToBackStack(null);
            transaction.Commit();

            //FragmentManager.BeginTransaction().Replace(Resource.Id.frame_container, fragment).Commit();
        }
        protected override void OnCreate(Bundle bundle)
        {
            // Set our view from the "main" layout resource
            startPostingService();
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            // Initializing Elements
            Initialize();

            // Show the mapFragment
            // fm.BeginTransaction().Show(mapFrag);

            Android.App.FragmentTransaction t = FragmentManager.BeginTransaction();
            t.Show(mapFrag);
            t.Commit();

            // Checking Permissions
            if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) != (int)Permission.Granted)
            {
                RequestLocationPermission();
            }
            else
            {
                mapFrag.GetMapAsync(this);

                // Starting Location Service
                App.StartLocationService();
            }
        }
        /// <summary>
        /// Initiates a map fragment
        /// </summary>
        private void InitMapFragment()
        {
            _locationManager = (LocationManager)GetSystemService(LocationService);

            Criteria criteriaForLocationService = new Criteria
            {
                Accuracy = Accuracy.Fine
            };
            IList <string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

            if (acceptableLocationProviders.Any())
            {
                _locationProvider = acceptableLocationProviders.First();
            }
            else
            {
                _locationProvider = string.Empty;
            }

            _mapFragment = FragmentManager.FindFragmentByTag("map") as MapFragment;
            if (_mapFragment == null)
            {
                GoogleMapOptions mapOptions = new GoogleMapOptions()
                                              .InvokeMapType(GoogleMap.MapTypeNormal)
                                              .InvokeZoomControlsEnabled(true)
                                              .InvokeCompassEnabled(true);

                Android.App.FragmentTransaction fragTx = FragmentManager.BeginTransaction();
                _mapFragment = MapFragment.NewInstance(mapOptions);
                fragTx.Add(Resource.Id.MapFragment, _mapFragment, "map");
                fragTx.Commit();
            }
        }
Exemple #4
0
 private void continueToApplication()
 {
     Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
     transaction.Add(Resource.Id.device_controls, dc);
     transaction.Add(Resource.Id.settings, new SettingsFragment());
     transaction.Commit();
 }
Exemple #5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_main);
            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.main_drawer);

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

            SetSupportActionBar(toolbar);

            var upNavigationEnabled = GetUpNavigationEnabled();

            var actionBar = SupportActionBar;

            if (upNavigationEnabled == true)
            {
            }
            else
            {
                actionBar.SetDisplayHomeAsUpEnabled(false);
                actionBar.SetHomeButtonEnabled(false);
            }

            MenuFragment detailFragment = new MenuFragment();

            Android.App.FragmentTransaction vv = FragmentManager.BeginTransaction();
            vv.Replace(Resource.Id.menu_content_fragment_holder, detailFragment);
            vv.Commit();
        }
Exemple #6
0
        private void ImageButton_Click(object sender, EventArgs e)
        {
            FragmentTransaction    ft             = FragmentManager.BeginTransaction();
            DefectAddImageFragment defectAddImage = DefectAddImageFragment.NewInstance(ref defect);

            ft.Replace(Resource.Id.container1, defectAddImage);
            ft.Commit();
        }
Exemple #7
0
        private void DetailsButton_Click(object sender, EventArgs e)
        {
            FragmentTransaction      ft = FragmentManager.BeginTransaction();
            DefectAddDetailsFragment defectAddDetailsFragment = new DefectAddDetailsFragment();

            ft.Replace(Resource.Id.container1, defectAddDetailsFragment);
            ft.Commit();
        }
        /// <summary>
        /// Adds log fragment
        /// to activity
        /// </summary>
        private void AddLogFragment()
        {
            Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
            LogFragment fragment = new LogFragment();

            transaction.Replace(Resource.Id.framelog, fragment);
            transaction.Commit();
        }
        private async void GetAlarms()
        {
            try
            {
                var o_data = new ServiceResponseObject <ListAlarmResponse>();
                using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
                {
                    AlarmService.InitializeClient(client);
                    o_data = await AlarmService.GetAlarms();

                    if (o_data.Status == HttpStatusCode.OK)
                    {
                        Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                        alarmlist = new List <AlarmBookModel>();

                        if (o_data.ResponseData.ALARMS_STATUS == null ||
                            o_data.ResponseData.ALARMS_STATUS.Count == 0)
                        {
                            StaticUser.NamePadeAbsenceSomething = "AlarmsActivity";
                            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
                            NotFoundOrdersActivity          content     = new NotFoundOrdersActivity();
                            transaction.Replace(Resource.Id.frameDriverlayout, content);
                            transaction.Commit();
                        }

                        foreach (var alm in o_data.ResponseData.ALARMS_STATUS)
                        {
                            alarmlist.Add(new AlarmBookModel
                            {
                                Id           = alm.id,
                                Acknowledged = alm.acknowledged,
                                Container_id = alm.container_id,
                                Name         = alm.name,
                                Raised_At    = alm.raised_at,
                                IsDepot      = (alm.depot == "1") ? true : false
                            }
                                          );
                        }
                        UpdateList();
                        lstAlarm.ItemClick += ListBoxes_ItemClick;
                    }
                    else
                    {
                        StaticUser.NamePadeAbsenceSomething = "AlarmsActivity";
                        Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
                        NotFoundOrdersActivity          content     = new NotFoundOrdersActivity();
                        transaction.Replace(Resource.Id.frameDriverlayout, content);
                        transaction.Commit();
                    }
                }
            }
            catch (System.Exception ex)
            {
                Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show();
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            try
            {
                View view;
                if (StaticUser.PresenceOnPage != true)
                {
                    view = inflater.Inflate(Resource.Layout.activity_not_found_book, container, false);
                    var btn_add_order1 = view.FindViewById <Button>(Resource.Id.btn_add_order1);
                    btn_add_order1.Click += delegate
                    {
                        try
                        {
                            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
                            AddOrderActivity content = new AddOrderActivity();
                            transaction.Replace(Resource.Id.framelayout, content).AddToBackStack(null);
                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            Toast.MakeText(Activity, ex.Message, ToastLength.Long);
                        }
                    };
                    return(view);
                }
                else
                {
                    view      = inflater.Inflate(Resource.Layout.activity_order_book, container, false);
                    lstOrder  = view.FindViewById <ListView>(Resource.Id.orderlistview);
                    orderlist = new List <OrderBookModel>();
                    //начинай тестиьть

                    GetOrders();

                    //editEnterOrder.TextChanged += EtSearch_TextChanged;

                    //int i = 0;
                    //while(i<1)
                    //{
                    //    OrderResponse order = new OrderResponse();
                    //    order = o_date.Rusult;
                    //}
                    //AuthResponseData o_user_data = new AuthResponseData();
                    //o_user_data = o_data.ResponseData;

                    return(view);
                }
            }
            catch (Exception ex)
            {
                var view        = inflater.Inflate(Resource.Layout.activity_errors_handling, container, false);
                var TextOfError = view.FindViewById <TextView>(Resource.Id.TextOfError);
                TextOfError.Text += "\n(Ошибка: " + ex.Message + ")";
                return(view);
            }
        }
Exemple #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            FragmentTransaction ft = FragmentManager.BeginTransaction();

            ft.Replace(Resource.Id.fragment_frame_layout, new MainFragment(), "main");
            ft.Commit();
        }
Exemple #12
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.driver_box_management, container, false);

            Id           = view.FindViewById <TextView>(Resource.Id.TaskManagementTextIdValue1);
            Weight       = view.FindViewById <TextView>(Resource.Id.OrderManagementTexWeight1);
            Temperature  = view.FindViewById <TextView>(Resource.Id.OrderManagementTextTemperature1);
            Battery      = view.FindViewById <TextView>(Resource.Id.OrderManagementTexBattery1);
            Illumination = view.FindViewById <TextView>(Resource.Id.OrderManagementTextIllumination1);
            Humidity     = view.FindViewById <TextView>(Resource.Id.OrderManagementTextHumidity1);
            Gate         = view.FindViewById <TextView>(Resource.Id.OrderManagementTextState1);
            Lock         = view.FindViewById <TextView>(Resource.Id.OrderManagementTextCastle1);
            Fold         = view.FindViewById <TextView>(Resource.Id.OrderManagementTextRoleta1);
            Events       = view.FindViewById <TextView>(Resource.Id.OrderManagementTextEvents1);
            var btn_order = view.FindViewById <Button>(Resource.Id.btn_about_order);

            btn_order.Click += delegate
            {
                try
                {
                    FragmentTransaction     transaction = this.FragmentManager.BeginTransaction();
                    MainOrderStatusActivity content     = new MainOrderStatusActivity();
                    transaction.Replace(Resource.Id.frameDriverlayout, content).AddToBackStack(null).Commit();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Application.Context, ex.Message, ToastLength.Long);
                }
            };

            var result = GetTasks();

            if (result.Result == TaskStatus.OK)
            {
                GetOrderParameters();
            }
            else if (result.Result == TaskStatus.OrderNotImplemented)
            {
                StaticUser.NamePadeAbsenceSomething = "OrderNotFoundForDriver";
                Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                NotFoundOrdersActivity          content      = new NotFoundOrdersActivity();
                transaction1.Replace(Resource.Id.frameDriverlayout, content);
                transaction1.Commit();
            }
            else
            {
                FragmentTransaction  ft  = this.FragmentManager.BeginTransaction();
                TaskNotFoundActivity act = new TaskNotFoundActivity();
                ft.Replace(Resource.Id.frameDriverlayout, act);
                ft.Commit();
            }

            return(view);
        }
Exemple #13
0
        private async void AbortTask()
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                TaskService.InitializeClient(client);
                var o_data = await TaskService.Abort(StaticTask.comment);

                if (o_data.Status == System.Net.HttpStatusCode.OK)
                {
                    //o_data.Message = "Успешно авторизован!";
                    StaticTask.IsStoppedGettingTasks = false;
                    StartUp.StartTracking(context, 1);
                    Toast.MakeText(context, o_data.ResponseData.Message, ToastLength.Long).Show();
                }
                else
                {
                    Toast.MakeText(context, o_data.Message, ToastLength.Long).Show();//"Unexpected character encountered while parsing value: {. Path 'ORDERS[0].last_stage_at', line 2, position 1086."
                }

                TaskActivity act = new TaskActivity();
                manager.Replace(Resource.Id.frameDriverlayout, act);
                manager.Commit();
            }
        }
Exemple #14
0
        //init the map and set its parameters
        public void InitMapFragment()
        {
            mapFragment = FragmentManager.FindFragmentByTag("map") as MapFragment;

            if (mapFragment == null)
            {
                GoogleMapOptions mapOptions = new GoogleMapOptions()
                                              .InvokeMapType(GoogleMap.MapTypeNormal)
                                              .InvokeZoomControlsEnabled(true)
                                              .InvokeCompassEnabled(true);

                Android.App.FragmentTransaction fragTx = FragmentManager.BeginTransaction();
                mapFragment = MapFragment.NewInstance(mapOptions);
                fragTx.Add(Resource.Id.map, mapFragment, "map");
                fragTx.Commit();
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_main);
            layout = FindViewById(Resource.Id.sample_main_layout);

            if (bundle == null)
            {
                Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
                var fragment = new RuntimePermissionsFragment();
                transaction.Replace(Resource.Id.sample_content_fragment, fragment);
                transaction.Commit();
            }

            // This method sets up our custom logger, which will print all log messages to the device
            // screen, as well as to adb logcat.
            InitializeLogging();
        }
Exemple #16
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = LayoutInflater.From(context).Inflate(Resource.Layout.order_book_parameters, null);
            }

            view.FindViewById <TextView>(Resource.Id.txtFrom).Text  = orders[position].Inception;
            view.FindViewById <TextView>(Resource.Id.txtWhere).Text = orders[position].Destination;
            view.FindViewById <TextView>(Resource.Id.txtPrice).Text = orders[position].Price;
            var txt_date = view.FindViewById <TextView>(Resource.Id.txtDate);

            view.FindViewById <TextView>(Resource.Id.txtOrderName).Text = "Заказ: " + orders[position].OrderName;
            var btn = view.FindViewById <Button>(Resource.Id.btn_alarms);

            string date = orders[position].Date;

            string[] words = date.Split(' ');
            txt_date.Text = "";

            foreach (var word in words)
            {
                txt_date.Text += word + "\n";
            }

            btn.Click += delegate
            {
                try
                {
                    MainOrderStatusActivity content = new MainOrderStatusActivity();
                    StaticOrder.Order_id = orders[position].OrderName;
                    manager.Replace(Resource.Id.framelayout, content).AddToBackStack(null);
                    manager.Commit();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(context, ex.Message, ToastLength.Long);
                }
            };

            return(view);
        }
Exemple #17
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var data = Intent.GetStringExtra("movie");

            var movie = Newtonsoft.Json.JsonConvert.DeserializeObject <MovieModel>(data);

            viewModel       = new MovieDetailViewModel();
            viewModel.Movie = movie;

            await viewModel.GetSimilarMovies(movie.Id);

            FindViewById <TextView>(Resource.Id.movie_overview).Text = movie.Overview;
            FindViewById <TextView>(Resource.Id.movie_title).Text    = movie.Title;
            FindViewById <TextView>(Resource.Id.release_date).Text   = "Release date: 01/05/2001";          //TODO: format this date!
            FindViewById <TextView>(Resource.Id.votes_amount).Text   = Convert.ToString(movie.VoteCount);


            ImageView coverImageView = FindViewById <ImageView>(Resource.Id.movie_cover);
            var       url            = await viewModel.GetMovieCover(movie.Id);

            try
            {
                Uri uri = Uri.Parse(url);
                Picasso.With(this).Load(uri).Fit().Into(coverImageView);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error getting the movie cover image: ", ex.Message);
            }

            //// Create a new fragment and a transaction.
            Android.App.FragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction();
            MovieDetailAdapter adapter = new MovieDetailAdapter(this, viewModel);

            MovieCategoryFragment <MovieDetailViewModel> aCategoryFragment = new MovieCategoryFragment <MovieDetailViewModel>(viewModel, adapter);

            ////// The fragment will have the ID of Resource.Id.fragment_container.
            fragmentTx.Add(Resource.Id.similar_movies, aCategoryFragment);
            ////// Commit the transaction.
            fragmentTx.Commit();
        }
Exemple #18
0
        private void switchtoMap()
        {
            updateToggle.Visibility = ViewStates.Invisible;
            Fab2.SetVisibility(ViewStates.Visible);

            // Removing other fragments

            /*  foreach (Android.App.Fragment f in FragmentList)
             * {
             *    fm.BeginTransaction().Hide(f).Commit();
             *    fm.BeginTransaction().Remove(f).Commit();
             * }*/

            Android.App.FragmentTransaction t = FragmentManager.BeginTransaction();
            //t.Replace(Resource.Id.content_frame, mapFrag);
            //  t.AddToBackStack(null);

            foreach (Android.App.Fragment f in FragmentList)
            {
                if (f != mapFrag)
                {
                    t.Hide(f);
                }
            }

            t.Show(mapFrag);
            t.Commit();

            // Getting the map
            mapFrag.GetMapAsync(this);

            // Showing the map fragment
            // fm.BeginTransaction().Show(mapFrag).Commit();

            // If location isn't null AND map has been initialized (the location service can start updating before
            Location location = LocationServices.FusedLocationApi.GetLastLocation(apiClient);

            if (location != null && MyMap != null)
            {
                CameraUpdate center = CameraUpdateFactory.NewLatLng(new LatLng(location.Latitude, location.Longitude));
                MyMap.MoveCamera(center);
            }
        }
Exemple #19
0
        public void ShowHistory()
        {
            if (_history == null)
            {
                // #1 Initialize
                Forms.Init(this, null);
                // #2 Use it
                _history = new HistoryPage().CreateFragment(this);
            }


            // And push that fragment onto the stack
            FragmentTransaction ft = FragmentManager.BeginTransaction();

            ft.AddToBackStack(null);
            ft.Replace(Resource.Id.fragment_frame_layout, _history, "history");

            ft.Commit();
        }
Exemple #20
0
        //MAP

        public void SetMap(int OrderID)
        {
            core.OrderID = OrderID;
            map.StartMap();
            map.MapFrag = MapFragment.NewInstance();
            map.MapFrag = FragmentManager.FindFragmentById(Resource.Id.map) as MapFragment;
            if (map.MapFrag == null)
            {
                GoogleMapOptions mapOptions = new GoogleMapOptions()
                                              .InvokeMapType(GoogleMap.MapTypeSatellite)
                                              .InvokeZoomControlsEnabled(false)
                                              .InvokeCompassEnabled(true);

                Android.App.FragmentTransaction fragTx = FragmentManager.BeginTransaction();
                map.MapFrag = MapFragment.NewInstance(mapOptions);
                fragTx.Add(Resource.Id.map, map.MapFrag, "map");
                fragTx.Commit();
            }
            map.MapFrag.GetMapAsync(this);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view          = inflater.Inflate(Resource.Layout.LayoutLast, container, false);
            var btn_calculate = view.FindViewById <Button>(Resource.Id.btn_cost);

            Button btn_auth1 = view.FindViewById <Button>(Resource.Id.btn_auth2);

            btn_auth1.Click += (s, e) =>
            {
                try
                {
                    Android.App.FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                    AuthActivity content3 = new AuthActivity();
                    transaction1.Replace(Resource.Id.framelayout, content3).AddToBackStack(null);
                    transaction1.Commit();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Activity, "" + ex.Message, ToastLength.Long).Show();
                }
            };

            // Переход к форме регистрации.
            btn_calculate.Click += (s, e) =>
            {
                //set alert for executing the task
                try
                {
                    Android.App.FragmentTransaction transaction2 = this.FragmentManager.BeginTransaction();
                    AddOrderActivity content = new AddOrderActivity();
                    transaction2.Replace(Resource.Id.framelayout, content).AddToBackStack(null);
                    transaction2.Commit();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Activity, "" + ex.Message, ToastLength.Long).Show();
                }
            };
            return(view);
            // Переход к форме авторизация
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            if (bundle == null)
            {
                Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();
                //var fragment = new XamarinListView.FragmentAtmListview();
                var fragment = new XamarinListView.Fragments.AtmFinderFragement();
                transaction.Replace(Resource.Id.titles_fragment, fragment);
                transaction.Commit();
            }

            //var view = FindViewById<ViewPager>(Resource.Id.)

            //var adapter =
            //        new AtmFinderAdapter(SupportFragmentManager,
            //            new FirstFragement(), new AtmListviewFragment(), new PagerFragment());
            //var viewPager = FindViewById<Android.Support.V4.View.ViewPager>(Resource.Id.vpPager);
            //viewPager.Adapter = adapter;
        }
Exemple #23
0
        private void switchtoSensorFragment()
        {
            updateToggle.Visibility = ViewStates.Invisible;
            Fab2.SetVisibility(ViewStates.Invisible);

            Android.App.FragmentTransaction t = FragmentManager.BeginTransaction();
            t.Replace(Resource.Id.content_frame, senFrag);

            foreach (Android.App.Fragment f in FragmentList)
            {
                if (f != senFrag)
                {
                    t.Hide(f);
                }
            }

            t.Show(senFrag);
            t.Commit();


            //  fm.BeginTransaction().Replace(Resource.Id.content_frame, senFrag).Commit();
            //  fm.BeginTransaction().Show(senFrag).Commit();
        }
        private void AlertDialogCall(string Messag)
        {
            AlertDialog.Builder alert = new AlertDialog.Builder(Activity);
            alert.SetTitle("Внимание!");
            alert.SetMessage(Messag);
            alert.SetPositiveButton("Закрыть", (senderAlert, args) =>
            {
                try
                {
                    Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
                    UserActivity content = new UserActivity();
                    transaction.Replace(Resource.Id.framelayout, content);
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(Activity, ex.Message, ToastLength.Long);
                }
            });
            Dialog dialog = alert.Create();

            dialog.Show();
        }
Exemple #25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_add_defect);

            checkPermissionForStorage();

            //defect = new Defect(System.Guid.NewGuid().ToString());
            defect = new Defect("Defect002");
            CreateFolders(defect.Id, false);

            detailsButton        = (Button)FindViewById(Resource.Id.detailsButton);
            imageButton          = (Button)FindViewById(Resource.Id.imageButton);
            detailsButton.Click += DetailsButton_Click;
            imageButton.Click   += ImageButton_Click;

            saveButton        = (Button)FindViewById(Resource.Id.saveButton);
            saveButton.Click += SaveButton_Click;
            FragmentTransaction      ft = FragmentManager.BeginTransaction();
            DefectAddDetailsFragment defectAddDetailsFragment = new DefectAddDetailsFragment();

            ft.Replace(Resource.Id.container1, defectAddDetailsFragment);
            ft.Commit();
        }
        //не отображается архив заказов, проверить!
        private async void GetOrders()
        {
            //var o_data1 = new ServiceResponseObject<SensorResponse>();
            //using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            //{
            //    //надо было сначала клиента указать, а потом вызывать метод
            //    //и обязательно с токеном
            //    OrderService.InitializeClient(client);
            //    o_data1 = await OrderService.GetSensorParameters();



            //}

            var o_data = new ServiceResponseObject <ListResponse <OrderResponseData, ArchiveResponse> >();

            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                //надо было сначала клиента указать, а потом вызывать метод
                //и обязательно с токеном
                OrderService.InitializeClient(client);
                o_data = await OrderService.GetOrders();

                if (o_data.Status == HttpStatusCode.OK)
                {
                    //o_data.Message = "Успешно авторизован!";
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                    //StaticUser.Email = s_login.Text;
                    //StaticUser.AddInfoAuth(o_user_data);
                    if (o_data.ResponseData.ARCHIVE.Count == 0)
                    {
                        try
                        {
                            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
                            BookNotFoundActivity            content     = new BookNotFoundActivity();
                            transaction.Replace(Resource.Id.framelayout, content);
                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            Toast.MakeText(Activity, ex.Message, ToastLength.Long);
                        }
                        return;
                    }

                    //обязательно должен быть прогресс бар при обращении к серверу, типо такого
                    //preloader.Visibility = Android.Views.ViewStates.Invisible;
                    foreach (var order in o_data.ResponseData.ARCHIVE)
                    {
                        orderlist.Add(new OrderBookModel
                        {
                            Id          = order.id,
                            Destination = order.destination_address,
                            Inception   = order.inception_address,
                            Price       = order.payment_amount + " рублей",
                            OrderName   = order.id,
                            Date        = order.stage2_datetime.ToString()
                        }
                                      );
                    }



                    //OrderBookModel p2 = new OrderBookModel()
                    //{
                    //    Id = 2,
                    //    Destination = "Славный переулок, 5, Новошахтинск",
                    //    Inception = "Астаховский переулок, 84, Каменск-Шахтинский",
                    //    Price = "950 руб",
                    //    OrderName = "Заказ OP5887450402",
                    //    Date = "12 марта 11:34"
                    //};
                    //OrderBookModel p3 = new OrderBookModel()
                    //{
                    //    Id = 3,
                    //    Destination = "Комитетская улица, 88, Новочеркасск",
                    //    Inception = "переулок Чапаева, 2, Шахты",
                    //    Price = "800 руб",
                    //    OrderName = "Заказ PR3921079101",
                    //    Date = "19 февраля 09:11"
                    //};
                    //orderlist.Add(p1);
                    //orderlist.Add(p2);
                    //orderlist.Add(p3);
                    UpdateList();
                    lstOrder.ItemClick += ListOrders_ItemClick;
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();//"Unexpected character encountered while parsing value: {. Path 'ORDERS[0].last_stage_at', line 2, position 1086."
                }
            }
        }
Exemple #27
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View view = convertView;

            if (view == null)
            {
                view = LayoutInflater.From(context).Inflate(Resource.Layout.EventCardView, null);
            }

            var message   = view.FindViewById <TextView>(Resource.Id.EventCardTextName);
            var btn_video = view.FindViewById <Button>(Resource.Id.btn_video);

            view.FindViewById <TextView>(Resource.Id.EventCardTextTime).Text = events[position].Time;
            view.FindViewById <TextView>(Resource.Id.EventCardTextDate).Text = events[position].Date;


            if (events[position].ContentType == "image")
            {
                btn_video.Visibility = ViewStates.Visible;
                btn_video.Enabled    = true;
                message.Text         = "Сделано фото";
                btn_video.Text       = "Просмотреть фото";
            }
            else if (events[position].ContentType == "video")
            {
                message.Text         = "Получено видео";
                btn_video.Text       = "Просмотреть видео";
                btn_video.Visibility = ViewStates.Visible;
                btn_video.Enabled    = true;
            }
            else
            {
                message.Text         = events[position].Name;
                btn_video.Visibility = ViewStates.Invisible;
                btn_video.Enabled    = false;
                btn_video.Text       = "";
            }

            btn_video.Click += delegate
            {
                try
                {
                    listPosition.Add(position);
                    if (_Clicked == false)
                    {
                        _Clicked = true;

                        AlertDialog.Builder alert = new AlertDialog.Builder(context);
                        alert.SetTitle("Внимание!");
                        alert.SetMessage("Вы действительно хотите открыть медиа файл?");
                        alert.SetPositiveButton("Открыть", (senderAlert, args) =>
                        {
                            _Clicked   = false;
                            MaxElement = listPosition.Max();
                            if (btn_video.Text == "Просмотреть фото")
                            {
                                SetPhoto(events[MaxElement].Name);
                            }
                            else
                            {
                                GetVideo();
                                VideoFromServerActivity content = new VideoFromServerActivity();
                                listPosition.Clear();
                                manager.Replace(Resource.Id.framelayout, content);
                                manager.Commit();
                            }
                        });
                        alert.SetNegativeButton("Отмена", (senderAlert, args) =>
                        {
                            _Clicked = false;
                            listPosition.Clear();
                        });
                        Dialog dialog = alert.Create();
                        dialog.Show();
                    }

                    //if (events[position].ContentType == "image")
                    //{
                    //    string Message = "Фотография успешно получена. Вы можете её посмотреть.";
                    //}
                    //else
                    //{
                    //    string Message = "Видео успешно получено. Вы можете его просмотреть.";
                    //}
                }
                catch (Exception ex)
                {
                    Toast.MakeText(context, ex.Message, ToastLength.Long);
                }
            };

            return(view);
        }
        private void AlertDialogCreation(string titleString, string messageString)
        {
            LayoutInflater layoutInflater = LayoutInflater.From(Activity);
            View           view           = layoutInflater.Inflate(Resource.Layout.qqqqqqww, null);

            var txtTitle     = view.FindViewById <TextView>(Resource.Id.TextTitle);
            var txtInfo      = view.FindViewById <TextView>(Resource.Id.TextInfo);
            var btn_Negative = view.FindViewById <Button>(Resource.Id.BtnNegative);

            btn_Positive = view.FindViewById <Button>(Resource.Id.BtnPositive);

            //TimerCallback tm = new TimerCallback(QWE);
            // создаем таймер
            int i = 0;

            // Thread thread = new Thread
            //(()
            //     =>
            //{
            //    while (true)
            //    {
            //        if (StaticOrder.MessageResult == "1")
            //        {
            //            QWE();
            //            return;
            //        }
            //    }
            //});

            txtTitle.Text = titleString;
            txtInfo.Text  = messageString;

            Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(Activity);

            alert.SetView(view);
            alert.SetCancelable(false);

            Dialog dialog = alert.Create();

            btn_Positive.Click += delegate
            {
                if (btn_Positive.Text == "Открыть")
                {
                    if (StaticOrder.MessageResult == "1")
                    {
                        //thread.Abort();
                        //thread.Join();
                        switch (titleString)
                        {
                        case "Сделать фотографию":
                            dialog.Dismiss();
                            SetPhoto();
                            break;

                        case "Сделать видео":
                            dialog.Dismiss();
                            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
                            VideoFromServerActivity         content     = new VideoFromServerActivity();
                            transaction.Replace(Resource.Id.framelayout, content);
                            transaction.Commit();
                            break;
                        }
                    }
                    else
                    {
                        string PhotoorVideo = "";
                        switch (titleString)
                        {
                        case "Сделать фотографию":
                            PhotoorVideo = "Фото";
                            break;

                        case "Сделать видео":
                            PhotoorVideo = "Видео";
                            break;
                        }
                        Toast.MakeText(Activity, PhotoorVideo + " ещё не загруженно.", ToastLength.Long).Show();
                    }
                }
                else
                {
                    //thread.Start();
                    //Timer timer = new Timer(tm, i, 0, 1000);
                    switch (titleString)
                    {
                    case "Сделать фотографию":
                        btn_Positive.Text = "Открыть";
                        GetPhoto();
                        break;

                    case "Сделать видео":
                        btn_Positive.Text = "Открыть";
                        GetVideo();
                        break;

                    case "Внесение оплаты":
                        MakePayment();
                        break;
                    }
                }
            };
            btn_Negative.Click += delegate
            {
                dialog.Dismiss();
            };
            dialog.Show();


            //AlertDialog.Builder alert = new AlertDialog.Builder(Activity);
            //alert.SetTitle(titleString);
            //alert.SetMessage(messageString);
            //alert.SetPositiveButton("Да", (senderAlert, args) =>
            //{
            //    switch(titleString)
            //    {
            //        case "Сделать фотографию":
            //            GetPhoto();
            //            break;
            //        case "Сделать видео":
            //            Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
            //            VideoFromServerActivity content = new VideoFromServerActivity(StaticOrder.Order_id, "");
            //            transaction.Replace(Resource.Id.framelayout, content);
            //            transaction.Commit();
            //            break;
            //        case "Внесение оплаты":
            //            MakePayment();
            //            break;
            //    }
            //});
            //alert.SetNegativeButton("Отмена", (senderAlert, args) =>
            //{
            //});
            //Dialog dialog = alert.Create();
            //dialog.Show();
        }
        private async void GetOrders()
        {
            var o_data = new ServiceResponseObject <ListResponse <OrderResponseData, ArchiveResponse> >();

            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                OrderService.InitializeClient(client);
                o_data = await OrderService.GetOrders();

                if (o_data.Status == HttpStatusCode.OK && o_data.ResponseData.ORDERS.Count != 0)
                {
                    var number = 0;

                    orderlist = new List <OrderAdapter>();
                    foreach (var order in o_data.ResponseData.ORDERS)
                    {
                        number++;
                        orderlist.Add(new OrderAdapter
                        {
                            id = order.id,
                            Id = number,
                            inception_address   = order.inception_address,
                            inception_lat       = order.inception_lat,
                            cargo_class         = order.cargo_class,
                            distance            = order.distance,
                            insurance           = order.insurance,
                            stage2_datetime     = order.stage2_datetime,
                            stage5_datetime     = order.stage5_datetime,
                            payment_id          = order.payment_id,
                            order_stage_id      = order.order_stage_id,
                            created_at          = order.created_at,
                            payment_amount      = order.payment_amount,
                            payment_status      = order.payment_status,
                            order_stage_name    = order.order_stage_name,
                            last_stage_at       = order.last_stage_at,
                            container_id        = order.container_id,
                            sensors_status      = order.sensors_status,
                            event_count         = order.event_count,
                            destination_address = order.destination_address,
                            destination_lat     = order.destination_lat,
                            destination_lng     = order.destination_lng
                        }
                                      );
                    }
                    UpdateList();
                }
                else
                {
                    try
                    {
                        StaticUser.NamePadeAbsenceSomething = "";
                        Android.App.FragmentTransaction transaction = this.FragmentManager.BeginTransaction();
                        NotFoundOrdersActivity          content     = new NotFoundOrdersActivity();
                        transaction.Replace(Resource.Id.framelayout, content);
                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        Android.Util.Log.Debug("Reference on another page error: ", ex.Message);
                        // Toast.MakeText(Activity, ex.Message, ToastLength.Long);
                    }
                }
            }
        }
Exemple #30
0
 }

        protected override void OnResume()
        {
            base.OnResume();

            if (!_methods.IsConnected())
            {
                NoConnectionActivity.ActivityName = this;
                StartActivity(typeof(NoConnectionActivity));
                Finish();
                return;
            }

            _mapFragment =
                    FragmentManager.FindFragmentByTag("map") as MapFragment;
            if (_mapFragment == null)
            {
                GoogleMapOptions mapOptions = new GoogleMapOptions()
                    .InvokeMapType(GoogleMap.MapTypeNormal)
                    .InvokeZoomControlsEnabled(false)
                    .InvokeCompassEnabled(true);

                Android.App.FragmentTransaction fragTx = FragmentManager.BeginTransaction();
                _mapFragment = MapFragment.NewInstance(mapOptions);
                fragTx.Add(Resource.Id.map, _mapFragment, "map");
                fragTx.Commit();
            }
            _mapFragment.GetMapAsync(this);

            InitElements();
            if (!_databaseMethods.GetShowMapHint())
                _hintRl.Visibility = ViewStates.Gone;
            _okBn.Click += (s, e) =>
            {
                _hintRl.Visibility = ViewStates.Gone;
            };
            _neverShowBn.Click += (s, e) =>
            {
                _hintRl.Visibility = ViewStates.Gone;
                _databaseMethods.InsertMapHint(false);
            };

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

            _centerPositionBn.Click += CenterPositionBn_Click;

            _applyAddressBn.Click += (s, e) =>
     {
         HomeAddressActivity.ChangedSomething = true;
         if (!String.IsNullOrEmpty(_latTemporary) && !String.IsNullOrEmpty(_lngTemporary))
         {
             Lat = _latTemporary;
             Lng = _lngTemporary;
         }
                else
         {
             Lat = _myPosition?.Latitude.ToString();
                    Lng = _myPosition?.Longitude.ToString();
         }
         HomeAddressActivity.CameFromMap = true;
         OnBackPressed();
     };
        }