Пример #1
0
        private void InitializeUI()
        {
            _listViewPoi = FindViewById <ListView>(Resource.Id.listViewPoi);

            List <PoiViewItem> _items = Context.PoiData;

            _items               = _items.OrderBy(i => i.GpsLocation.Distance).ToList();
            _adapter             = new PoiListItemAdapter(this, _items, this);
            _listViewPoi.Adapter = _adapter;

            _listViewPoi.ItemClick += OnListItemClick;

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

            SetActionBar(toolbar);

            ActionBar.SetDisplayShowHomeEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowTitleEnabled(false);


            _editTextSearch           = FindViewById <SearchView>(Resource.Id.editTextSearch);
            _editTextSearch.Iconified = false;
            _editTextSearch.SetQueryHint(Resources.GetText(Resource.String.Common_Search));
            _editTextSearch.SetOnQueryTextListener(this);
            _editTextSearch.FocusableViewAvailable(_listViewPoi);

            _spinnerSelection = FindViewById <Spinner>(Resource.Id.spinnerSelection);

            var selectionAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, GetFilterOptions());

            _spinnerSelection.Adapter = selectionAdapter;
            _spinnerSelection.SetSelection((int)Context.SelectedPoiFilter);
            _spinnerSelection.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(OnFilterSelectionChanged);

            _spinnerCountry               = FindViewById <Spinner>(Resource.Id.spinnerCountry);
            _spinnerCountry.Adapter       = new CountryAdapter(this, true);
            _spinnerCountry.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(OnFilterCountryChanged);

            _spinnerCategory               = FindViewById <Spinner>(Resource.Id.spinnerCategory);
            _spinnerCategory.Adapter       = new CategoryAdapter(this, true);
            _spinnerCategory.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(OnFilterCategoryChanged);

            var expandButton = FindViewById <ImageButton>(Resource.Id.expandButton);

            if (expandButton != null)
            {
                expandButton.SetOnClickListener(this);
                _expandableLayout = FindViewById <LinearLayout>(Resource.Id.expandableLayout);
            }
        }
Пример #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (DeviceDisplay.MainDisplayInfo.Orientation == DisplayOrientation.Portrait)
            {
                SetContentView(Resource.Layout.PoiSelectActivityPortrait);
            }
            else
            {
                SetContentView(Resource.Layout.PoiSelectActivityLandscape);
            }


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

            SetActionBar(toolbar);

            ActionBar.SetDisplayShowHomeEnabled(true);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetDisplayShowTitleEnabled(true);
            ActionBar.SetTitle(Resource.String.PoiSelectActivity);

            _changeFilterTimer.Interval  = 1000;
            _changeFilterTimer.Elapsed  += OnChangeFilterTimerElapsed;
            _changeFilterTimer.AutoReset = false;

            var longitude = Intent.GetDoubleExtra("Longitude", Double.NaN);
            var latitude  = Intent.GetDoubleExtra("Latitude", Double.NaN);
            var sortBy    = Intent.GetStringExtra("SortBy");

            if (longitude != Double.NaN && latitude != Double.NaN)
            {
                _centerGpsLocation = new GpsLocation(longitude, latitude, 0);
            }

            if (!Enum.TryParse(sortBy, out _sortBy))
            {
                _sortBy = SortBy.Name;
            }

            _searchViewText           = FindViewById <SearchView>(Resource.Id.editTextSearch);
            _searchViewText.Iconified = false;
            _searchViewText.SetQueryHint(Resources.GetText(Resource.String.Common_Search));
            _searchViewText.SetOnQueryTextListener(this);
            _searchViewText.FocusableViewAvailable(_listViewPoi);

            _spinnerCountry               = FindViewById <Spinner>(Resource.Id.spinnerCountry);
            _spinnerCountry.Adapter       = new CountryAdapter(this, true);
            _spinnerCountry.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(OnFilterCountryChanged);

            _spinnerCategory               = FindViewById <Spinner>(Resource.Id.spinnerCategory);
            _spinnerCategory.Adapter       = new CategoryAdapter(this, true);
            _spinnerCategory.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(OnFilterCategoryChanged);

            _listViewPoi = FindViewById <ListView>(Resource.Id.listViewPoi);

            var poiViewItems = new PoiViewItemList(null, AppContext.MyLocation, _iGpsUtilities);

            if (Intent.Action == REQUEST_SELECT_DOWNLOADELEVATIONDATAAREA.ToString())
            {
                if (Peaks360Lib.Utilities.GpsUtils.HasLocation(AppContext.MyLocation))
                {
                    AddMyLocation(poiViewItems);
                }
            }

            _adapter             = new PoiListItemAdapter(this, poiViewItems, this, false);
            _listViewPoi.Adapter = _adapter;
        }