Ejemplo n.º 1
0
 private void RefreshFromData(bool fromPull = false)
 {
     // need to load it
     parent.InitializeSolSys((theSystem) =>
     {
         this.Activity.RunOnUiThread(() =>
         {
             UpdateForNewSystem();
             if (fromPull)
             {
                 planetList.OnRefreshCompleted();
             }
         });
     });
 }
Ejemplo n.º 2
0
        private void RefreshFromServer(bool fromPullDown = false)
        {
            PhabrikServer.FetchKnownSystems((resultList) =>
            {
                resultList.Sort((obj1, obj2) =>
                {
                    int loc1 = obj1.xLoc * obj1.xLoc + obj1.yLoc * obj1.yLoc + obj1.zLoc * obj1.zLoc;
                    int loc2 = obj2.xLoc * obj2.xLoc + obj2.yLoc * obj2.yLoc + obj2.zLoc * obj2.zLoc;

                    if (loc1 < loc2)
                    {
                        return(-1);
                    }
                    else if (loc1 > loc2)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                });
                this.Activity.RunOnUiThread(() =>
                {
                    header.Text = string.Format("{0} known systems", resultList.Count);
                    if (adapter == null)
                    {
                        if (adapter == null)
                        {
                            adapter = new SolSysListAdapter(this, resultList);
                        }
                        systemList.Adapter = adapter;
                        RefreshListView();
                    }

                    if (fromPullDown)
                    {
                        systemList.OnRefreshCompleted();
                    }
                });
            });
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            //TabLayoutResource = Resource.Layout.Tabbar;
            //ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            #region  拉列表显示效果

            mainActivity = this;

            SetContentView(Resource.Layout.main);

            PullToRefresharp.Android.Widget.ListView lv = (PullToRefresharp.Android.Widget.ListView)FindViewById(Resource.Id.myGridView1);
            //lv.Adapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, ITEMS);

            List <Students> studentsList = new List <Students>();
            for (int i = 0; i < 10; i++)
            {
                Students stu = new Students
                {
                    photo = "user.png",
                    name  = "name" + i,
                    age   = 10 + i,
                    //sex = item.sex,
                };
                studentsList.Add(stu);
            }
            lv.Adapter = new MyAdapter(studentsList, Android.App.Application.Context);


            lv.RefreshActivated += (e, s) =>
            {
                Task.Delay(1000).ContinueWith((t) =>
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        lv.OnRefreshCompleted();
                    });
                });
            };

            lv.SetMenuCreator(new LvSwipeMenuCreator());

            lv.SetOnMenuItemClickListener(new LvMenuItemClickListener());

            LvSwipeListener swipeListener = new LvSwipeListener();

            lv.SetOnSwipeListener(swipeListener);
            #endregion

            #region 自定义adapater
            //ListView lv = new ListView(this);
            //lv.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, ITEMS);

            #endregion

            #region com.Swipelistview
            //SetContentView(Resource.Layout.activity_main);
            //Com.Fortysevendeg.Swipelistview.SwipeListView lv = (Com.Fortysevendeg.Swipelistview.SwipeListView)FindViewById(Resource.Id.example_lv_list);
            //lv.Adapter= new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, ITEMS);

            #endregion

            //LoadApplication(new App());
        }