protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); ListAdapter = new ListAdapter<string>() { DataSource = new[] { "One", "Two", "Three" } }; }
protected override void OnResume() { base.OnResume(); if (_tweets == null) return; _listAdapter = new ListAdapter(this, _tweets); _listView.Adapter = _listAdapter; }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); List<string> items = GetListItems(); _adapter = new ListAdapter(this,items); ListAdapter = _adapter; ListView.SetSelection(items.Count/2); }
protected override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); Preferences.init(this, Tomdroid.CLEAR_PREFERENCES); TLog.d(TAG, "creating shortcut..."); SetContentView(Resource.Layout.shortcuts_list); Title = Resource.String.shortcuts_view_caption; adapter = NoteManager.getListAdapter(this); ListAdapter = adapter; ListView.EmptyView = FindViewById<View>(Resource.Id.list_empty); }
protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); var data = await SongLoader.Load(); ListAdapter = new ListAdapter<Song>() { DataSource = data.ToList(), TextProc = s => s.Name, DetailTextProc = s => s.Artist + " - " + s.Album }; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); view_ = inflater.Inflate(Resource.Layout.timeLine, container, false); list_ = view_.FindViewById <ListView>(Resource.Id.listView1); adapter_ = new ListAdapter(Context.ApplicationContext); swipe_ = view_.FindViewById <SwipeRefreshLayout>(Resource.Id.refresh); swipe_.SetOnRefreshListener(this); swipe_.SetColorSchemeColors(new int[] { Application.Context.GetColor(Resource.Color.red), Application.Context.GetColor(Resource.Color.blue), Application.Context.GetColor(Resource.Color.limegreen) }); return(view_); }
public override bool OnContextItemSelected(IMenuItem item) { var info = (AdapterView.AdapterContextMenuInfo)item.MenuInfo; var note = (Note)ListAdapter.GetItem(info.Position); switch (item.ItemId) { case MENU_ITEM_DELETE: { // Delete the note that the context menu is for NoteRepository.DeleteNote(note); PopulateList(); return(true); } } return(false); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.ListView_layout); GetActivityInstance.UpdateActivity(this); buttonAdd = FindViewById <FloatingActionButton>(Resource.Id.btn_add); recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.HasFixedSize = true; CreatePresenter(savedInstanceState); recyclerView.SetAdapter(itemAdapter = new ListAdapter(this, Presenter.CollectionOfStore)); itemAdapter.ItemClick += OnItemCLick; buttonAdd.Click += buttonAddClick; }
public void Patch_OnNonGenericListObject_Fails() { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new ArrayList(); targetObject.Add(20); targetObject.Add(30); var listAdapter = new ListAdapter(); // Act var addStatus = listAdapter.TryAdd(targetObject, "-", resolver, "40", out var message); // Assert Assert.False(addStatus); Assert.Equal($"The type '{targetObject.GetType().FullName}' which is a non generic list is not supported for json patch operations. Only generic list types are supported.", message); }
private void Rec_DeviceFound(object sender, DeviceFoundEventArgs e) { if (e.Device == null) { return; } if (e.Device.Name == null) { return; } if (e.Device.BondState == Bond.Bonded | e.Device.BondState == Bond.Bonding) { return; } ListAdapter.Add(e.Device.Name); FoundDevices.Add(e.Device); }
public void Add_WithOutOfBoundsIndex_Fails(string position) { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <string>() { "James", "Mike" }; var listAdapter = new ListAdapter(); // Act var addStatus = listAdapter.TryAdd(targetObject, position, resolver, "40", out var message); // Assert Assert.False(addStatus); Assert.Equal($"The index value provided by path segment '{position}' is out of bounds of the array size.", message); }
public void Test_DoesNotThrowException_IfTestIsSuccessful() { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <int>() { 10, 20 }; var listAdapter = new ListAdapter(); // Act var testStatus = listAdapter.TryTest(targetObject, "0", resolver, "10", out var message); //Assert Assert.True(testStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); }
public void Patch_OnNonGenericListObject_Fails() { // Arrange var targetObject = new ArrayList { 20, 30 }; var listAdapter = new ListAdapter(); var options = new JsonSerializerOptions(); // Act var addStatus = listAdapter.TryAdd(targetObject, typeof(ArrayList), "-", options, "40", out var message); // Assert Assert.False(addStatus); Assert.Equal($"The type '{targetObject.GetType().FullName}' which is a non generic list is not supported for json patch operations. Only generic list types are supported.", message); }
public void Patch_WithInvalidPositionFormat_Fails(string position) { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <string>() { "James", "Mike" }; var listAdapter = new ListAdapter(); // Act var addStatus = listAdapter.TryAdd(targetObject, position, resolver, "40", out var message); // Assert Assert.False(addStatus); Assert.Equal($"The path segment '{position}' is invalid for an array index.", message); }
public void ContainsWorksAsExpected() { var wrappedList = new List <Uri>(); var destList = new ListAdapter <string, Uri>( str => new Uri(str), uri => uri.ToString(), (str, uri) => string.Equals(str, uri?.ToString()), wrappedList) { "http://maps.google.com", "http://www.twitter.com" }; destList.Contains("http://www.twitter.com/").Should().BeTrue(); wrappedList.Contains(new Uri("http://www.twitter.com/")).Should().BeTrue(); destList.Contains("mailto:[email protected]").Should().BeFalse(); }
public void Replace_ReplacesValue_AtGivenPosition(string position, List <int> expected) { // Arrange var targetObject = new List <int> { 10, 20 }; var listAdapter = new ListAdapter(); var options = new JsonSerializerOptions(); // Act var replaceStatus = listAdapter.TryReplace(targetObject, typeof(List <int>), position, options, "30", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Equal(expected, targetObject); }
public void Replace_NonCompatibleType_Fails() { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <int>() { 10, 20 }; var listAdapter = new ListAdapter(); // Act var replaceStatus = listAdapter.TryReplace(targetObject, "-", resolver, "James", out var message); // Assert Assert.False(replaceStatus); Assert.Equal("The value 'James' is invalid for target location.", message); }
public void AddingValueWrapsItInOtherList() { var wrappedList = new List <Uri>(); var destList = new ListAdapter <string, Uri>( str => new Uri(str), uri => uri.ToString(), (str, uri) => string.Equals(str, uri?.ToString()), wrappedList) { "http://maps.google.com" }; destList.Count.Should().Be(wrappedList.Count); destList.IsReadOnly.Should().Be(((IList <Uri>)wrappedList).IsReadOnly); wrappedList[0].Should().BeOfType <Uri>(); destList[0].Should().Be(wrappedList[0].ToString()); }
public void Test_ThrowsJsonPatchException_IfTestFails() { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <int>() { 10, 20 }; var listAdapter = new ListAdapter(); var expectedErrorMessage = "The current value '20' at position '1' is not equal to the test value '10'."; // Act var testStatus = listAdapter.TryTest(targetObject, "1", resolver, "10", out var errorMessage); //Assert Assert.False(testStatus); Assert.Equal(expectedErrorMessage, errorMessage); }
public override bool OnContextItemSelected(IMenuItem item) { var info = (AdapterView.AdapterContextMenuInfo)item.MenuInfo; var bug = (BugModel)ListAdapter.GetItem(info.Position); switch (item.ItemId) { case Resource.Id.markFixedBug: BugRepository.MarkAsFixed(bug.Id); Toast.MakeText(this, Resource.String.bugSaved, ToastLength.Short).Show(); PopulateList(); break; } return(base.OnContextItemSelected(item)); }
public void Test_ThrowsJsonPatchException_IfListPositionOutOfBounds() { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <int>() { 10, 20 }; var listAdapter = new ListAdapter(); var expectedErrorMessage = "The index value provided by path segment '2' is out of bounds of the array size."; // Act var testStatus = listAdapter.TryTest(targetObject, "2", resolver, "10", out var errorMessage); //Assert Assert.False(testStatus); Assert.Equal(expectedErrorMessage, errorMessage); }
// Update is called once per frame void Update() { if (Input.GetKeyDown("i")) { IListAdapter adapter = new ListAdapter(data, new SingleTextItemAdapter()); ScrollList.SetAdapter(adapter); } if (Input.GetKeyDown("a")) { data.Add(new TextData("new Item")); } if (Input.GetKeyDown("m")) { ScrollList.SmoothScrollByOffset(4); } }
public void Replace_ReplacesValue_AtGivenPosition(string position, List <int> expected) { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <int>() { 10, 20 }; var listAdapter = new ListAdapter(); // Act var replaceStatus = listAdapter.TryReplace(targetObject, position, resolver, "30", out var message); // Assert Assert.True(replaceStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Equal(expected, targetObject); }
public override void OnBackPressed() { base.OnBackPressed(); //更新绑定用户 var array = ListView.CheckedItemPositions; Storage.BindUsers.Clear(); for (int i = 0; i < array.Size(); i++) { if (!array.ValueAt(i)) { continue; } int index = array.KeyAt(i); Storage.BindUsers.Add(ListAdapter.GetItem(index).ToString()); } Storage.IsAssigned = true; }
public override bool OnContextItemSelected(IMenuItem item) { var info = (AdapterView.AdapterContextMenuInfo)item.MenuInfo; var project = (ProjectModel)ListAdapter.GetItem(info.Position); switch (item.ItemId) { case Resource.Id.editProject: StartAddProject(project.Id, typeof(AddProjectActivity)); break; case Resource.Id.deleteProject: _selectedProject = project.Id; ShowDialog(ALERT_DELETE_DIALOG); break; } return(base.OnContextItemSelected(item)); }
/// <summary> /// Creates an adaptive load balancer with the function that scores the items in the list. /// </summary> /// <param name="scorer">the scoring function</param> /// <param name="items">the list of items to load balance (if null will create an empty list)</param> public UpdateableAdaptiveLoadBalancer(Func <T, int> scorer, IList <T> items = null) { adaptiveBalancer = new AdaptiveLoadBalancer <Updateable <T> >(Adapt(scorer)); Resources = new ListAdapter <T, Updateable <T> >( external => new Updateable <T>(external), intItem => intItem.Item, (extItem, intItem) => extItem.Equals(intItem.Item), adaptiveBalancer.Resources); if (items == null) { return; } foreach (var val in items) { Resources.Add(val); } }
public void ClearAffectsBothLists() { var wrappedList = new List <Uri>(); var destList = new ListAdapter <string, Uri>( str => new Uri(str), uri => uri.ToString(), (str, uri) => string.Equals(str, uri?.ToString()), wrappedList) { "http://maps.google.com", "http://www.twitter.com" }; wrappedList.Count.Should().Be(2); destList.Clear(); wrappedList.Count.Should().Be(0); destList.Count.Should().Be(0); }
/// <summary> /// Loading more 10 tweets /// </summary> private void LoadMoreTweets() { RunOnUiThread(() => { _headerButton.Text = "Loading"; }); var newTweets = TwitterManager.GetTweets(10, _tweets[_tweets.Count - 1].Id); if (newTweets != null && newTweets.Count != 0) { _tweets.AddRange(newTweets); RunOnUiThread(() => { _listAdapter = new ListAdapter(this, _tweets); _listAdapter.NotifyDataSetChanged(); _listView.InvalidateViews(); }); } RunOnUiThread(() => { _headerButton.Text = "Load older tweets"; }); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.FragmentInputLayout, container, false); _listViewInputPorts = view.FindViewById <ListView>(Resource.Id.listViewInputPorts); _listViewInputPorts.Divider = null; _listViewInputPorts.DividerHeight = 0; _listAdapter = new ListAdapter(Activity, _inputViewModels); _listViewInputPorts.Adapter = _listAdapter; // When we are already connected we can load the intpu devices here if (FtInterfaceInstanceProvider.Instance != null && FtInterfaceInstanceProvider.Instance.Connection == ConnectionStatus.Online) { InitializeInputDevices(); } return(view); }
public void Add_NullObject_ToReferenceTypeListWorks() { // Arrange var listAdapter = new ListAdapter(); var targetObject = new List <string> { "James", "Mike" }; var options = new JsonSerializerOptions(); // Act var addStatus = listAdapter.TryAdd(targetObject, typeof(List <string>), "-", options, null, out var message); // Assert Assert.True(addStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Equal(3, targetObject.Count); Assert.Equal(new List <string> { "James", "Mike", null }, targetObject); }
public void Add_WithIndexSameAsNumberOfElements_Works() { // Arrange var targetObject = new List <string> { "James", "Mike" }; var listAdapter = new ListAdapter(); var position = targetObject.Count.ToString(); var options = new JsonSerializerOptions(); // Act var addStatus = listAdapter.TryAdd(targetObject, typeof(List <string>), position, options, "Rob", out var message); // Assert Assert.Null(message); Assert.True(addStatus); Assert.Equal(3, targetObject.Count); Assert.Equal(new List <string> { "James", "Mike", "Rob" }, targetObject); }
public void CanCopyToArray() { var destList = new ListAdapter <string, Uri>( str => new Uri(str), uri => uri.ToString(), (str, uri) => string.Equals(str, uri?.ToString()), new List <Uri>()) { "http://maps.google.com", "http://www.twitter.com" }; var array = new string[2]; destList.CopyTo(array, 0); for (var i = 0; i < array.Length; i++) { array[i].Should().Be(destList[i]); } }
public void RemoveAtRemovesItemByIndex() { var wrappedList = new List <Uri>(); var destList = new ListAdapter <string, Uri>( str => new Uri(str), uri => uri.ToString(), (str, uri) => string.Equals(str, uri?.ToString()), wrappedList) { "http://maps.google.com", "http://www.twitter.com" }; wrappedList.Count.Should().Be(2); destList.RemoveAt(0); wrappedList.Count.Should().Be(1); wrappedList[0].ToString().Should().Be("http://www.twitter.com/"); destList[0].Should().Be(wrappedList[0].ToString()); }
public void Add_CompatibleTypeWorks() { // Arrange var sDto = new SimpleObject(); var iDto = new InheritedObject(); var targetObject = new List <SimpleObject> { sDto }; var listAdapter = new ListAdapter(); var options = new JsonSerializerOptions(); // Act var addStatus = listAdapter.TryAdd(targetObject, typeof(List <SimpleObject>), "-", options, iDto, out var message); // Assert Assert.True(addStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Equal(2, targetObject.Count); Assert.Equal(new List <SimpleObject> { sDto, iDto }, targetObject); }
public void Add_NullObject_ToReferenceTypeListWorks() { // Arrange var resolver = new DefaultContractResolver(); var listAdapter = new ListAdapter(); var targetObject = new List <string>() { "James", "Mike" }; // Act var addStatus = listAdapter.TryAdd(targetObject, "-", resolver, value: null, errorMessage: out var message); // Assert Assert.True(addStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Equal(3, targetObject.Count); Assert.Equal(new List <string>() { "James", "Mike", null }, targetObject); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); CommonUtils.SetFullScreen(this); SetContentView(Resource.Layout.Main); _listView = FindViewById<ListView>(Resource.Id.List); _listAdapter = new ListAdapter(this, new List<Tweet>()); var footerView = ((LayoutInflater) GetSystemService(LayoutInflaterService)).Inflate(Resource.Layout.FooterView, null); _headerButton = footerView.FindViewById<Button>(Resource.Id.buttonMoreFooter); _headerButton.Text = "Loading"; _listView.AddFooterView(footerView); _listView.Adapter = _listAdapter; ThreadPool.QueueUserWorkItem(lt => LoadTweets()); FindViewById<Button>(Resource.Id.buttonFavourites).Click += delegate { CommonUtils.StartNewActivity(this, typeof (FavouritesActivity)); }; }
public void Add_WithIndexSameAsNumberOfElements_Works() { // Arrange var resolver = new DefaultContractResolver(); var targetObject = new List <string>() { "James", "Mike" }; var listAdapter = new ListAdapter(); var position = targetObject.Count.ToString(CultureInfo.InvariantCulture); // Act var addStatus = listAdapter.TryAdd(targetObject, position, resolver, "Rob", out var message); // Assert Assert.Null(message); Assert.True(addStatus); Assert.Equal(3, targetObject.Count); Assert.Equal(new List <string>() { "James", "Mike", "Rob" }, targetObject); }
/// <summary> /// Loading tweets on application start /// </summary> private void LoadTweets() { _tweets = TwitterManager.GetTweets(20, null); var listAdapter = new ListAdapter(this, _tweets); RunOnUiThread(() => { _listView.Adapter = listAdapter; listAdapter.NotifyDataSetChanged(); _listView.InvalidateViews(); _headerButton.Text = "Load older tweets"; _headerButton.Click += delegate { ThreadPool.QueueUserWorkItem(lm => LoadMoreTweets()); }; }); }