示例#1
0
        private void InitializeCategoryFilterButton(int resourceId)
        {
            var category    = PoiCategoryHelper.GetCategory(resourceId);
            var imageButton = FindViewById <ImageButton>(resourceId);

            imageButton.SetOnClickListener(this);
            bool enabled = _context.Settings.Categories.Contains(category);

            imageButton.SetImageResource(PoiCategoryHelper.GetImage(category, enabled));

            _imageButtonCategoryFilter.Add(category, imageButton);
        }
示例#2
0
        private void OnSelectionUpdated(Poi poi)
        {
            FindViewById <TextView>(Resource.Id.textViewPlaceName).Text    = poi.Name;
            FindViewById <TextView>(Resource.Id.textViewPlaceCountry).Text = PoiCountryHelper.GetCountryName(poi.Country);
            FindViewById <TextView>(Resource.Id.textViewAltitude).Text     = $"{poi.Altitude:F0} m";
            FindViewById <TextView>(Resource.Id.textViewGpsLocation).Text  = GpsUtils.LocationAsString(poi.Latitude, poi.Longitude);

            var thumbnail = FindViewById <ImageView>(Resource.Id.Thumbnail);

            thumbnail.SetImageResource(PoiCategoryHelper.GetImage(poi.Category));

            CalculateDownloadSize(poi);
        }
示例#3
0
        private void OnCategoryFilterSelectNone()
        {
            foreach (var category in _context.Settings.Categories)
            {
                if (supportedCategories.Contains(category))
                {
                    var imageButton = _imageButtonCategoryFilter[category];
                    imageButton.SetImageResource(PoiCategoryHelper.GetImage(category, false));
                }
            }

            _context.Settings.Categories.Clear();

            _context.Settings.NotifySettingsChanged(ChangedData.PoiFilterSettings);
        }
示例#4
0
 private void OnCategoryFilterSelectAll()
 {
     foreach (var category in supportedCategories)
     {
         if (_context.Settings.Categories.Contains(category))
         {
             continue;
         }
         else
         {
             var imageButton = _imageButtonCategoryFilter[category];
             _context.Settings.Categories.Add(category);
             imageButton.SetImageResource(PoiCategoryHelper.GetImage(category, true));
         }
     }
     _context.Settings.NotifySettingsChanged(ChangedData.PoiFilterSettings);
 }
示例#5
0
        private void OnCategoryFilterChanged(int resourceId)
        {
            var poiCategory = PoiCategoryHelper.GetCategory(resourceId);
            var imageButton = _imageButtonCategoryFilter[poiCategory];

            if (_context.Settings.Categories.Contains(poiCategory))
            {
                _context.Settings.Categories.Remove(poiCategory);
                imageButton.SetImageResource(PoiCategoryHelper.GetImage(poiCategory, false));
            }
            else
            {
                _context.Settings.Categories.Add(poiCategory);
                imageButton.SetImageResource(PoiCategoryHelper.GetImage(poiCategory, true));
            }

            _context.Settings.NotifySettingsChanged(ChangedData.PoiFilterSettings);
        }
示例#6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            AppContextLiveData.Instance.SetLocale(this);
            Platform.Init(this, savedInstanceState);

            if (AppContextLiveData.Instance.IsPortrait)
            {
                SetContentView(Resource.Layout.EditActivityPortrait);
            }
            else
            {
                SetContentView(Resource.Layout.EditActivityLandscape);
            }

            _id = Intent.GetLongExtra("Id", -1);

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

            SetActionBar(toolbar);

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

            _editTextName      = FindViewById <EditText>(Resource.Id.editTextName);
            _editTextLatitude  = FindViewById <EditText>(Resource.Id.editTextLatitude);
            _editTextLongitude = FindViewById <EditText>(Resource.Id.editTextLongitude);
            _editTextAltitude  = FindViewById <EditText>(Resource.Id.editTextAltitude);
            _buttonFavourite   = FindViewById <ImageView>(Resource.Id.buttonFavourite);
            _buttonOpenWiki    = FindViewById <Button>(Resource.Id.buttonWiki);
            _buttonOpenMap     = FindViewById <Button>(Resource.Id.buttonMap);
            _buttonTeleport    = FindViewById <Button>(Resource.Id.buttonTeleport);
            _spinnerCategory   = FindViewById <Spinner>(Resource.Id.spinnerCategory);
            _spinnerCountry    = FindViewById <Spinner>(Resource.Id.spinnerCountry);

            _spinnerCountry.Adapter = new CountryAdapter(this);

            _spinnerCategory.Adapter = new CategoryAdapter(this);

            _thumbnail = FindViewById <ImageView>(Resource.Id.Thumbnail);

            if (_id != -1)
            {
                _item = Context.Database.GetItem(_id);

                var categoryIndex = (_spinnerCategory.Adapter as CategoryAdapter).GetPosition(_item.Category);
                _spinnerCategory.SetSelection(categoryIndex);

                var countryIndex = (_spinnerCountry.Adapter as CountryAdapter).GetPosition(_item.Country);
                _spinnerCountry.SetSelection(countryIndex);
                _editTextName.Text      = _item.Name;
                _editTextAltitude.Text  = $"{_item.Altitude:F0}";
                _editTextLongitude.Text = $"{_item.Longitude:F7}".Replace(",", ".");
                _editTextLatitude.Text  = $"{_item.Latitude:F7}".Replace(",", ".");

                _thumbnail.SetImageResource(PoiCategoryHelper.GetImage(_item.Category));
            }
            else
            {
                var country      = PoiCountryHelper.GetDefaultCountryByPhoneSettings();
                var countryIndex = (_spinnerCountry.Adapter as CountryAdapter).GetPosition(country);
                _spinnerCountry.SetSelection(countryIndex);
            }

            _buttonFavourite.SetImageResource(_item.Favorite ? Android.Resource.Drawable.ButtonStarBigOn : Android.Resource.Drawable.ButtonStarBigOff);

            _buttonOpenWiki.Enabled    = (string.IsNullOrEmpty(_item.Wikidata) && string.IsNullOrEmpty(_item.Wikipedia)) ? false : true;
            _buttonOpenWiki.Visibility = (string.IsNullOrEmpty(_item.Wikidata) && string.IsNullOrEmpty(_item.Wikipedia)) ? ViewStates.Gone : ViewStates.Visible;

            //finally set-up event listeners
            _editTextName.TextChanged      += OnTextChanged;
            _editTextLatitude.TextChanged  += OnTextChanged;
            _editTextLongitude.TextChanged += OnTextChanged;
            _editTextAltitude.TextChanged  += OnTextChanged;

            _buttonFavourite.SetOnClickListener(this);
            _buttonOpenMap.SetOnClickListener(this);
            _buttonOpenWiki.SetOnClickListener(this);
            _buttonTeleport.SetOnClickListener(this);

            _spinnerCategory.ItemSelected += OnCategorySelected;
            _spinnerCountry.ItemSelected  += OnCountrySelected;
        }
示例#7
0
 private void OnCategorySelected(object sender, AdapterView.ItemSelectedEventArgs e)
 {
     _category = (_spinnerCategory.Adapter as CategoryAdapter)[e.Position] ?? PoiCategory.Other;
     _thumbnail.SetImageResource(PoiCategoryHelper.GetImage(_category));
 }