Beispiel #1
0
 public void RemoveFragment(Context context, Fragment newFragment, string TAG)
 {
     Android.Support.V4.App.FragmentManager     fragmentManager = ((FragmentActivity)context).SupportFragmentManager;
     Android.Support.V4.App.FragmentTransaction ft = fragmentManager.BeginTransaction();
     ft.Remove(newFragment);
     ft.AddToBackStack(TAG);
     ft.Commit();
 }
Beispiel #2
0
 public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object @object)
 {
     base.DestroyItem(container, position, @object);
     if (position >= Count)
     {
         FragmentManager     manager = ((Fragment)@object).FragmentManager;
         FragmentTransaction trans   = manager.BeginTransaction();
         trans.Remove((Fragment)@object);
         trans.Commit();
     }
 }
Beispiel #3
0
        public void startDialogFragment(v4App.DialogFragment dialogFragment)
        {
            v4App.FragmentTransaction ft = SupportFragmentManager.BeginTransaction();
            //Remove fragment else it will crash as it is already added to backstack
            v4App.Fragment prev = SupportFragmentManager.FindFragmentByTag("dialog");
            if (prev != null)
            {
                ft.Remove(prev);
            }
            ft.AddToBackStack(null);

            dialogFragment.Show(ft, "dialog");
        }
Beispiel #4
0
 public void Dismiss()
 {
     if (dismissed)
     {
         return;
     }
     dismissed = true;
     new Handler().Post(() => {
         FragmentManager.PopBackStack();
         V4FragmentTransaction ft = FragmentManager.BeginTransaction();
         ft.Remove(this);
         ft.CommitAllowingStateLoss();
     });
 }
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            Android.Support.V4.App.Fragment residentsFragment     = null;
            Android.Support.V4.App.Fragment residentsPrevFragment = null;

            residentsFragment     = FragmentManager.FindFragmentByTag("residentsFragment");
            residentsPrevFragment = FragmentManager.FindFragmentByTag("residentsPrevFragment");


            if (residentsFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft1 = FragmentManager.BeginTransaction();
                ft1.Remove(residentsFragment);
                ft1.AddToBackStack(null);
                ft1.Commit();
            }

            if (residentsPrevFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft2 = FragmentManager.BeginTransaction();
                ft2.Remove(residentsPrevFragment);
                ft2.AddToBackStack(null);
                ft2.Commit();
            }

            Android.Support.V4.App.FragmentTransaction ft = FragmentManager.BeginTransaction();
            ft.Commit();


            var ignored = base.OnCreateView(inflater, container, savedInstanceState);
            var view    = inflater.Inflate(Resource.Layout.fragment_canvass, null);

            cm = (ConnectivityManager)Activity.GetSystemService(Context.ConnectivityService);


            if (checkNetwork())
            {
                drawTable(view);
            }
            else
            {
                showNetworkError();
            }

            return(view);
        }
Beispiel #6
0
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            Android.Support.V4.App.Fragment residentsFragment     = null;
            Android.Support.V4.App.Fragment residentsPrevFragment = null;

            residentsFragment     = FragmentManager.FindFragmentByTag("residentsFragment");
            residentsPrevFragment = FragmentManager.FindFragmentByTag("residentsPrevFragment");


            if (residentsFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft1 = FragmentManager.BeginTransaction();
                ft1.Remove(residentsFragment);
                ft1.AddToBackStack(null);
                ft1.Commit();
            }

            if (residentsPrevFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft2 = FragmentManager.BeginTransaction();
                ft2.Remove(residentsPrevFragment);
                ft2.AddToBackStack(null);
                ft2.Commit();
            }

            var ignored = base.OnCreateView(inflater, container, savedInstanceState);
            var view    = inflater.Inflate(Resource.Layout.fragment_register, null);

            cm = (ConnectivityManager)Activity.GetSystemService(Context.ConnectivityService);

            if (checkNetwork())
            {
                WebView localWebView = view.FindViewById <WebView>(Resource.Id.webView1);
                localWebView.SetWebViewClient(new WebViewClient());           // stops request going to Web Browser
                localWebView.LoadUrl("https://www.registertovote.service.gov.uk/register-to-vote/country-of-residence?_ga=1.24772217.255160918.1436270892");
            }
            else
            {
                showNetworkError();
            }

            return(view);
        }
Beispiel #7
0
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            Android.Support.V4.App.Fragment residentsFragment     = null;
            Android.Support.V4.App.Fragment residentsPrevFragment = null;

            residentsFragment     = FragmentManager.FindFragmentByTag("residentsFragment");
            residentsPrevFragment = FragmentManager.FindFragmentByTag("residentsPrevFragment");


            if (residentsFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft1 = FragmentManager.BeginTransaction();
                ft1.Remove(residentsFragment);
                ft1.AddToBackStack(null);
                ft1.Commit();
            }

            if (residentsPrevFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft2 = FragmentManager.BeginTransaction();
                ft2.Remove(residentsPrevFragment);
                ft2.AddToBackStack(null);
                ft2.Commit();
            }

            var ignored = base.OnCreateView(inflater, container, savedInstanceState);
            var view    = inflater.Inflate(Resource.Layout.fragment_settings, null);

            cm = (ConnectivityManager)Activity.GetSystemService(Context.ConnectivityService);

            oldPass    = (EditText)view.FindViewById(Resource.Id.oldPassword);
            newPass    = (EditText)view.FindViewById(Resource.Id.newPassword);
            changePass = (Button)view.FindViewById(Resource.Id.changePassword);

            changePass.Click += (object sender, EventArgs e) =>
            {
                changePassword();
            };

            return(view);
        }
Beispiel #8
0
        public void removeFragment()
        {
            //			Android.Support.V4.App.Fragment canvassesFragment = null;
            //			canvassesFragment = new CanvassesFragment ();
            //
            //			Android.Support.V4.App.FragmentTransaction ft = FragmentManager.BeginTransaction ();
            //			ft.Replace (Resource.Id.content_frame, canvassesFragment, "canvassesFragment");
            //			ft.Commit ();

            try
            {
                Android.Support.V4.App.FragmentTransaction ft = FragmentManager.BeginTransaction();
                ft.Remove(this);
                ft.Show(FragmentManager.FindFragmentByTag("canvassesFragment"));
                ft.Commit();
            }

            catch (Exception ex)
            {
                //Console.WriteLine ("Ex From REEEEEEEEEPREEEEEEEEFRAG" + ex.ToString());
            }
        }
Beispiel #9
0
        public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
        {
            Android.Support.V4.App.Fragment residentsFragment     = null;
            Android.Support.V4.App.Fragment residentsPrevFragment = null;

            residentsFragment     = FragmentManager.FindFragmentByTag("residentsFragment");
            residentsPrevFragment = FragmentManager.FindFragmentByTag("residentsPrevFragment");


            if (residentsFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft1 = FragmentManager.BeginTransaction();
                ft1.Remove(residentsFragment);
                ft1.AddToBackStack(null);
                ft1.Commit();
            }

            if (residentsPrevFragment != null)
            {
                Android.Support.V4.App.FragmentTransaction ft2 = FragmentManager.BeginTransaction();
                ft2.Remove(residentsPrevFragment);
                ft2.AddToBackStack(null);
                ft2.Commit();
            }



            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            var view = inflater.Inflate(Resource.Layout.fragment_map, null);

            //MapsInitializer.initialize(getActivity());
            mapFrag = (SupportMapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
            //Console.WriteLine ("before maps");
            GoogleMap map = mapFrag.Map;

            //Console.WriteLine ("after maps");

            if (DataController.lat != null && DataController.lng != null)
            {
                //Console.WriteLine ("inside map if");
                LatLng location = new LatLng(Convert.ToDouble(DataController.lat), Convert.ToDouble(DataController.lng));
                //Console.WriteLine ("after getting locations");
                CameraPosition.Builder builder = CameraPosition.InvokeBuilder();
                //Console.WriteLine ("After the camera");
                builder.Target(location);
                builder.Zoom(15);
                builder.Bearing(0);
                builder.Tilt(0);

                CameraPosition cameraPosition = builder.Build();
                CameraUpdate   cameraUpdate   = CameraUpdateFactory.NewCameraPosition(cameraPosition);
                map.AnimateCamera(cameraUpdate);
            }

            if (map != null)
            {
//				MarkerOptions markerOpt1 = new MarkerOptions();
//				markerOpt1.SetPosition(new LatLng(Convert.ToDouble(DataController.lat), Convert.ToDouble(DataController.lng)));
//				markerOpt1.SetTitle("My Location");
//				markerOpt1.SetIcon (BitmapDescriptorFactory.DefaultMarker (BitmapDescriptorFactory.HueAzure));
//				map.AddMarker(markerOpt1);

                coords    = DataController.coords;
                addresses = DataController.addresses;

                if (coords != null)
                {
                    for (int i = 0; i < coords.Count; i++)
                    {
                        MarkerOptions markerOpt1 = new MarkerOptions();
                        propertyDict = addresses [i];
                        markerOpt1.SetPosition(coords [i]);
                        //if (propertyDict ["status"].ToString() != "NV") {
                        markerOpt1.SetTitle(propertyDict ["fullAddress"].ToString());
                        //markerOpt1.SetIcon (BitmapDescriptorFactory.DefaultMarker (BitmapDescriptorFactory.HueAzure));
                        //} else {
                        //	markerOpt1.SetTitle (propertyDict ["fullAddress"].ToString ());
                        //}
                        map.AddMarker(markerOpt1);
                    }
                    //map.MoveCamera (cameraUpdate);
                }
                map.MyLocationEnabled = true;
            }

            return(view);
        }
Beispiel #10
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            DataBase.db = DataBase.getDataBase();
            DataBase.db.createDataBase();

            string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);

            Log.Info("DB_PATH", folder);

            long elementId;
            var  view = inflater.Inflate(Resource.Layout.SecondFragmentLayout, container, false);

            lstData = view.FindViewById <ListView>(Resource.Id.listView);
            //Задаем текст для пустого списка
            var emptyView = inflater.Inflate(Resource.Layout.emptyList, container, false);

            lstData.EmptyView = emptyView.FindViewById <TextView>(Resource.Id.empty);

            var btnAdd       = view.FindViewById <FloatingActionButton>(Resource.Id.btnAdd);
            var btnRefresh   = view.FindViewById <Button>(Resource.Id.btnRefresh);
            var btnDeleteAll = view.FindViewById <Button>(Resource.Id.btnDeleteAll);

            //Загружаем данные из бд и обновляем список задач
            LoadData();
            //Добавить новую задачу
            btnAdd.Click += delegate
            {
                //Создаем пустую запись в бд


                Resources.Model.Task task = new Resources.Model.Task()
                {
                    Name        = "",
                    Date        = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day),
                    Time        = new DateTime(1, 1, 1, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second),
                    Description = "",
                    Category    = "Спорт",
                    Priority    = "0",
                    Done        = false
                };
                var t = System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    DataBase.db.insertIntoTableTask(task);
                });
                t.Wait();
                t.Dispose();
                //Создаем окно для добавления новой задачи
                Android.Support.V4.App.FragmentTransaction ft   = FragmentManager.BeginTransaction();
                Android.Support.V4.App.Fragment            prev = FragmentManager.FindFragmentByTag("dialog");
                //Передаем id новой заметки для корректной записи в бд
                Bundle frag_bundle = new Bundle();
                frag_bundle.PutLong("Id", task.Id);

                if (prev != null)
                {
                    ft.Remove(prev);
                }
                ft.AddToBackStack(null);

                _activity._taskWindow = DialogWindow.NewInstance(frag_bundle);
                var act = _activity._taskWindow.Activity;
                //Показываем окно
                _activity._taskWindow.SetActivity(_activity);
                _activity._taskWindow.Show(ft, "dialog");
            };

            btnRefresh.Click += delegate
            {
                LoadData();
            };

            // Эта кнопка удаляет все выполненные задачи
            btnDeleteAll.Click += delegate
            {
                Android.App.AlertDialog.Builder delDoneDialog = new Android.App.AlertDialog.Builder(_activity);
                delDoneDialog.SetTitle("Удалить все выполненные задачи");
                delDoneDialog.SetMessage("Вы уверены?");
                delDoneDialog.SetPositiveButton("Да", (senderAlert, args) =>
                {
                    DataBase.db.delAllDoneTask();
                    _activity._fragment2.LoadData();
                });
                delDoneDialog.SetNegativeButton("Нет", (senderAlert, args) =>
                {
                    return;
                });
                Dialog dialog = delDoneDialog.Create();
                dialog.Show();

                //delDoneWindow.Show;
            };
            //Просмотр/ редактирование существующей задачи
            lstData.ItemClick += (s, e) =>
            {
                for (int i = 0; i < lstData.Count; i++)
                {
                    if (e.Position == i)
                    {
                        //Получаем id выбранного в списке элемента
                        var t = System.Threading.Tasks.Task.Factory.StartNew(() =>
                        {
                            elementId = DataBase.db.selectQuery(lstData.Adapter.GetItemId(e.Position));

                            return(elementId);
                        });
                        t.Wait();

                        Android.Support.V4.App.FragmentTransaction ft = FragmentManager.BeginTransaction();
                        //Remove fragment else it will crash as it is already added to backstack
                        Android.Support.V4.App.Fragment prev = FragmentManager.FindFragmentByTag("dialog");
                        Bundle frag_bundle = new Bundle();
                        frag_bundle.PutLong("Id", t.Result);

                        t.Dispose();

                        if (prev != null)
                        {
                            ft.Remove(prev);
                        }
                        ft.AddToBackStack(null);
                        _activity._taskWindow = DialogWindow.NewInstance(frag_bundle);
                        _activity._taskWindow.SetActivity(_activity);
                        _activity._taskWindow.Show(ft, "dialog");
                    }
                }

                //Заполняем поля данными
                var txtName    = e.View.FindViewById <TextView>(Resource.Id.textView1);
                var checkedBox = e.View.FindViewById <CheckBox>(Resource.Id.chkBox);
                //var txtDone = e.View.FindViewById<TextView>(Resource.Id.textView5);
                checkedBox.SetOnCheckedChangeListener(null);
            };
            //Удержание на элементе
            lstData.ItemLongClick += (s, e) =>
            {
                if (DataBase.db.getSettings()[0].fastDel == true || DataBase.db.getSettings()[0].fastDel == null)
                {
                    Android.App.AlertDialog.Builder delDialog = new Android.App.AlertDialog.Builder(_activity);
                    delDialog.SetTitle("Удалить задачу");
                    delDialog.SetMessage("Вы уверены?");
                    delDialog.SetPositiveButton("Да", (senderAlert, args) =>
                    {
                        for (int i = 0; i < lstData.Count; i++)
                        {
                            if (e.Position == i)
                            {
                                var selected_Element = DataBase.db.get_Element(lstData.Adapter.GetItemId(e.Position))[0];
                                DataBase.db.delTask(selected_Element.Id);
                                _activity._fragment2.LoadData();
                                Toast.MakeText(_activity, "Задача удалена", ToastLength.Long).Show();
                            }
                        }
                    });
                    delDialog.SetNegativeButton("Нет", (senderAlert, args) =>
                    {
                        return;
                    });
                    Dialog dialog = delDialog.Create();
                    dialog.Show();
                }
            };
            return(view);
        }