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); }
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))); } } }