Coder Social home page Coder Social logo

githubtrending's Introduction

GithubTrending

Summary

This is a sample app that shows trending Android repositories on Github. The main screen which is the entry point of the app is a list repositories. It acts as master view where the user can click on a repository item and gets navigated to a detail view.

Dependencies

Build

The App can be build by executing the task assembleRelease with the supplied Gradle wrapper "gradlew"

Challenges

How is trending Github repositories defined?

Use Github Trending Website as reference: Trending repositories seem to be defined as these repositories that gained stars in certain time interval:

  • Today
  • This week
  • This month

From the naming it seems like the stars per repository is counted from the beginning of the interval until now. This translates into the following pseudo query: Return all repositories that gained stars since the beginning of [interval] sorted by stars gained in descending order. Browsing the documentation of Github REST API v3 there is no API call that returns a list of repositories that match the criteria or returns a result similar to Github Trending Website. This leads to the following alternatives

  1. Parse the html output of Github Trending Website
  2. Use a third party library/API that parses the Github Trending Website like trending-github
  3. Use a suggested API call on stackoverflow using the Search Repository API
  4. Simplify the requirement by using "popular" instead of "trending" repositories

Solution one is a lot of work to implement and is unstable meaning that it could completely break the app when the page is changed. Solution two makes the App dependent on an external source that is out of control. It's also not provided in a way that cann be easily used by or integrated into the App. Solution three doesn't meet the requirements as the stars are not counted based on a time interval. Solution four is a compromise that is near to the requirement, easy to implement and should word as long as API v3 is supported.

How to get a list of popular Github repositories from the Github API

Use the Github search repositories API using the following parameters

  • Filter by topic android
  • Sort by stars
  • Order descending

This results in the following API call:

https://api.github.com/search/repositories?q=topic:android&sort=stars&order=desc

What kind of information should be shown in a single repository item?

Use Github Trending Website as reference:

  • image of the owner
  • full name (includes owner name)
  • description
  • # of stargazers
  • # of forks

The Language property is left out as Android repositories are either Java or Kotlin.

How to present the repository items?

The first question that arises is how to present the items on the screen next to each other. Following Design Guidelines we have three main representations:

  • Grid lists
  • Cards
  • List

The collection of repositories that needs to be visualized is a homogeneous data type thus the list representation is chosen. To visualize the contents of the repository tile/item a two line list with avatar is chosen.

Known issues

  • Scroll position is not preserved on orientation change
  • Repository details don't survive app kill when app is in background

Possible improvements

  • Cache repository entities in database using Room

githubtrending's People

Contributors

ralphhm avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.