Giter Club home page Giter Club logo

reactivedroid / tvflix Goto Github PK

View Code? Open in Web Editor NEW
409.0 15.0 57.0 494 KB

TvFlix android app using Dagger Hilt, Coroutines, Flow, KTX, Jetpack(Room, ViewModel, Paging3, Lifecycle) based on MVVM with clean code architecture purely written in Kotlin

Home Page: https://reactivedroid.github.io/TvFlix/

License: MIT License

Kotlin 100.00%
retrofit2 clean-code codeanalysis pmd checkstyle databinding android-architecture-components unit-testing espresso-tests kotlin

tvflix's Introduction

Android CI GitHub top language License: MIT API GitHub stars GitHub forks

TvFlix 📺

The aim of this app is to replicate the high level functionality of www.tvmaze.com and showcase an android app out of it. It connects with TVDB API to give you popular shows and let you mark anyone as favorite. TvFlix consists of 3 pieces of UI right now:

  1. Home with Popular Shows
  2. Favorites
  3. All Shows

This app is under development. 👷 🛠️

Note: TvFlix is an unofficial app built only for learning and sharing the latest concepts with #AndroidDevs

Android Development and Architecture

Further Reading

There are several articles written on this repository which state the design and architecture.

Kotlin Everywhere. Coroutines, Tests, Robots and much more…

The TvFlix complete repository has been re-written in Kotlin with Coroutines covering Unit Tests across ViewModels and UI tests for the app. Know more: Kotlin Everywhere. Coroutines, Tests, Robots and much more…

MVVM using Android Architecture Components

The codebase tries to follow Uncle Bob Clean Code Architecture with SOLID principles. Know more: Migration from MVP to MVVM using Android Architecture Components

Pagination using Paging Library

The Shows screen displays the list of shows fetched from TvMaze API using Paging3 of Android Architecture Components. It also handles the retry if any network error occurred. Recently the repository has been migrated to use Paging3.
Paging3 is in heavy development, and if you want to catch up with stable library(Paging 2), then check out this blog Pagination using Paging Library with RxJava and Dagger

Room Persistence Library

The Favourites screen displays the list of shows marked favourites from the Home screen. The user can add/remove from the favorites as and when required. The implementation of the favorites is done using Room Persistence Library with RxJava and Dagger. Know more: Room with RxJava and Dagger

Static Code Analysis

TvFlix has Static Code Analysis tools like FindBugs, PMD and Checkstyle integrated. These tools help in finding potential bugs that would have been missed and help in making the codebase clean. Know more: Static Code Analysis for Android Using FindBugs, PMD and CheckStyle

Contributions

If you have found an issue in this sample, please file it. Better yet, if you want to contribute to the repository, go ahead, any kind of patches are encouraged, and may be submitted by forking this project and submitting a pull request. If you have something big in mind, or any architectural change, please raise an issue first to discuss it.

License

Copyright (c) 2020 Ashwini Kumar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

tvflix's People

Contributors

reactivedroid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tvflix's Issues

calling retrofit API Dispatchers.main

** ViewModelscope.launch will launch in Dispatchers.main context check below lines in
HomeViewModel.kt does it affect performance

viewModelScope.launch(coroutineExceptionHandler) {

        // Get shows from network, suspend function in retrofit will launch a new coroutine with IO dispatcher .

        *calling in Dispatchers.Main does it affect performance *val episodes = tvMazeApi.getCurrentSchedule(COUNTRY_US, currentDate)**

        // Return the result on main thread via Dispatchers.Main
        homeViewStateLiveData.value = Success(HomeViewData(getShowsWithFavorites(episodes, favoriteShowIds)))
    }

Help me!

**I don't understand the 3rd function of DiffUtil.ItemCallBack well...
payload
**

You used this feature in the previous version of TvMaze ....

For what purpose is this function used, what makes it convenient for us?

When the Recyclerview adapter inherits from the ListAdapter, the notifyItem .... (position, Payload) methods do not work, so does using ItemCallback's 3rd function help? I would be happy if you share your knowledge! Thank you !!!

NullPointerException

Describe the bug
When I open the app it show different shows but the first of all shows has a black image (I guess that image did not load yet) and when I click on favourite, the application crashes.

To Reproduce
Steps to reproduce the behavior:

  1. Open the app
  2. Click on favourite button in first show
  3. Application crashes

Screenshot
Screenshot_1612376924

Desktop (please complete the following information):
I cloned the repository in a MacBook Pro with macOS Big Sur v11.2.

Smartphone (please complete the following information):
I execute in emulator Nexus 5X with API 29 (Android 10.0) and CPU/ABI x86

Additional context
Logs are there:

E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-3
    Process: com.android.tvflix.dev.debug, PID: 28772
    java.lang.NullPointerException
        at com.android.tvmaze.favorite.FavoriteShowsRepository.insertShowIntoFavorites(FavoriteShowsRepository.kt:22)
        at com.android.tvmaze.home.HomeViewModel$onFavoriteClick$1.invokeSuspend(HomeViewModel.kt:83)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

It's a NullPointerException whose origin is in line 22 of FavoriteShowsRepository class on imageURL property of FavouriteShow:

suspend fun insertShowIntoFavorites(show: Show) {
        val favoriteShow = FavoriteShow(
            id = show.id,
            name = show.name,
            premiered = show.premiered,
            imageUrl = show.image!!["original"],
            summary = show.summary,
            rating = show.rating!!["average"],
            runtime = show.runtime!!,
            isFavorite = true
        )
        showDao.insert(favoriteShow)
 }

Crash Immediately When I Launch The App

App Crash
Crash Immediately When I Launch The App

To Reproduce
Steps to reproduce the behavior:

  1. Clone the Repo from Github and build successfully.
  2. Install to my smartphone (Meizu M6 - Android 7.0 OS)
  3. Installed and launch the app
  4. App crash

PS: I got the same issue on the emulator.

Desktop (please complete the following information):

  • OS: [Android]
  • Version [7.0]

Logcat

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.android.tvmaze.dev.debug, PID: 20277
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.tvmaze.dev.debug/com.android.tvmaze.home.HomeActivity}: android.view.InflateException: Binary XML file line #6: Binary XML file line #6: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: android.view.InflateException: Binary XML file line #6: Binary XML file line #6: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
     Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
        at com.android.tvmaze.home.HomeActivity.onCreate(HomeActivity.kt:30)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/constraintlayout/widget/R$styleable;
        at androidx.constraintlayout.widget.ConstraintLayout.init(ConstraintLayout.java:590)
        at androidx.constraintlayout.widget.ConstraintLayout.<init>(ConstraintLayout.java:567)
        at java.lang.reflect.Constructor.newInstance0(Native Method) 
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343) 
        at android.view.LayoutInflater.createView(LayoutInflater.java:647) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:374) 
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
        at com.android.tvmaze.home.HomeActivity.onCreate(HomeActivity.kt:30) 
        at android.app.Activity.performCreate(Activity.java:7136) 
        at android.app.Activity.performCreate(Activity.java:7127) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
E/AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.constraintlayout.widget.R$styleable" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.android.tvmaze.dev.debug-DPyD1uV_UJdzi7AqrQAfMA==/base.apk"],nativeLibraryDirectories=[/data/app/com.android.tvmaze.dev.debug-DPyD1uV_UJdzi7AqrQAfMA==/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        	... 28 more

It seems the androidx dependency of ConstraintLayout has some problem. Could you help me to solve the problem? Thanks.

API 18 device crash immediately when launching app

launching app with api 18 device got crash immediately, but no problem running with device with api 21 or higher

com.android.tvmaze.dev.debug E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
java.lang.NoClassDefFoundError: java.util.Objects
at okhttp3.Address.hashCode(Address.kt:180)
at okhttp3.Route.hashCode(Route.kt:84)
at java.util.HashMap.containsKey(HashMap.java:332)
at java.util.HashSet.contains(HashSet.java:138)
at okhttp3.internal.connection.RouteDatabase.shouldPostpone(RouteDatabase.kt:40)
at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:74)

Seems like MultiDex problem, MultiDex under api 21 and code under heavy dependicy likely cause this kind of problem. create multiDexKeepFile and multiDexKeepProguard maybe help.

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.