use of uk.ivanc.archi.model.Repository in project archi by ivacf.
the class RepositoryAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RepositoryViewHolder holder, int position) {
Repository repository = repositories.get(position);
Context context = holder.titleTextView.getContext();
holder.repository = repository;
holder.titleTextView.setText(repository.name);
holder.descriptionTextView.setText(repository.description);
holder.watchersTextView.setText(context.getResources().getString(R.string.text_watchers, repository.watchers));
holder.starsTextView.setText(context.getResources().getString(R.string.text_stars, repository.stars));
holder.forksTextView.setText(context.getResources().getString(R.string.text_forks, repository.forks));
}
use of uk.ivanc.archi.model.Repository in project archi by ivacf.
the class MainActivity method setupRecyclerView.
private void setupRecyclerView(RecyclerView recyclerView) {
RepositoryAdapter adapter = new RepositoryAdapter();
adapter.setCallback(new RepositoryAdapter.Callback() {
@Override
public void onItemClick(Repository repository) {
startActivity(RepositoryActivity.newIntent(MainActivity.this, repository));
}
});
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
use of uk.ivanc.archi.model.Repository in project archi by ivacf.
the class MainActivity method loadGithubRepos.
public void loadGithubRepos(String username) {
progressBar.setVisibility(View.VISIBLE);
reposRecycleView.setVisibility(View.GONE);
infoTextView.setVisibility(View.GONE);
ArchiApplication application = ArchiApplication.get(this);
GithubService githubService = application.getGithubService();
subscription = githubService.publicRepositories(username).observeOn(AndroidSchedulers.mainThread()).subscribeOn(application.defaultSubscribeScheduler()).subscribe(new Subscriber<List<Repository>>() {
@Override
public void onCompleted() {
progressBar.setVisibility(View.GONE);
if (reposRecycleView.getAdapter().getItemCount() > 0) {
reposRecycleView.requestFocus();
hideSoftKeyboard();
reposRecycleView.setVisibility(View.VISIBLE);
} else {
infoTextView.setText(R.string.text_empty_repos);
infoTextView.setVisibility(View.VISIBLE);
}
}
@Override
public void onError(Throwable error) {
Log.e(TAG, "Error loading GitHub repos ", error);
progressBar.setVisibility(View.GONE);
if (error instanceof HttpException && ((HttpException) error).code() == 404) {
infoTextView.setText(R.string.error_username_not_found);
} else {
infoTextView.setText(R.string.error_loading_repos);
}
infoTextView.setVisibility(View.VISIBLE);
}
@Override
public void onNext(List<Repository> repositories) {
Log.i(TAG, "Repos loaded " + repositories);
RepositoryAdapter adapter = (RepositoryAdapter) reposRecycleView.getAdapter();
adapter.setRepositories(repositories);
adapter.notifyDataSetChanged();
}
});
}
use of uk.ivanc.archi.model.Repository in project archi by ivacf.
the class RepositoryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_repository);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
descriptionText = (TextView) findViewById(R.id.text_repo_description);
homepageText = (TextView) findViewById(R.id.text_homepage);
languageText = (TextView) findViewById(R.id.text_language);
forkText = (TextView) findViewById(R.id.text_fork);
ownerNameText = (TextView) findViewById(R.id.text_owner_name);
ownerEmailText = (TextView) findViewById(R.id.text_owner_email);
ownerLocationText = (TextView) findViewById(R.id.text_owner_location);
ownerImage = (ImageView) findViewById(R.id.image_owner);
ownerLayout = findViewById(R.id.layout_owner);
Repository repository = getIntent().getParcelableExtra(EXTRA_REPOSITORY);
bindRepositoryData(repository);
loadFullUser(repository.owner.url);
}
Aggregations