Giter Club home page Giter Club logo

newss's Introduction

NEWSS

Newss is an android application mainly built for personal app development learning purpose. This application is built purely in java and is mainly for android platform. This app fetches the articles by consuming News API. It makes use of Retrofit type safe client for handling HTTP request along with GSON object converter. It uses Glide for image downloading and caching. We can definitely use Picasso library too. Please refer this article for significant differences between both. We will also make use of another third-party library to beautify the timestamp of the news application.

1. Including Third party Libraries:

Include the below implementations to your dependencies block inside app.gradle file.

// Recycler view and card view dependency
implementation 'com.google.android.material:material:1.0.0'
implementation "androidx.cardview:cardview:1.0.0"
implementation "androidx.recyclerview:recyclerview:1.1.0"
// For control over item selection of both touch and mouse driven selection
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"

// Image download and caching
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'

// Establishing HTTP connection with the API endpoints
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation("com.squareup.okhttp3:logging-interceptor:4.9.1")
implementation("com.squareup.okhttp3:okhttp:4.9.0")
// Time formatter
implementation 'org.ocpsoft.prettytime:prettytime:4.0.4.Final'

NOTE: Please try to update to the libraries to their latest version. When I built this application these were the latest versions.

2. Getting the API key from the News API

Head over to News API and create an account to get the API key (generally alphanumeric) which is very much required to establish the connection from the API endpoints.

3. Adding the permissions to manifest file

In your AndroidManifest.xml add the below permissions:

<uses-permission android:name="android.permission.INTERNET"/>
    <!--
    Allows Glide to monitor connectivity status and restart failed requests if users go from a
    a disconnected to a connected network state.
    -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

4. Tinkering with layouts and colors

  1. Adding colors.xml from this gist.
  2. [TO ADD]

5. Setup for consuming the API

  1. The first thing is to create a model package and in that package creating a class which consumes the json response in java.
    • We use @SerializedName("name_of_field_in_json_file") annotation when the json property name is different than our variable or field name.
    • We use @Expose to allow or disallow serialization. It is optional. This answer is worth reading.
    • Next thing is generating the getters for each and every field.

newss's People

Contributors

mandy8055 avatar

Watchers

 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.