Weather App is a sample that implements the WeatherView library for displaying weather data.
WeatherView library provides a fragment that can be included to your application for displaying the Weather Data of major cities.
The WeatherView is created by:
WeatherViewFragment.newInstance(); Once created, add it to an existing activity or fragment.
class MainActivity {
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.container, WeatherViewFragment.newInstance())
.commitNow();
}On adding the fragment, the fragment will perform the fetching of necessary data and displays the UI. The UI displays:
- A carousel view of Weather data for major cities around the world.
- For each city, the current weather information as well as the forecast for the next 5 days.
- User can swipe through the cards to see the weather forecast for each city.
- If the user wishes to see the weather info for his/her current location, then user can tap on the 'My Location' card in the carousel.
- On tapping, the current location will be fetched and the weather info for the location will be displayed.
WeatherView library uses the Card-Carousel and MyLocation libraries to implement the features.
- Presentation - Android MVVM with LiveData
- Domain - UseCases
- Data - Repository Design pattern
- Android Architecture components
- RxJava
- Retrofit, OkHTTP, Gson
- Dagger2
- Junit, Mockito & MockWebServer
A RecyclerView based implementation of a Carousel like view. The library provides a custom view that can be included to a layout in your project or can be used programatically.
- Include the CarouselView to the layout.
<com.androidnerds.cardcarousel.CarouselView
android:id="@+id/carouselView"
android:layout_width="0dp"
android:layout_height="300dp"/>- Define the Adapter for the CarouselView similar to how we create ViewHolders and Adapters for a RecyclerView.
- Assign the adapter to the CarouselView.
- To receive callbacks when an item in the CarouselView comes to the middle(selected), then implement the OnCarouselItemSelectedListener as below:
carouselView.setItemSelectedListener(position -> {});This is a library that implements the FusedLocationProviderClient and performs the retreiving the location of the device. The library provides the location as a datasource.
Use the DeviceLocationDataSource class that provides the location info of the device via a Flowable. If you wish to receive location updates, then create an instance of the DeviceLocationDataSource class and subscribe to the Flowable provided by calling the getDeviceLocation() method.


