Пример #1
0
        public void GetRoutesAsync()
        {
            if (list == null)
            {
                list = new List <SearchWaySystem.RouteInfo>();
            }

            list = SearcherAdapter.GetRoutes(firstStation, secondStation, tral[0], tral[1], tral[2], tral[3]);
        }
Пример #2
0
        private void _ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            FindViewById <LinearLayout>(Resource.Id.rootLayout).RequestFocus();
            InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);

            imm.ToggleSoftInput(InputMethodManager.ShowForced, 0);

            if (SearcherAdapter.CheckRoute(startSpinner.Text, endSpinner.Text))
            {
                favouritiesBtn.SetImageResource(Resource.Drawable.Contains);
            }
            else
            {
                favouritiesBtn.SetImageResource(Resource.Drawable.NotContains);
            }
        }
Пример #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetTheme(Resource.Style.AppTheme);
            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);
            SupportActionBar.Title = "Что приедет";

            favouritiesBtn        = FindViewById <ImageButton>(Resource.Id.FavouritiesButton);
            favouritiesBtn.Click += Fbtn_Click;

            SearcherAdapter.DownloadDataBase(Assets.Open("allroutes.dat"), Assets.Open("allstations.dat"), Assets.Open("routematrix.dat"));
            SearcherAdapter.Init();

            AllStations stations = SearcherAdapter.GetAllStations();

            items = new List <string>();

            for (int i = 0; i < stations.Count; i++)
            {
                items.Add(stations.GetStation(i).StationName.ToString());
            }

            startSpinner = new CustomTextView(FindViewById <AutoCompleteTextView>(Resource.Id.Start), new ArrayAdapter(this, Resource.Layout.list_item, items));
            startSpinner.textView.ItemClick += _ItemClick;
            endSpinner = new CustomTextView(FindViewById <AutoCompleteTextView>(Resource.Id.End), new ArrayAdapter(this, Resource.Layout.list_item, items));
            endSpinner.textView.ItemClick += _ItemClick;

            text            = FindViewById <ListView>(Resource.Id.Schedule);
            text.ItemClick += Text_ItemClick;
            var btn = FindViewById <Button>(Resource.Id.SearchButton);

            btn.Click += FindTransport;

            if (SearcherAdapter.St != null)
            {
                var m = SearcherAdapter.GetPoint();
                startSpinner.Text = items[m[0]];
                endSpinner.Text   = items[m[1]];
                favouritiesBtn.SetImageResource(Resource.Drawable.Contains);
            }

            FindViewById <LinearLayout>(Resource.Id.rootLayout).RequestFocus();
        }
Пример #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_favourities);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar2);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDefaultDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.Title = "Избранное";
            var text    = FindViewById <ListView>(Resource.Id.FavouritiesList);
            var adapter = new TextViewFavoriteRoutesAdapter(this, SearcherAdapter.GetFavoriteRoutes());

            text.Adapter    = adapter;
            text.ItemClick += Text_ItemClick;
        }
Пример #5
0
        private void Fbtn_Click(object sender, System.EventArgs e)
        {
            if (items.Contains(startSpinner.Text) && items.Contains(endSpinner.Text))
            {
                firstStation  = startSpinner.Text;
                secondStation = endSpinner.Text;

                if (!SearcherAdapter.CheckRoute(firstStation, secondStation))
                {
                    SearcherAdapter.AddFavoriteRoute(new SearchWaySystem.FavoriteRoutesNode(firstStation + "-" + secondStation, firstStation, secondStation));
                    favouritiesBtn.SetImageResource(Resource.Drawable.Contains);
                    Toast.MakeText(this, "Маршрут добавлен в избранное", ToastLength.Short).Show();
                }
                else
                {
                    SearcherAdapter.DeleteFavoriteRoute(firstStation, secondStation);
                    favouritiesBtn.SetImageResource(Resource.Drawable.NotContains);
                    Toast.MakeText(this, "Маршрут удален из избранного", ToastLength.Short).Show();
                }
                SearcherAdapter.SaveFavoriteRoutes();
            }
        }
Пример #6
0
 private void Text_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
 {
     SearcherAdapter.SetPoint(SearcherAdapter.GetFavoriteRoutes().FavoriteRoutesList[e.Position].PointOfDeparture, SearcherAdapter.GetFavoriteRoutes().FavoriteRoutesList[e.Position].PointOfDestination);
     StartActivity(typeof(MainActivity));
     OverridePendingTransition(Resource.Animation.slide_left, Resource.Animation.fade_out);
 }