Exemple #1
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();
            };
        }
Exemple #2
0
 public string Readme(Repo repo)
 {
     return $"{repo.Url}/readme";
 }
Exemple #3
0
 public string Star(Repo repo)
 {
     return $"https://api.github.com/user/starred/{repo.Owner.Name}/{repo.Name}";
 }
Exemple #4
0
 public string Commits(Repo repo)
 {
     return $"{repo.Url}/commits";
 }