public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            this.EnsureBindingContextIsSet(savedInstanceState);
            var view = this.BindingInflate(Resource.Layout.FriendsFragmentView, container, false);

            friendsListView = view.FindViewById <ListView>(Resource.Id.friendsList);
            progress        = view.FindViewById <ProgressBar>(Resource.Id.busyIndicator);

            friendsAdapter          = new FriendsAdapter(this.Activity, ViewModel);
            friendsListView.Adapter = friendsAdapter;

            friendsListener = new MvxPropertyChangedListener(ViewModel).Listen(() => ViewModel.Friends, (sender, e) =>
            {
                friendsAdapter.NotifyDataSetChanged();
            });

            friendsListView.ItemClick += (sender, e) =>
            {
                var selected = ViewModel.Friends[e.Position];
                ViewModel.NavigateToCreateMessageCommand.Execute(selected);
            };

            return(view);
        }
Example #2
0
        public static FriendsAdapter GetFriendsAdapter()
        {
            if (friendsAdapter == null)
            {
                Console.WriteLine("Creating friends adapter");
                friendsAdapter = new FriendsAdapter(SteamAlerts.GetContext());
            }

            return(friendsAdapter);
        }
        private void MSearch_TextChanged(object sender, Android.Text.TextChangedEventArgs e)
        {
            List <Friend> searchedFriends = (from friend in mFriends
                                             where friend.FirstName.Contains(mSearch.Text, StringComparison.OrdinalIgnoreCase) || friend.LastName.Contains(mSearch.Text, StringComparison.OrdinalIgnoreCase) ||
                                             friend.Age.Contains(mSearch.Text, StringComparison.OrdinalIgnoreCase) || friend.Gender.Contains(mSearch.Text, StringComparison.OrdinalIgnoreCase)
                                             select friend).ToList <Friend>();

            mAdapter          = new FriendsAdapter(this, Resource.Layout.row_friend, searchedFriends);
            mListView.Adapter = mAdapter;
        }
Example #4
0
        /// <summary>
        /// Returns the friend with the specified steam id
        /// </summary>
        /// <param name="steamId"></param>
        /// <returns></returns>
        public static Friend GetFriendBySteamId(String steamId)
        {
            FriendsAdapter adapter = SteamAdapters.GetFriendsAdapter();

            for (int i = 0; i < adapter.Count; i++)
            {
                if (adapter.GetFriendAt(i).SteamId.ToString() == steamId)
                {
                    return(adapter.GetFriendAt(i));
                }
            }

            throw new Exception("Error retrieving friend by Steam ID: " + steamId);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.AnimatedList);

            mListView  = FindViewById <ListView>(Resource.Id.listView);
            mSearch    = FindViewById <EditText>(Resource.Id.etSearch);
            mContainer = FindViewById <LinearLayout>(Resource.Id.llContainer);

            mSearch.Alpha        = 0;
            mSearch.TextChanged += MSearch_TextChanged;

            mFriends = new List <Friend>();
            mFriends.Add(new Friend {
                FirstName = "Arnold", LastName = "McFlight", Age = "30", Gender = "male"
            });
            mFriends.Add(new Friend {
                FirstName = "Will", LastName = "Smith", Age = "40", Gender = "male"
            });
            mFriends.Add(new Friend {
                FirstName = "Jhon", LastName = "McClain", Age = "50", Gender = "male"
            });
            mFriends.Add(new Friend {
                FirstName = "Joe", LastName = "Mortog", Age = "36", Gender = "male"
            });
            mFriends.Add(new Friend {
                FirstName = "Jim", LastName = "Carrey", Age = "35", Gender = "male"
            });
            mFriends.Add(new Friend {
                FirstName = "Ethan", LastName = "Hunt", Age = "32", Gender = "male"
            });
            mFriends.Add(new Friend {
                FirstName = "Jason", LastName = "Burn", Age = "37", Gender = "male"
            });
            mFriends.Add(new Friend {
                FirstName = "Sylvestre", LastName = "Stallone", Age = "38", Gender = "male"
            });

            mAdapter          = new FriendsAdapter(this, Resource.Layout.row_friend, mFriends);
            mListView.Adapter = mAdapter;
        }
Example #6
0
        protected override void OnListItemClick(ListView l, View v, int position, long id)
        {
            base.OnListItemClick(l, v, position, id);

            FriendsAdapter adapter = SteamAdapters.GetFriendsAdapter();
            Friend         friend  = adapter.GetFriendAt(position);

            if (SteamService.GetClient().Friends.GetPersonaState() == SteamKit2.EPersonaState.Offline)
            {
                SteamAlerts.ShowToast("Your state is set to offline");
            }
            else if (friend.State == SteamKit2.EPersonaState.Offline)
            {
                SteamAlerts.ShowToast(friend.Name + " is offline");
            }
            else
            {
                Intent chatIntent = new Intent(this, typeof(Chat));
                chatIntent.PutExtra("steam_id", friend.SteamId.ToString());
                StartActivity(chatIntent);
            }
        }