Exemplo n.º 1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.SearchPerson);
            ToolBar        = FindViewById <SupportToolBar>(Resource.Id.toolbar);
            SearchUserView = FindViewById <SupportRecyclerView>(Resource.Id.searchUserList);

            SetSupportActionBar(ToolBar);
            SupportActionBar.Title = "Select Person";

            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            UsersDatabase db = new UsersDatabase();

            ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private);
            String             Date = info.GetString(Application.Context.GetString(Resource.String.ModifyDate), String.Empty);

            ProgressDialog progressDialog = ProgressDialog.Show(this, "", "Loading, please wait...", true);

            List <UserListItem> tmp = await MeritMoneyBrain.GetListOfUsers(modifyAfter : Date);

            if (db.IsExist())
            {
                db.Merge(tmp);
            }
            else
            {
                db.CreateDatabase();
                db.Insert(tmp);
            }

            SearchUsersList = db.GetUsers();

            progressDialog.Dismiss();

            RecyclerViewManager = new LinearLayoutManager(this);
            SearchUserView.SetLayoutManager(RecyclerViewManager);
            RecyclerViewAdapter = new UsersAdapter(SearchUsersList, this);
            SearchUserView.SetAdapter(RecyclerViewAdapter);

            for (int i = 0; i < SearchUsersList.Count; i++)
            {
                new CacheListItemImage(RecyclerViewAdapter, i, Application.Context).Execute(SearchUsersList[i]);
            }

            //ToolBar.MenuItemClick += ToolBar_MenuItemClick;
        }
Exemplo n.º 2
0
        bool SupportSearchView.IOnQueryTextListener.OnQueryTextChange(string newText)
        {
            String text = newText.ToLower();
            List <UserListItem> newList = new List <UserListItem>();

            foreach (UserListItem user in SearchUsersList)
            {
                String name  = user.name.ToLower();
                String email = user.email.ToLower();
                if (name.Contains(text) || email.Contains(text))
                {
                    newList.Add(user);
                }
            }
            RecyclerViewAdapter = new UsersAdapter(newList, this);
            SearchUserView.SetAdapter(RecyclerViewAdapter);

            return(true);
        }