Пример #1
0
        public async void Search()
        {
            var json = await _fetch.GetJson(_url.Search(query, page), token);

            var searchedRepos = await ParseManager.Parse <Repos>(json);

            totalPages = (int)Math.Ceiling(searchedRepos.Total / 10);
            repos      = searchedRepos.Data;

            if (page == 1)
            {
                previousPage.Enabled = false;
            }
            else
            {
                previousPage.Enabled = true;
            }

            if (totalPages == 1)
            {
                nextPage.Enabled      = false;
                navigation.Visibility = ViewStates.Gone;
            }
            else
            {
                nextPage.Enabled      = true;
                navigation.Visibility = ViewStates.Visible;
            }

            pageInfo.Text = $"Page: {page} of {totalPages}";

            listView.Adapter = new RepoListAdapter(this, token, user, repos);
        }
Пример #2
0
 private void ParseFiles(List <string> filePaths)
 {
     Parallel.ForEach(filePaths, filePath =>
     {
         _parseManager.Parse(filePath);
     });
 }
Пример #3
0
        /// <summary>
        /// Gets the commits and binds to the ListView
        /// </summary>
        private async Task GetCommits()
        {
            var commitsJson = await _fetch.GetJson(_url.Commits(MainActivity.repo), MainActivity.token);

            commits = await ParseManager.Parse <List <CommitRepo> >(commitsJson);

            commitList.Adapter = new CommitListAdapter(this, commits);
        }
Пример #4
0
        public static async Task <Token> GetLocalAccessToken()
        {
            StreamReader strm = new StreamReader(Application.Context.Assets.Open("LocalStorage.txt"));
            var          json = await strm.ReadToEndAsync();

            var token = await ParseManager.Parse <Token>(json);

            return(token);
        }
Пример #5
0
 private void GetProductFromDiv(IElement div)
 {
     try
     { ParseManager parseManager = new ParseManager();
       string       urlForPage   = div.GetElementsByClassName("g-i-tile-i-title")[0].GetElementsByTagName("a")[0].GetAttribute("href");
       var          product      = parseManager.Parse(Store.Rozetka, urlForPage);
       _productRepository.AddProduct(product); }
     catch (Exception ex)
     {
     }
 }
Пример #6
0
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            Button    signIn     = FindViewById <Button>(Resource.Id.SignIn);
            ImageView userAvatar = FindViewById <ImageView>(Resource.Id.UserAvatar);
            Button    getStarred = FindViewById <Button>(Resource.Id.GetStarred);
            TextView  greeting   = FindViewById <TextView>(Resource.Id.Greeting);

            pageInfo     = FindViewById <TextView>(Resource.Id.PageInfo);
            navigation   = FindViewById <LinearLayout>(Resource.Id.Navigation);
            previousPage = FindViewById <Button>(Resource.Id.PreviousPage);
            nextPage     = FindViewById <Button>(Resource.Id.NextPage);

            listView = FindViewById <ListView>(Resource.Id.RepoList);

            token = await GetLocalStorage.GetLocalAccessToken();

            signIn.Click += async(sender, e) =>
            {
                var json = await _fetch.GetJson(_url.User, token);

                user = await ParseManager.Parse <User>(json);

                if (user != null)
                {
                    greeting.Text = $"Welcome {user.UserName}";
                    var bitmap = GetImageHelper.GetImageBitmapFromUrl(user.avatarUrl);
                    userAvatar.SetImageBitmap(bitmap);
                    getStarred.Enabled = true;
                    signIn.Visibility  = ViewStates.Gone;
                }
            };

            getStarred.Click += async(sender, e) =>
            {
                var json = await _fetch.GetJson(_url.Starred(user), token);

                repos = await ParseManager.Parse <List <Repo> >(json);

                foreach (Repo repo in repos)
                {
                    repo.IsStarred = true;
                }
                ;

                navigation.Visibility = ViewStates.Gone;

                listView.Adapter = new RepoListAdapter(this, token, user, repos);
            };

            listView.ItemClick += (sender, e) =>
            {
                var listView = sender as ListView;
                repo = repos[e.Position];
                var intent = new Intent(this, typeof(RepoActivity));
                StartActivity(intent);
            };

            previousPage.Click += (sender1, e1) =>
            {
                page--;
                Search();
            };

            nextPage.Click += (sender2, e2) =>
            {
                page++;
                Search();
            };
        }