├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── themes.xml │ │ │ ├── drawable │ │ │ │ ├── bg_dark.xml │ │ │ │ ├── ic_home_black_24dp.xml │ │ │ │ ├── ic_baseline_arrow_forward_ios_24.xml │ │ │ │ ├── ic_baseline_close_24.xml │ │ │ │ ├── ic_baseline_info_24.xml │ │ │ │ ├── ic_dashboard_black_24dp.xml │ │ │ │ ├── ic_notifications_black_24dp.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── menu │ │ │ │ └── bottom_nav_menu.xml │ │ │ ├── values-night │ │ │ │ └── themes.xml │ │ │ ├── layout │ │ │ │ ├── fragment_home.xml │ │ │ │ ├── fragment_dashboard.xml │ │ │ │ ├── fragment_notifications.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── popular_movie_item.xml │ │ │ │ └── fragement_bottom_sheet_detail.xml │ │ │ ├── navigation │ │ │ │ └── mobile_navigation.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── droidkerala │ │ │ │ └── theshard │ │ │ │ ├── utils │ │ │ │ ├── Status.kt │ │ │ │ ├── Resource.kt │ │ │ │ └── databinding │ │ │ │ │ └── ViewBinding.kt │ │ │ │ ├── data │ │ │ │ ├── MovieResponse.kt │ │ │ │ ├── datasources │ │ │ │ │ ├── IMovieLocalDataSource.kt │ │ │ │ │ ├── IMovieDataSource.kt │ │ │ │ │ ├── MovieDataSource.kt │ │ │ │ │ └── MovieLocalDataSource.kt │ │ │ │ ├── network │ │ │ │ │ └── ApiService.kt │ │ │ │ ├── Movie.kt │ │ │ │ └── repositoryimpl │ │ │ │ │ └── MovieRepositoryImpl.kt │ │ │ │ ├── di │ │ │ │ ├── DatabaseModule.kt │ │ │ │ ├── AppModule.kt │ │ │ │ └── NetworkModule.kt │ │ │ │ ├── TheShardApp.kt │ │ │ │ ├── presentation │ │ │ │ └── ui │ │ │ │ │ ├── theme │ │ │ │ │ └── color.kt │ │ │ │ │ ├── dashboard │ │ │ │ │ ├── DashboardViewModel.kt │ │ │ │ │ └── DashboardFragment.kt │ │ │ │ │ ├── notifications │ │ │ │ │ ├── NotificationsViewModel.kt │ │ │ │ │ └── NotificationsFragment.kt │ │ │ │ │ ├── home │ │ │ │ │ ├── HomeViewModel.kt │ │ │ │ │ └── HomeFragment.kt │ │ │ │ │ ├── adapters │ │ │ │ │ └── PopularMoviesAdapter.kt │ │ │ │ │ └── bottomsheet │ │ │ │ │ └── MovieDetailBottomSheet.kt │ │ │ │ ├── domain │ │ │ │ └── MovieRepository.kt │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── droidkerala │ │ │ └── theshard │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── droidkerala │ │ └── theshard │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── cover.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "TheShard" 2 | include ':app' 3 | -------------------------------------------------------------------------------- /cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/cover.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Droid-Kerala/TheShard/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/utils/Status.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.utils 2 | 3 | enum class Status { 4 | SUCCESS, 5 | ERROR, 6 | LOADING 7 | } -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TheShard 3 | Home 4 | Dashboard 5 | Notifications 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jun 10 18:47:19 IST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/MovieResponse.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data 2 | 3 | //data class for movie api response 4 | data class MovieResponse( 5 | val page: Int=0, 6 | val results: MutableList, 7 | val total_pages: Int=0, 8 | val total_results: Int=0 9 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/di/DatabaseModule.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.di 2 | 3 | import dagger.Module 4 | import dagger.hilt.InstallIn 5 | import dagger.hilt.components.SingletonComponent 6 | 7 | @InstallIn(SingletonComponent::class) 8 | @Module 9 | object DatabaseModule { 10 | 11 | } -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/TheShardApp.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard 2 | 3 | import android.app.Application 4 | import dagger.hilt.android.HiltAndroidApp 5 | 6 | @HiltAndroidApp 7 | class TheShardApp :Application() { 8 | 9 | override fun onCreate() { 10 | super.onCreate() 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/theme/color.kt: -------------------------------------------------------------------------------- 1 | package io.shrineapps.divinevibes.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Red700 = Color(0xffdd0d3c) 6 | val Red800 = Color(0xffd00036) 7 | val Red900 = Color(0xffc20029) 8 | val white900 = Color(0x66FFFFFF) 9 | val grey900 = Color(0x80C7C7C7) -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/datasources/IMovieLocalDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data.datasources 2 | 3 | import com.droidkerala.theshard.data.Movie 4 | import com.droidkerala.theshard.data.MovieResponse 5 | 6 | interface IMovieLocalDataSource { 7 | fun saveMovieList(movieList : List) 8 | fun getMovieListDataById(id: String): Movie? 9 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_home_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_arrow_forward_ios_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_close_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_baseline_info_24.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dashboard_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/datasources/IMovieDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data.datasources 2 | 3 | import com.droidkerala.theshard.data.MovieResponse 4 | import com.droidkerala.theshard.data.network.ApiService 5 | import retrofit2.http.Query 6 | import javax.inject.Inject 7 | 8 | interface IMovieDataSource { 9 | 10 | suspend fun getMoviesList(apikey: String?, page: Int) : MovieResponse 11 | 12 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/domain/MovieRepository.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.domain 2 | 3 | import android.security.identity.ResultData 4 | import com.droidkerala.theshard.data.Movie 5 | import com.droidkerala.theshard.data.MovieResponse 6 | 7 | interface MovieRepository { 8 | 9 | suspend fun getMovies(apiKey : String? , page :Int): MovieResponse 10 | 11 | fun getMovieListById(id : String): Movie? 12 | 13 | 14 | } -------------------------------------------------------------------------------- /app/src/test/java/com/droidkerala/theshard/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/dashboard/DashboardViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.dashboard 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | 7 | class DashboardViewModel : ViewModel() { 8 | 9 | private val _text = MutableLiveData().apply { 10 | value = "This is dashboard Fragment" 11 | } 12 | val text: LiveData = _text 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/network/ApiService.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data.network 2 | 3 | import com.droidkerala.theshard.data.MovieResponse 4 | import retrofit2.Response 5 | import retrofit2.http.GET 6 | import retrofit2.http.Headers 7 | import retrofit2.http.Query 8 | 9 | interface ApiService { 10 | 11 | @Headers("Accept: application/json") 12 | @GET("popular") 13 | suspend fun getMoviesList(@Query("api_key") apikey: String?, @Query("page") page: Int): MovieResponse 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/notifications/NotificationsViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.notifications 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | 7 | class NotificationsViewModel : ViewModel() { 8 | 9 | private val _text = MutableLiveData().apply { 10 | value = "This is notifications Fragment" 11 | } 12 | val text: LiveData = _text 13 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/datasources/MovieDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data.datasources 2 | 3 | import com.droidkerala.theshard.data.MovieResponse 4 | import com.droidkerala.theshard.data.network.ApiService 5 | import retrofit2.http.Query 6 | import javax.inject.Inject 7 | 8 | class MovieDataSource @Inject constructor(private val apiService: ApiService) : IMovieDataSource{ 9 | 10 | override suspend fun getMoviesList(apikey: String?, page: Int) = apiService.getMoviesList(apikey,page) 11 | 12 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_notifications_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # bundle file 12 | *.aab 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | out/ 18 | 19 | # Gradle files 20 | .gradle/* 21 | build/ 22 | 23 | .idea/ 24 | 25 | 26 | 27 | # Local configuration file (sdk path, etc) 28 | local.properties 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Intellij 34 | *.iml 35 | 36 | 37 | .DS_Store 38 | # Android Studio captures folder 39 | captures/ 40 | 41 | .externalNativeBuild 42 | .cxx 43 | 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/datasources/MovieLocalDataSource.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data.datasources 2 | 3 | import com.droidkerala.theshard.data.Movie 4 | import javax.inject.Inject 5 | 6 | class MovieLocalDataSource @Inject constructor() : IMovieLocalDataSource { 7 | private var listMovieData: List? = null 8 | override fun saveMovieList(movieList: List) { 9 | this.listMovieData = movieList 10 | } 11 | 12 | override fun getMovieListDataById(id: String): Movie? { 13 | return listMovieData?.firstOrNull { it.id == id } 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/utils/Resource.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.utils 2 | 3 | data class Resource(val status: Status, val data: T?, val message: String?) { 4 | companion object { 5 | fun success(data: T): Resource = Resource(status = Status.SUCCESS, data = data, message = null) 6 | 7 | fun error(data: T?, message: String): Resource = 8 | Resource(status = Status.ERROR, data = data, message = message) 9 | 10 | fun loading(data: T?): Resource = Resource(status = Status.LOADING, data = data, message = null) 11 | } 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/Movie.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data 2 | 3 | import android.os.Parcelable 4 | import kotlinx.parcelize.Parcelize 5 | 6 | //data class for popular movies 7 | @Parcelize 8 | data class Movie( 9 | val id: String, 10 | val original_language: String, 11 | val original_title: String, 12 | val overview: String, 13 | val popularity: Double, 14 | val poster_path: String, 15 | val release_date: String, 16 | val title: String, 17 | val video: Boolean, 18 | val vote_average: String, 19 | val vote_count: String, 20 | val backdrop_path : String, 21 | val genre_ids: List 22 | ) : Parcelable -------------------------------------------------------------------------------- /app/src/main/res/menu/bottom_nav_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 13 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/droidkerala/theshard/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("in.droidkerala.theshard", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_home.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 19 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_dashboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_notifications.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Kotlin code style for this project: "official" or "obsolete": 19 | kotlin.code.style=official -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/data/repositoryimpl/MovieRepositoryImpl.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.data.repositoryimpl 2 | 3 | import com.droidkerala.theshard.data.Movie 4 | import com.droidkerala.theshard.data.MovieResponse 5 | import com.droidkerala.theshard.data.datasources.IMovieDataSource 6 | import com.droidkerala.theshard.data.datasources.IMovieLocalDataSource 7 | import com.droidkerala.theshard.data.datasources.MovieDataSource 8 | import com.droidkerala.theshard.data.datasources.MovieLocalDataSource 9 | import com.droidkerala.theshard.domain.MovieRepository 10 | import javax.inject.Inject 11 | 12 | class MovieRepositoryImpl @Inject constructor( 13 | private val movieDataSource: IMovieDataSource, 14 | private val movieLocalDataSource: IMovieLocalDataSource 15 | ) : MovieRepository { 16 | 17 | 18 | override suspend fun getMovies(apiKey: String?, page: Int): MovieResponse { 19 | val list = movieDataSource.getMoviesList(apiKey, page) 20 | movieLocalDataSource.saveMovieList(list.results) 21 | return list 22 | } 23 | 24 | override fun getMovieListById(id: String): Movie? { 25 | return movieLocalDataSource.getMovieListDataById(id) 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/home/HomeViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.home 2 | 3 | import androidx.lifecycle.* 4 | import com.droidkerala.theshard.data.Movie 5 | import com.droidkerala.theshard.domain.MovieRepository 6 | import com.droidkerala.theshard.utils.Resource 7 | import dagger.hilt.android.lifecycle.HiltViewModel 8 | import kotlinx.coroutines.Dispatchers 9 | import javax.inject.Inject 10 | 11 | 12 | @HiltViewModel 13 | class HomeViewModel @Inject constructor(private val movieRepository : MovieRepository, private val savedStateHandle: SavedStateHandle): ViewModel() { 14 | 15 | private val _text = MutableLiveData().apply { 16 | value = "This is home Fragment" 17 | } 18 | val text: LiveData = _text 19 | 20 | 21 | fun getMovies(apiKey : String, page: Int) = liveData(Dispatchers.IO) { 22 | emit(Resource.loading(data = null)) 23 | try { 24 | emit(Resource.success(data = movieRepository.getMovies(apiKey,page))) 25 | } catch (exception: Exception) { 26 | emit(Resource.error(data = null, message = exception.message ?: "Error Occurred!")) 27 | } 28 | } 29 | 30 | fun getMovieListById(id : String) : Movie? { 31 | return movieRepository.getMovieListById(id) 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/di/AppModule.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.di 2 | 3 | import com.droidkerala.theshard.data.datasources.IMovieDataSource 4 | import com.droidkerala.theshard.data.datasources.IMovieLocalDataSource 5 | import com.droidkerala.theshard.data.datasources.MovieDataSource 6 | import com.droidkerala.theshard.data.datasources.MovieLocalDataSource 7 | import com.droidkerala.theshard.data.network.ApiService 8 | import com.droidkerala.theshard.data.repositoryimpl.MovieRepositoryImpl 9 | import com.droidkerala.theshard.domain.MovieRepository 10 | import dagger.Binds 11 | import dagger.Module 12 | import dagger.Provides 13 | import dagger.hilt.InstallIn 14 | import dagger.hilt.components.SingletonComponent 15 | import javax.inject.Singleton 16 | 17 | @InstallIn(SingletonComponent::class) 18 | @Module(includes = [ NetworkModule::class]) 19 | 20 | class AppModule { 21 | 22 | @Provides 23 | @Singleton 24 | fun bindRepository(local : IMovieLocalDataSource, remote : IMovieDataSource): MovieRepository{ 25 | return MovieRepositoryImpl(remote,local) 26 | } 27 | 28 | @Provides 29 | @Singleton 30 | fun bindLocalDataSource(): IMovieLocalDataSource{ 31 | return MovieLocalDataSource() 32 | } 33 | 34 | @Provides 35 | @Singleton 36 | fun bindRemoteDataSource(apiService : ApiService): IMovieDataSource{ 37 | return MovieDataSource(apiService) 38 | } 39 | } -------------------------------------------------------------------------------- /app/src/main/res/navigation/mobile_navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | 25 | 26 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/dashboard/DashboardFragment.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.dashboard 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.TextView 8 | import androidx.fragment.app.Fragment 9 | import androidx.lifecycle.Observer 10 | import androidx.lifecycle.ViewModelProvider 11 | import com.droidkerala.theshard.databinding.FragmentDashboardBinding 12 | 13 | class DashboardFragment : Fragment() { 14 | 15 | private lateinit var dashboardViewModel: DashboardViewModel 16 | private var _binding: FragmentDashboardBinding? = null 17 | 18 | // This property is only valid between onCreateView and 19 | // onDestroyView. 20 | private val binding get() = _binding!! 21 | 22 | override fun onCreateView( 23 | inflater: LayoutInflater, 24 | container: ViewGroup?, 25 | savedInstanceState: Bundle? 26 | ): View? { 27 | dashboardViewModel = 28 | ViewModelProvider(this).get(DashboardViewModel::class.java) 29 | 30 | _binding = FragmentDashboardBinding.inflate(inflater, container, false) 31 | val root: View = binding.root 32 | 33 | val textView: TextView = binding.textDashboard 34 | dashboardViewModel.text.observe(viewLifecycleOwner, Observer { 35 | textView.text = it 36 | }) 37 | return root 38 | } 39 | 40 | override fun onDestroyView() { 41 | super.onDestroyView() 42 | _binding = null 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard 2 | 3 | import android.os.Bundle 4 | import com.google.android.material.bottomnavigation.BottomNavigationView 5 | import androidx.appcompat.app.AppCompatActivity 6 | import androidx.navigation.findNavController 7 | import androidx.navigation.ui.AppBarConfiguration 8 | import androidx.navigation.ui.setupActionBarWithNavController 9 | import androidx.navigation.ui.setupWithNavController 10 | import com.droidkerala.theshard.databinding.ActivityMainBinding 11 | import dagger.hilt.android.AndroidEntryPoint 12 | 13 | @AndroidEntryPoint 14 | class MainActivity : AppCompatActivity() { 15 | 16 | private lateinit var binding: ActivityMainBinding 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | 21 | binding = ActivityMainBinding.inflate(layoutInflater) 22 | setContentView(binding.root) 23 | 24 | val navView: BottomNavigationView = binding.navView 25 | 26 | val navController = findNavController(R.id.nav_host_fragment_activity_main) 27 | // Passing each menu ID as a set of Ids because each 28 | // menu should be considered as top level destinations. 29 | val appBarConfiguration = AppBarConfiguration( 30 | setOf( 31 | R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications 32 | ) 33 | ) 34 | // setupActionBarWithNavController(navController, appBarConfiguration) 35 | navView.setupWithNavController(navController) 36 | } 37 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/notifications/NotificationsFragment.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.notifications 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.TextView 8 | import androidx.fragment.app.Fragment 9 | import androidx.lifecycle.Observer 10 | import androidx.lifecycle.ViewModelProvider 11 | import com.droidkerala.theshard.databinding.FragmentNotificationsBinding 12 | 13 | class NotificationsFragment : Fragment() { 14 | 15 | private lateinit var notificationsViewModel: NotificationsViewModel 16 | private var _binding: FragmentNotificationsBinding? = null 17 | 18 | // This property is only valid between onCreateView and 19 | // onDestroyView. 20 | private val binding get() = _binding!! 21 | 22 | override fun onCreateView( 23 | inflater: LayoutInflater, 24 | container: ViewGroup?, 25 | savedInstanceState: Bundle? 26 | ): View? { 27 | notificationsViewModel = 28 | ViewModelProvider(this).get(NotificationsViewModel::class.java) 29 | 30 | _binding = FragmentNotificationsBinding.inflate(inflater, container, false) 31 | val root: View = binding.root 32 | 33 | val textView: TextView = binding.textNotifications 34 | notificationsViewModel.text.observe(viewLifecycleOwner, Observer { 35 | textView.text = it 36 | }) 37 | return root 38 | } 39 | 40 | override fun onDestroyView() { 41 | super.onDestroyView() 42 | _binding = null 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/di/NetworkModule.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.di 2 | 3 | import com.droidkerala.theshard.BuildConfig 4 | import com.droidkerala.theshard.data.network.ApiService 5 | import dagger.Module 6 | import dagger.Provides 7 | import dagger.hilt.InstallIn 8 | import dagger.hilt.components.SingletonComponent 9 | import okhttp3.OkHttpClient 10 | import okhttp3.logging.HttpLoggingInterceptor 11 | import retrofit2.Retrofit 12 | import retrofit2.converter.gson.GsonConverterFactory 13 | import javax.inject.Singleton 14 | 15 | @InstallIn(SingletonComponent::class) 16 | @Module 17 | object NetworkModule { 18 | @Provides 19 | fun provideBaseUrl(): String { 20 | return "https://api.themoviedb.org/3/movie/" 21 | } 22 | 23 | @Provides 24 | @Singleton 25 | fun provideOkHttpClient() = if (BuildConfig.DEBUG) { 26 | val loggingInterceptor = HttpLoggingInterceptor() 27 | loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY 28 | OkHttpClient.Builder() 29 | .addInterceptor(loggingInterceptor) 30 | .build() 31 | } else OkHttpClient 32 | .Builder() 33 | .build() 34 | 35 | 36 | @Provides 37 | @Singleton 38 | fun provideRetrofit(okHttpClient: OkHttpClient, BASE_URL: String): Retrofit = 39 | Retrofit.Builder() 40 | .addConverterFactory(GsonConverterFactory.create()) 41 | .baseUrl(BASE_URL) 42 | .client(okHttpClient) 43 | .build() 44 | 45 | @Provides 46 | @Singleton 47 | fun provideApiService(retrofit: Retrofit) = retrofit.create(ApiService::class.java) 48 | 49 | 50 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/popular_movie_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | 11 | 14 | 15 | 27 | 28 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/adapters/PopularMoviesAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.adapters 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import androidx.recyclerview.widget.RecyclerView 6 | import com.droidkerala.theshard.data.Movie 7 | import com.droidkerala.theshard.databinding.PopularMovieItemBinding 8 | 9 | 10 | //Recyclerview adapter for showing list of popular movies 11 | class PopularMoviesAdapter(private val listener: OnPopularMovieListener?) : 12 | 13 | RecyclerView.Adapter() { 14 | 15 | private var movies: List = arrayListOf() 16 | 17 | override fun getItemCount(): Int { 18 | return movies.size 19 | } 20 | 21 | override fun onBindViewHolder(holder: PopularMovieViewHolder, position: Int) { 22 | val movie = movies[position] 23 | holder.bind(movie, listener) 24 | } 25 | 26 | //To set data to adapter 27 | fun setData(listItems: List) { 28 | if (!listItems.isNullOrEmpty()) { 29 | this.movies = listItems 30 | notifyDataSetChanged() 31 | } 32 | } 33 | 34 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PopularMovieViewHolder { 35 | return PopularMovieViewHolder(PopularMovieItemBinding.inflate(LayoutInflater.from(parent.context))) 36 | } 37 | 38 | class PopularMovieViewHolder(private val binding: PopularMovieItemBinding) : 39 | RecyclerView.ViewHolder(binding.root) { 40 | 41 | //this method handles all data mapping and event listeneres. 42 | fun bind( 43 | movie: Movie?, 44 | listener: OnPopularMovieListener? 45 | ) { 46 | movie?.let { 47 | binding.movie = movie 48 | binding.executePendingBindings() 49 | //Click listener for movie icon. 50 | binding.imageview.setOnClickListener { 51 | listener?.onPopularMovieSelected(movie) 52 | } 53 | 54 | } 55 | } 56 | } 57 | 58 | 59 | interface OnPopularMovieListener { 60 | fun onPopularMovieSelected(movie: Movie) 61 | } 62 | } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/utils/databinding/ViewBinding.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.utils.databinding 2 | 3 | import android.graphics.drawable.Drawable 4 | import android.view.View 5 | import android.view.ViewGroup 6 | import android.widget.ImageView 7 | import android.widget.ProgressBar 8 | import androidx.databinding.BindingAdapter 9 | import com.bumptech.glide.Glide 10 | import com.bumptech.glide.load.DataSource 11 | import com.bumptech.glide.load.engine.GlideException 12 | import com.bumptech.glide.request.RequestListener 13 | import com.bumptech.glide.request.target.Target 14 | import com.google.android.material.imageview.ShapeableImageView 15 | 16 | 17 | 18 | //To change visibility of View based on passed data 19 | @BindingAdapter("android:viewvisibility") 20 | fun setViewVisibility(view: View, value: String?) { 21 | view.visibility = if (!value.isNullOrBlank()) View.VISIBLE else View.GONE 22 | } 23 | 24 | //To change visibility of Viewgroup based on passed data 25 | @BindingAdapter("android:viewvisibility") 26 | fun setViewVisibility(view: ViewGroup, value: String?) { 27 | view.visibility = if (!value.isNullOrBlank()) View.VISIBLE else View.GONE 28 | } 29 | 30 | //Load image with progress 31 | @BindingAdapter("imageUrl", "progressbar") 32 | fun loadImageWithProgress(imageView: ImageView, imageUrl: String?, ProgressBar: ProgressBar?) { 33 | Glide.with(imageView.context).load("https://image.tmdb.org/t/p/w185$imageUrl") 34 | .listener(object : RequestListener { 35 | override fun onLoadFailed( 36 | e: GlideException?, 37 | model: Any?, 38 | target: Target?, 39 | isFirstResource: Boolean 40 | ): Boolean { 41 | return false 42 | } 43 | 44 | override fun onResourceReady( 45 | resource: Drawable?, 46 | model: Any?, 47 | target: Target?, 48 | dataSource: DataSource?, 49 | isFirstResource: Boolean 50 | ): Boolean { 51 | ProgressBar?.visibility = View.GONE 52 | return false 53 | } 54 | }).into(imageView) 55 | } 56 | @BindingAdapter("imageUrl") 57 | fun loadImage(imageView: ImageView, imageUrl: String?) { 58 | Glide.with(imageView.context).load("https://image.tmdb.org/t/p/w185$imageUrl").into(imageView) 59 | } 60 | 61 | 62 | @BindingAdapter("imageShapeUrl") 63 | fun loadImageShape(imageView: ShapeableImageView, imageShapeUrl: String?) { 64 | Glide.with(imageView.context).load(imageShapeUrl).into(imageView) 65 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Shard 2 | 3 | ![](cover.png) 4 | 5 | > A project to showcase different architectural approaches to develop Android apps 6 | 7 | ## Built With 🛠 8 | 9 | - [Kotlin](https://kotlinlang.org/) - First class and official programming language for Android development. 10 | - [Coroutines](https://kotlinlang.org/docs/reference/coroutines-overview.html) - For asynchronous and more.. 11 | - [Android Architecture Components](https://developer.android.com/topic/libraries/architecture) - Collection of libraries that help you design robust, testable, and maintainable apps. 12 | - [LiveData](https://developer.android.com/topic/libraries/architecture/livedata) - Data objects that notify views when the underlying database changes. 13 | - [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel) - Stores UI-related data that isn't destroyed on UI changes. 14 | - [ViewBinding](https://developer.android.com/topic/libraries/view-binding) - Generates a binding class for each XML layout file present in that module and allows you to more easily write code that interacts with views. 15 | - [Room](https://developer.android.com/topic/libraries/architecture/room) - SQLite object mapping library. 16 | - [Hilt](https://developer.android.com/training/dependency-injection/hilt-android) - Dependency Injection Framework 17 | - [Retrofit](https://square.github.io/retrofit/) - A type-safe HTTP client for Android and Java. 18 | JSON. 19 | - [Glide](https://bumptech.github.io/glide/) - An image loading library for Android backed by Kotlin Coroutines. 20 | 21 | ## 🤝 Contributing 22 | 23 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any 24 | contributions you make are **greatly appreciated**. 25 | 26 | 1. Open an issue first to discuss what you would like to change. 27 | 1. Fork the Project 28 | 1. Create your feature branch (`git checkout -b feature/amazing-feature`) 29 | 1. Commit your changes (`git commit -m 'Add some amazing feature'`) 30 | 1. Push to the branch (`git push origin feature/amazing-feature`) 31 | 1. Open a pull request 32 | 33 | Please make sure to update tests as appropriate. 34 | 35 | 36 | ## ☑️ TODO 37 | 38 | - TBD 39 | 40 | ## 📝 License 41 | 42 | ``` 43 | Copyright © 2021 - Droid-Kerala 44 | 45 | Licensed under the Apache License, Version 2.0 (the "License"); 46 | you may not use this file except in compliance with the License. 47 | You may obtain a copy of the License at 48 | 49 | http://www.apache.org/licenses/LICENSE-2.0 50 | 51 | Unless required by applicable law or agreed to in writing, software 52 | distributed under the License is distributed on an "AS IS" BASIS, 53 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 54 | See the License for the specific language governing permissions and 55 | limitations under the License. 56 | ``` 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/bottomsheet/MovieDetailBottomSheet.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.bottomsheet 2 | 3 | import android.app.Dialog 4 | import android.content.pm.ActivityInfo 5 | import android.graphics.Color 6 | import android.graphics.drawable.ColorDrawable 7 | import android.os.Bundle 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import android.widget.FrameLayout 12 | import androidx.fragment.app.viewModels 13 | import com.droidkerala.theshard.R 14 | import com.droidkerala.theshard.databinding.FragementBottomSheetDetailBinding 15 | import com.droidkerala.theshard.presentation.ui.home.HomeViewModel 16 | import com.google.android.material.bottomsheet.BottomSheetBehavior 17 | import com.google.android.material.bottomsheet.BottomSheetDialog 18 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment 19 | import dagger.hilt.android.AndroidEntryPoint 20 | 21 | @AndroidEntryPoint 22 | class MovieDetailBottomSheet : BottomSheetDialogFragment() { 23 | 24 | private lateinit var fragmentBottomSheet: FragementBottomSheetDetailBinding 25 | 26 | private val homeViewModel: HomeViewModel by viewModels() 27 | 28 | var id : String? = null 29 | 30 | override fun onCreate(savedInstanceState: Bundle?) { 31 | super.onCreate(savedInstanceState) 32 | arguments?.let { 33 | id = it.getString("id") 34 | } 35 | } 36 | 37 | // override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 38 | // val bottomSheetDialog: BottomSheetDialog = BottomSheetDialog( 39 | // requireContext(), 40 | // R.style.BottomSheetStyle 41 | // ) 42 | // 43 | // bottomSheetDialog.setOnShowListener { 44 | // if (it is BottomSheetDialog) { 45 | // val view = it.findViewById(R.id.design_bottom_sheet) 46 | // if (view is FrameLayout) { 47 | // BottomSheetBehavior.from(view).state = BottomSheetBehavior.STATE_EXPANDED 48 | // } 49 | // } 50 | // } 51 | // return bottomSheetDialog 52 | // } 53 | 54 | override fun onCreateView( 55 | inflater: LayoutInflater, 56 | container: ViewGroup?, 57 | savedInstanceState: Bundle? 58 | ): View { 59 | dialog?.setCanceledOnTouchOutside(true) 60 | dialog?.setCancelable(true) 61 | dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) 62 | fragmentBottomSheet = FragementBottomSheetDetailBinding.inflate(inflater, container, false) 63 | fragmentBottomSheet.movie = id?.let { homeViewModel.getMovieListById(it) } 64 | return fragmentBottomSheet.root 65 | } 66 | 67 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 68 | super.onViewCreated(view, savedInstanceState) 69 | activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT 70 | 71 | } 72 | 73 | companion object { 74 | const val TAG: String = "MovieDetailBottomSheet" 75 | fun newInstance(id: String): MovieDetailBottomSheet { 76 | return MovieDetailBottomSheet().apply { 77 | arguments = Bundle().apply { 78 | putString("id",id) 79 | } 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | id 'kotlin-kapt' 5 | id 'dagger.hilt.android.plugin' 6 | id 'kotlin-parcelize' 7 | } 8 | 9 | android { 10 | compileSdkVersion 30 11 | buildToolsVersion "30.0.3" 12 | 13 | defaultConfig { 14 | applicationId "in.droidkerala.theshard" 15 | minSdkVersion 21 16 | targetSdkVersion 30 17 | versionCode 1 18 | versionName "1.0" 19 | 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled true 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | debug{ 29 | minifyEnabled false 30 | } 31 | } 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | kotlinOptions { 37 | jvmTarget = '1.8' 38 | } 39 | buildFeatures { 40 | viewBinding true 41 | dataBinding true 42 | } 43 | flavorDimensions "default" 44 | productFlavors { 45 | dev { 46 | 47 | } 48 | prod { 49 | 50 | } 51 | } 52 | } 53 | 54 | dependencies { 55 | 56 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 57 | implementation 'androidx.core:core-ktx:1.5.0' 58 | implementation 'androidx.appcompat:appcompat:1.3.0' 59 | implementation 'com.google.android.material:material:1.3.0' 60 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 61 | 62 | implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' 63 | implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' 64 | 65 | implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5' 66 | implementation 'androidx.navigation:navigation-ui-ktx:2.3.5' 67 | 68 | testImplementation 'junit:junit:4.13.2' 69 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 70 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 71 | 72 | implementation "com.google.dagger:dagger:$dagger2_version" 73 | kapt "com.google.dagger:dagger-compiler:$dagger2_version" 74 | kapt "com.google.dagger:dagger-android-processor:$dagger2_version" 75 | implementation "com.google.dagger:dagger-android-support:$dagger2_version" 76 | 77 | implementation 'com.github.bumptech.glide:glide:4.11.0' 78 | kapt 'com.github.bumptech.glide:compiler:4.11.0' 79 | 80 | implementation "com.squareup.retrofit2:retrofit:$retrofit_version" 81 | implementation "com.squareup.retrofit2:converter-gson:$retrofit_version" 82 | implementation "com.squareup.okhttp3:logging-interceptor:$okhttplogging_version" 83 | 84 | implementation "androidx.room:room-runtime:$rootProject.roomVersion" 85 | implementation "androidx.room:room-ktx:$rootProject.roomVersion" 86 | kapt "androidx.room:room-compiler:$rootProject.roomVersion" 87 | androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion" 88 | 89 | // Kotlin Co-routines 90 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version" 91 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version" 92 | 93 | implementation("androidx.compose.ui:ui:1.0.0-beta08") 94 | // Tooling support (Previews, etc.) 95 | implementation("androidx.compose.ui:ui-tooling:1.0.0-beta08") 96 | // Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.) 97 | implementation("androidx.compose.foundation:foundation:1.0.0-beta08") 98 | // Material Design 99 | implementation("androidx.compose.material:material:1.0.0-beta08") 100 | // Material design icons 101 | implementation("androidx.compose.material:material-icons-core:1.0.0-beta08") 102 | implementation("androidx.compose.material:material-icons-extended:1.0.0-beta08") 103 | // Integration with observables 104 | implementation("androidx.compose.runtime:runtime-livedata:1.0.0-beta08") 105 | 106 | implementation "com.google.dagger:hilt-android:$hilt_version" 107 | kapt "com.google.dagger:hilt-android-compiler:$hilt_version" 108 | implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03' 109 | kapt 'androidx.hilt:hilt-compiler:1.0.0' 110 | } -------------------------------------------------------------------------------- /app/src/main/java/com/droidkerala/theshard/presentation/ui/home/HomeFragment.kt: -------------------------------------------------------------------------------- 1 | package com.droidkerala.theshard.presentation.ui.home 2 | 3 | import android.os.Bundle 4 | import android.util.Log 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import android.widget.TextView 9 | import android.widget.Toast 10 | import androidx.compose.foundation.isSystemInDarkTheme 11 | import androidx.compose.foundation.layout.fillMaxHeight 12 | import androidx.compose.foundation.layout.fillMaxWidth 13 | import androidx.compose.foundation.lazy.LazyColumn 14 | import androidx.compose.material.MaterialTheme 15 | import androidx.compose.material.Text 16 | import androidx.compose.material.darkColors 17 | import androidx.compose.material.lightColors 18 | import androidx.compose.runtime.Composable 19 | import androidx.compose.runtime.getValue 20 | import androidx.compose.runtime.livedata.observeAsState 21 | import androidx.compose.ui.Modifier 22 | import androidx.compose.ui.graphics.Color 23 | import androidx.compose.ui.text.input.KeyboardType.Companion.Text 24 | import androidx.core.os.bundleOf 25 | import androidx.fragment.app.Fragment 26 | import androidx.fragment.app.viewModels 27 | import androidx.lifecycle.Observer 28 | import androidx.lifecycle.ViewModelProvider 29 | import androidx.navigation.fragment.findNavController 30 | import com.droidkerala.theshard.R 31 | import com.droidkerala.theshard.data.Movie 32 | import com.droidkerala.theshard.databinding.FragmentHomeBinding 33 | import com.droidkerala.theshard.presentation.ui.adapters.PopularMoviesAdapter 34 | import com.droidkerala.theshard.utils.Status 35 | import dagger.hilt.android.AndroidEntryPoint 36 | import io.shrineapps.divinevibes.ui.theme.Red700 37 | import io.shrineapps.divinevibes.ui.theme.Red800 38 | import io.shrineapps.divinevibes.ui.theme.Red900 39 | import javax.inject.Inject 40 | 41 | @AndroidEntryPoint 42 | class HomeFragment : Fragment(), PopularMoviesAdapter.OnPopularMovieListener { 43 | 44 | 45 | private val lightColors = lightColors( 46 | primary = Red700, 47 | primaryVariant = Red900, 48 | onPrimary = Color.Black, 49 | secondary = Red700, 50 | secondaryVariant = Red900, 51 | onSecondary = Color.Black, 52 | error = Red800, 53 | ) 54 | 55 | private val darkColors = darkColors( 56 | primary = Red700, 57 | primaryVariant = Red900, 58 | onPrimary = Color.White, 59 | secondary = Red700, 60 | secondaryVariant = Red900, 61 | onSecondary = Color.White, 62 | error = Red800 63 | ) 64 | 65 | 66 | private var _binding: FragmentHomeBinding? = null 67 | 68 | private val homeViewModel: HomeViewModel by viewModels() 69 | 70 | private val binding get() = _binding!! 71 | 72 | override fun onCreateView( 73 | inflater: LayoutInflater, 74 | container: ViewGroup?, 75 | savedInstanceState: Bundle? 76 | ): View? { 77 | 78 | 79 | _binding = FragmentHomeBinding.inflate(inflater, container, false) 80 | val root: View = binding.root 81 | binding.recyclerPopularMovies.apply { 82 | adapter = PopularMoviesAdapter(this@HomeFragment) 83 | } 84 | // Todo Tmdb API here 85 | homeViewModel.getMovies("",1).observe(viewLifecycleOwner,{ 86 | it?.let { resource -> 87 | when (resource.status) { 88 | Status.SUCCESS -> { 89 | Log.d("hai", resource.data.toString()) 90 | resource.data?.results?.let { it1 -> 91 | (binding.recyclerPopularMovies.adapter as PopularMoviesAdapter).setData( 92 | it1 93 | ) 94 | } 95 | } 96 | Status.ERROR -> { 97 | Toast.makeText(requireContext(), it.message, Toast.LENGTH_LONG).show() 98 | } 99 | Status.LOADING -> { 100 | 101 | } 102 | } 103 | } 104 | }) 105 | return root 106 | } 107 | 108 | override fun onDestroyView() { 109 | super.onDestroyView() 110 | _binding = null 111 | } 112 | 113 | override fun onPopularMovieSelected(movie: Movie) { 114 | findNavController().navigate(R.id.bottom_sheet_detail, bundleOf("id" to movie.id)) 115 | } 116 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/fragement_bottom_sheet_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 19 | 20 | 21 | 32 | 33 | 45 | 46 | 57 | 58 | 69 | 70 | 85 | 86 | 94 | 95 | 105 | 106 | 121 | 122 | 130 | 131 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------