private void SetActionBar() { if (m_Editing) { SetupEditActionBar(); return; } if (m_AllTasks.Where(t => t.Checked).Count() > 0) { SetupDeleteActionBar(); } else { SetupMainActionBar(); } }
public void Get_MyContact(int lastId = 0) { try { RunOnUiThread(() => { if (AppSettings.ConnectivitySystem == "1") // Following { SupportActionBar.Title = GetText(Resource.String.Lbl_Following); } else // Friend { SupportActionBar.Title = GetText(Resource.String.Lbl_Friends); } }); //Get All User From Database var dbDatabase = new SqLiteDatabase(); var localList = dbDatabase.Get_MyContact(lastId, 25); if (localList != null) { RunOnUiThread(() => { var list = new JavaList <Classes.UserContacts.User>(localList); if (list.Count > 0) { var listNew = list?.Where(c => !UserContactsList.Select(fc => fc.UserId).Contains(c.UserId)).ToList(); if (listNew.Count > 0) { Classes.AddRange(UserContactsList, listNew); var listOrder = new JavaList <Classes.UserContacts.User>(UserContactsList.OrderBy(a => a.Name)); ContactAdapter.mMyContactsList = new JavaList <Classes.UserContacts.User>(listOrder); ContactAdapter.ItemClick += ContactAdapter_OnItemClick; ContactAdapter.NotifyDataSetChanged(); } else { if (ShowSnackbar) { ShowSnackbar = false; } Get_Contacts_APi(); } if (swipeRefreshLayout != null) { swipeRefreshLayout.Refreshing = false; } } else { if (ShowSnackbar) { ShowSnackbar = false; } Get_Contacts_APi(); } //Set Event Scroll if (OnMainScrolEvent == null) { var xamarinRecyclerViewOnScrollListener = new XamarinRecyclerViewOnScrollListener(ContactsLayoutManager, swipeRefreshLayout); OnMainScrolEvent = xamarinRecyclerViewOnScrollListener; OnMainScrolEvent.LoadMoreEvent += MyContact_OnScroll_OnLoadMoreEvent; ContactsRecyler.AddOnScrollListener(OnMainScrolEvent); ContactsRecyler.AddOnScrollListener(new ScrollDownDetector()); } else { OnMainScrolEvent.IsLoading = false; } }); } else { Get_Contacts_APi(); } dbDatabase.Dispose(); if (UserContactsList?.Count <= 24 || UserContactsList?.Count == 0) { Get_Contacts_APi(); } } catch (Exception e) { Console.WriteLine(e); } }
public void Get_MyContact(int lastId = 0) { try { RunOnUiThread(() => { if (Settings.ConnectivitySystem == "1") // Following { SupportActionBar.Title = GetText(Resource.String.Lbl_Following); } else // Friend { SupportActionBar.Title = GetText(Resource.String.Lbl_Friends); } }); //Get All User From Database var dbDatabase = new SqLiteDatabase(); var localList = dbDatabase.Get_MyContact(lastId, 25); if (localList != null) { RunOnUiThread(() => { var list = new JavaList <Classes.UserContacts.User>(localList); if (list.Count > 0) { var listNew = list?.Where(c => !UserContactsList.Select(fc => fc.user_id).Contains(c.user_id)).ToList(); if (listNew.Count > 0) { Classes.AddRange(UserContactsList, listNew); var listOrder = new JavaList <Classes.UserContacts.User>(UserContactsList.OrderBy(a => a.name)); if (MyContactsAdapter == null) { //Results differ MyContactsAdapter = new MyContacts_Adapter(this, listOrder, ContactsRecyler); ContactsRecyler.SetAdapter(MyContactsAdapter); MyContactsAdapter.ItemClick += MyContactsAdapter_OnItemClick; var lastCountItem = MyContactsAdapter.ItemCount; MyContactsAdapter.NotifyItemRangeInserted(lastCountItem, listNew.Count); } else { MyContactsAdapter.mMyContactsList = new JavaList <Classes.UserContacts.User>(listOrder); var lastCountItem = MyContactsAdapter.ItemCount; MyContactsAdapter.NotifyItemRangeInserted(lastCountItem, listNew.Count); } } else { if (ShowSnackbar) { Snackbar.Make(ContactsRecyler, GetText(Resource.String.Lbl_Loading_From_Server), Snackbar.LengthLong).Show(); ShowSnackbar = false; } Get_Contacts_APi(); } if (swipeRefreshLayout != null) { swipeRefreshLayout.Refreshing = false; } } else { if (ShowSnackbar) { Snackbar.Make(ContactsRecyler, GetText(Resource.String.Lbl_Loading_From_Server), Snackbar.LengthLong).Show(); ShowSnackbar = false; } Get_Contacts_APi(); } //Set Event Scroll if (OnMainScrolEvent == null) { var xamarinRecyclerViewOnScrollListener = new XamarinRecyclerViewOnScrollListener(ContactsLayoutManager, swipeRefreshLayout); OnMainScrolEvent = xamarinRecyclerViewOnScrollListener; OnMainScrolEvent.LoadMoreEvent += MyContact_OnScroll_OnLoadMoreEvent; ContactsRecyler.AddOnScrollListener(OnMainScrolEvent); ContactsRecyler.AddOnScrollListener(new ScrollDownDetector()); } else { OnMainScrolEvent.IsLoading = false; } }); } else { if (ShowSnackbar) { Snackbar.Make(ContactsRecyler, GetText(Resource.String.Lbl_Loading_From_Server), Snackbar.LengthLong).Show(); ShowSnackbar = false; } Get_Contacts_APi(); } dbDatabase.Dispose(); if (UserContactsList?.Count <= 24 || UserContactsList?.Count == 0) { swipeRefreshLayout.Refreshing = true; Get_Contacts_APi(); } } catch (Exception e) { Crashes.TrackError(e); } }