Skip to content

🎬 Kitchen sink project for learning android concepts 🎬

License

Notifications You must be signed in to change notification settings

anandwana001/catchflicks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

72 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Catchflicks 🎬

CircleCI Codacy Badge

GitHub license GitHub stars GitHub forks GitHub watchers GitHub followers Twitter Follow

Catchflicks is a sample project after completing Android Development Online Course For Professionals by MindOrks.

This app shows the popular movies, upcoming movies and the ongoing movies in theatre from the movie db API. The goal of this sample project is to implement most of the learning from the Bootcamp. Also, this project works as a kitchen sink project where anyone can play with any new Android API's and concepts.

Screenshot πŸ“±

Architecture

Project consist of multiple packages in order to achieve MVVM architecture.

  • data
  • di
  • ui
  • utils

Tech-stack πŸ› 

This project use multiple libraries to bring easy way of implementation

Development Setup βš™οΈ

This project uses the TMDb API to fetch movies data.
To begin with the setup, firstly you need to create an API key.

  1. Create an account at themoviedb.org
  2. Go to settings from the profile icon
  3. Click on API
  4. Click on create
# Insert at ~/.gradle/gradle.properties or catchflicks/gradle.properties
API_KEY=<insert>

This project uses the Dagger2 for dependency Injection. After opening this project in your Android Studio you might get some error which is due unavailability of few classes. You need to make project or try to build the project, this will generate all the required classes for dagger.

Custom ViewModelProviderFactory 🦾🦿

I had created a custom ViewModelProviderFactory class because I need to pass arguments in my View Model class constructor.

  • Default -> ViewModelProviders.of(this).get(MyViewModel.class);
  • ViewModelProviders.of, this depends upon a ViewModelStore and a ViewModelFactory
  • return new ViewModelProvider(activity.getViewModelStore(), factory);
  • getViewModelStore() under the hood uses onRetainNonConfigurationInstance() method and SavedStateRegistryController class which calls performRestore() and performSave() method of SavedStateRegistry class.
  • ViewModelStore store view model using HashMap<String, ViewModel>
  • So, if we have arguments in our view model class constructor then we create custom ViewModelProviderFactory.

class ViewModelProviderFactory<T : ViewModel>(
    private val kClass: KClass<T>,
    private val creator: () -> T
) : ViewModelProvider.NewInstanceFactory() {

    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalArgumentException::class)
    override fun <T : ViewModel> create(modelClass: Class<T>): T {
        if (modelClass.isAssignableFrom(kClass.java)) return creator() as T
        throw IllegalArgumentException("Unknown class name")
    }
}
    ViewModelProviders.of(activity, ViewModelProviderFactory(MainViewModel::class){
            // MainViewModel(PARAM_1,PARAM_2)
        }).get(MainViewModel::class.java)
  • We are extending our custom class with ViewModelProvider.NewInstanceFactory().
  • This is used to create the instance of the given class.
  • This by default returns class object with empty argument list. return modelClass.newInstance();
  • KClass is the holder of a class of type ViewModel that needs to be injected.
  • Instances of KClass class are obtainable by the ::class syntax.
  • This is the Lambda function, this is provided by the ActivityModule/FragmentModule, when creator lambda is called then that module creates and return the instance of ViewModel.

Work in Progress πŸš§πŸ› πŸš§

  • Search feature
  • Unit Testing
  • UI Testing, using espresso and mockito
  • Update Region option
  • Update Language option
  • Try Pagination API
  • Dark Mode
  • Try Navigation Component
  • Coroutine
  • Better UI
  • Bookmark Movie

Contact πŸ”—

Let's connect here -> anandwana001.github.io

License πŸ“

MIT License

Copyright (c) 2020 Akshay Nandwana

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.