コード例 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.EventList, container, false);

            listview = view.FindViewById <RecyclerView>(Resource.Id.eventsView);

            if (Context.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape)
            {
                listview.LayoutParameters.Height = LayoutParams.WrapContent;
            }

            theview = view;

            listAdapter = new EventAdapter(container.Context);

            listAdapter.UpdateData(events, eventviewtype);
            listAdapter.Capture     += ListAdapter_Capture;
            listAdapter.Edit        += ListAdapter_Edit;
            listAdapter.Share       += ListAdapter_Share;
            listAdapter.ShowMore    += ListAdapter_ShowMore;
            listAdapter.MakeShoot   += ListAdapter_MakeShoot;
            listAdapter.OnEnterCode += ListAdapter_OnEnterCode;
            listAdapter.HasStableIds = true;

            // use a linear layout manager
            if (eventviewtype == EventAdapter.EventViewType.FEATURED)
            {
                var lm = new LinearLayoutManager(Context, (int)Orientation.Horizontal, false);
                listview.SetLayoutManager(lm);
                view.FindViewById <SwipeRefreshLayout>(Resource.Id.swiperefresh).Enabled = false;
                listview.SetPadding(Utils.dp2px(Context, 30), 0, Utils.dp2px(Context, 30), 0);
                listview.NestedScrollingEnabled = true;
            }
            else
            {
                var mLayoutManager = new GridLayoutManager(container.Context, Activity.Resources.Configuration.Orientation == Android.Content.Res.Orientation.Landscape ? 2 : 1);
                mLayoutManager.SetSpanSizeLookup(new MySpanSizeLookup(Activity, listAdapter));
                listview.SetLayoutManager(mLayoutManager);
            }

            if (eventviewtype == EventAdapter.EventViewType.NEARBY_SINGLE)
            {
                //do nothing?
                var lm = new LinearLayoutManager(Context, (int)Orientation.Horizontal, false);
                listview.SetLayoutManager(lm);
                view.FindViewById <SwipeRefreshLayout>(Resource.Id.swiperefresh).Enabled = false;
            }

            listview.SetAdapter(listAdapter);

            listview.AddOnScrollListener(new PausableScrollListener(Context, listAdapter));
            view.FindViewById <SwipeRefreshLayout>(Resource.Id.swiperefresh).Refresh += Events_Refresh;

            view.FindViewById <View>(Resource.Id.swiperefresh).Visibility = ViewStates.Visible;

            return(view);
        }
コード例 #2
0
        //EventAdapter.EventViewType viewtype;

        public void LoadEvents(List <Shoot> events, Shoot parent, EventAdapter.EventViewType ev)
        {
            this.events        = events;
            this.parent        = parent;
            this.eventviewtype = ev;
            if (listAdapter == null)
            {
                listAdapter = new EventAdapter(Activity);
            }
            listAdapter.UpdateData(events, ev);
        }
コード例 #3
0
 public MySpanSizeLookup(Activity activity, EventAdapter adapter)
 {
     this.adapter  = adapter;
     this.activity = activity;
 }
コード例 #4
0
        public async Task RefreshMe(bool manually)
        {
            try
            {
                if (!string.IsNullOrEmpty(propertyname))
                {
                    if (listAdapter == null)
                    {
                        listAdapter = new EventAdapter(Activity);
                    }

                    listAdapter.FlushFilter();
                    events = Bootlegger.BootleggerClient.GetType().GetProperty(propertyname).GetValue(Bootlegger.BootleggerClient) as List <Shoot>;
                    //events = data;

                    listAdapter.UpdateData(events, eventviewtype);

                    //run loader on initial set:
                    Loading = true;

                    if (manually)
                    {
                        if ((Context.ApplicationContext as BootleggerApp).IsReallyConnected)
                        {
                            try
                            {
                                await updater(canceller);
                            }
                            catch (TaskCanceledException)
                            {
                                //do nothing...
                            }
                            catch (Exception)
                            {
                                OnError?.Invoke(new Exception(Resources.GetString(Resource.String.noconnectionshort)));
                            }
                        }
                        events = Bootlegger.BootleggerClient.GetType().GetProperty(propertyname).GetValue(Bootlegger.BootleggerClient) as List <Shoot>;
                        listAdapter.UpdateData(events, eventviewtype);
                    }
                    //listAdapter.UpdateData(events, eventviewtype);
                    Loading = false;

                    // Whitelabel - if there is only 1 event:
                    if (eventviewtype == EventAdapter.EventViewType.FEATURED && WhiteLabelConfig.ALLOW_SINGLE_SHOOT)
                    {
                        if (events.Count == 1 && Bootlegger.BootleggerClient.CurrentUser != null)
                        {
                            var diag = new Android.Support.V7.App.AlertDialog.Builder(Context)
                                       .SetTitle(Resource.String.single_shoot_title)
                                       .SetMessage(Resource.String.single_shoot_msg)
                                       .SetPositiveButton(Resource.String.continuebtn, (o, e) =>
                            {
                                var ev = events[0];
                                OnConnect((string.IsNullOrEmpty(ev.group)) ? ev : ev.events[0]);
                            })
                                       .SetNegativeButton(Android.Resource.String.Cancel, (o, e) =>
                            {
                            })
                                       .Show();
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (Activity != null)
                {
                    //failed to refresh for some reason
                    OnError?.Invoke(new Exception(Resources.GetString(Resource.String.noconnectionshort)));
                }
            }
        }
コード例 #5
0
            public ViewHolder(View itemView, Action <Shoot> capture, Action <Shoot> edit, Action showmore, Action <Shoot> share, Action <string> entercode, EventViewType buttons, EventAdapter adpt, int tiletype) : base(itemView)
            {
                this.capture   = capture;
                this.edit      = edit;
                view           = itemView;
                this.buttons   = buttons;
                this.showmore  = showmore;
                this.adpt      = adpt;
                this.share     = share;
                this.entercode = entercode;

                if (tiletype == (int)TileType.MYEVENTSTITLE)
                {
                    //do nothing -- its the title
                }
                else
                {
                    if (buttons == EventViewType.MYEVENT)
                    {
                        view.Click += (sender, e) =>
                        {
                            if (currentevent != null)
                            {
                                edit(currentevent);
                            }
                        };

                        //view.FindViewById<ImageButton>(Resource.Id.capturebtn).Click += (sender, e) =>
                        //{
                        //    if (currentevent != null)
                        //        capture(currentevent);
                        //};
                        //view.FindViewById<ImageButton>(Resource.Id.editbtn).Click += (sender, e) =>
                        //{
                        //    if (currentevent != null)
                        //        edit(currentevent);
                        //};
                    }
                    else
                    {
                        view.Click += View_Click;
                    }

                    if (view.FindViewById <ImageButton>(Resource.Id.sharebtn) != null)
                    {
                        if (WhiteLabelConfig.EXTERNAL_LINKS)
                        {
                            view.FindViewById <ImageButton>(Resource.Id.sharebtn).Click += ViewHolder_Click;
                        }
                        else
                        {
                            view.FindViewById <ImageButton>(Resource.Id.sharebtn).Visibility = ViewStates.Gone;
                        }
                    }

                    if (view.FindViewById <EditText>(Resource.Id.code) != null)
                    {
                        view.FindViewById <EditText>(Resource.Id.code).TextChanged += ViewHolder_TextChanged;
                    }
                }
            }