Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.download);

            listView = (ListView)FindViewById(Android.Resource.Id.List);
            RegisterForContextMenu(listView);
            IEnumerable <GLMapDownloadTask> tasks = GLMapManager.MapDownloadTasks;

            GLMapManager.AddStateListener((IStateListener)this);

            Intent i = Intent;

            center = new MapPoint(i.GetDoubleExtra("cx", 0.0), i.GetDoubleExtra("cy", 0.0));
            long collectionID = i.GetLongExtra("collectionID", 0);

            if (collectionID != 0)
            {
                GLMapInfo collection = GLMapManager.GetMapWithID(collectionID);
                if (collection != null)
                {
                    UpdateAllItems(collection.GetMaps());
                }
            }
            else
            {
                UpdateAllItems(GLMapManager.GetMaps());
                GLMapManager.UpdateMapList(this, new Runnable(() => UpdateAllItems(GLMapManager.GetMaps())));
            }
        }
        internal virtual void updateMapDownloadButtonText()
        {
            if (btnDownloadMap.Visibility == ViewStates.Visible)
            {
                MapPoint center = mapView.MapCenter;

                mapToDownload = GLMapManager.MapAtPoint(center);

                if (mapToDownload != null)
                {
                    string text;
                    if (mapToDownload.State == GLMapInfoState.InProgress)
                    {
                        text = string.Format("Downloading {0} {1}%", mapToDownload.GetLocalizedName(localeSettings), (int)(mapToDownload.DownloadProgress * 100));
                    }
                    else
                    {
                        text = string.Format("Download {0}", mapToDownload.GetLocalizedName(localeSettings));
                    }
                    btnDownloadMap.Text = text;
                }
                else
                {
                    btnDownloadMap.Text = "Download maps";
                }
            }
        }
Exemplo n.º 3
0
        public void UpdateAllItems(GLMapInfo[] maps)
        {
            if (maps == null)
            {
                return;
            }

            GLMapManager.SortMaps(maps, center);
            ListView listView = (ListView)FindViewById(Android.Resource.Id.List);

            listView.Adapter    = new MapsAdapter(maps, this, localeSettings);
            listView.ItemClick += (object sender, ItemClickEventArgs e) => {
                GLMapInfo info = (GLMapInfo)listView.Adapter.GetItem(e.Position);
                if (info.IsCollection)
                {
                    Intent intent = new Intent(this, typeof(DownloadActivity));
                    intent.PutExtra("collectionID", info.MapID);
                    intent.PutExtra("cx", center.X);
                    intent.PutExtra("cy", center.Y);
                    StartActivity(intent);
                }
                else
                {
                    GLMapDownloadTask task = GLMapManager.GetDownloadTask(info);
                    if (task != null)
                    {
                        task.Cancel();
                    }
                    else if (info.State != GLMapInfoState.Downloaded)
                    {
                        GLMapManager.CreateDownloadTask(info, this).Start();
                    }
                }
            };

            listView.ItemLongClick += (object sender, ItemLongClickEventArgs e) => {
                GLMapInfo      info  = ((MapsAdapter)this.listView.Adapter).Maps[e.Position];
                GLMapInfoState state = info.State;
                if (state == GLMapInfoState.Downloaded || state == GLMapInfoState.NeedResume || state == GLMapInfoState.NeedUpdate)
                {
                    selectedMap = info;
                    //return false;
                }
                else
                {
                    //return true;
                }
            };
        }
Exemplo n.º 4
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                GLMapInfo map = maps[position];
                TextView  txtDescription, txtHeaderName;

                if (convertView == null)
                {
                    convertView = LayoutInflater.From(context).Inflate(Resource.Layout.map_name, null);
                }
                txtHeaderName  = ((TextView)convertView.FindViewById(Android.Resource.Id.Text1));
                txtDescription = ((TextView)convertView.FindViewById(Android.Resource.Id.Text2));

                string str = map.GetLocalizedName(localeSettings);

                txtHeaderName.SetText(str.ToCharArray(), 0, str.Length);

                if (map.IsCollection)
                {
                    str = "Collection";
                }
                else if (map.State == GLMapInfoState.Downloaded)
                {
                    str = "Downloaded";
                }
                else if (map.State == GLMapInfoState.NeedUpdate)
                {
                    str = "Need update";
                }
                else if (map.State == GLMapInfoState.NeedResume)
                {
                    str = "Need resume";
                }
                else if (map.State == GLMapInfoState.InProgress)
                {
                    str = string.Format("Download {0:0.00}%", map.DownloadProgress * 100);
                }
                else
                {
                    str = NumberFormatter.FormatSize(map.Size);
                }

                txtDescription.SetText(str.ToCharArray(), 0, str.Length);

                return(convertView);
            }
 public void OnStateChanged(GLMapInfo map)
 {
     updateMapDownloadButtonText();
 }
 public void OnFinishDownloading(GLMapInfo map)
 {
     mapView.ReloadTiles();
 }
 public void OnDownloadProgress(GLMapInfo map)
 {
     updateMapDownloadButtonText();
 }
 public void OnStartDownloading(GLMapInfo map)
 {
 }
Exemplo n.º 9
0
 public void OnStateChanged(GLMapInfo map)
 {
     ((MapsAdapter)listView.Adapter).NotifyDataSetChanged();
 }
Exemplo n.º 10
0
 public void OnFinishDownloading(GLMapInfo map)
 {
 }
Exemplo n.º 11
0
 public void OnDownloadProgress(GLMapInfo map)
 {
     ((MapsAdapter)listView.Adapter).NotifyDataSetChanged();
 }