Beispiel #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;
        }
Beispiel #2
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            FrameLayout MainLayout = new FrameLayout(this);

            SetContentView(MainLayout);
            base.CombineWith(MainLayout, Resource.Layout.History, ActivityIs.History);

            MainToolbar = FindViewById <SupportToolBar>(Resource.Id.toolbar);
            TabLayout   = FindViewById <SupportTabLayout>(Resource.Id.tabLayout);
            ViewPager   = FindViewById <SupportViewPager>(Resource.Id.viewPager);

            MainToolbar.Title = "History";
            String LastHistoryItemDate = String.Empty;

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

            if (NetworkStatus.State != NetworkState.Disconnected)
            {
                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);
                LastHistoryItemDate = info.GetString(Application.Context.GetString(Resource.String.HistoryLoadedDate), "0");

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

                if (db.IsExist())
                {
                    db.Update(tmp);
                }
                else
                {
                    db.CreateDatabase();
                    db.Insert(tmp);
                }
            }
            else
            {
                StartActivity(new Intent(this, typeof(NoInternetActivity)));
            }

            progressDialog.Dismiss();

            var db2   = new UsersDatabase();
            var Users = db2.GetUsers();

            ViewPagerAdapter = new ViewPagerAdapter(SupportFragmentManager);
            ViewPagerAdapter.AddFragments(new HistoryFragment(HistoryType.Personal,
                                                              LastHistoryItemDate,
                                                              NetworkStatus,
                                                              Users),
                                          new Java.Lang.String("Personal"));
            ViewPagerAdapter.AddFragments(new HistoryFragment(HistoryType.Company,
                                                              LastHistoryItemDate,
                                                              NetworkStatus,
                                                              Users),
                                          new Java.Lang.String("Company"));
            ViewPager.Adapter = ViewPagerAdapter;

            TabLayout.SetupWithViewPager(ViewPager);
        }