Skip to content

Commit

Permalink
Merge pull request #6 from Urdzik/dagger2-branch-activity
Browse files Browse the repository at this point in the history
Added dagger 2 and new caching system
  • Loading branch information
Slavik Urdzik authored Feb 29, 2020
2 parents 09f62cc + 1c922ef commit 47a7cdf
Show file tree
Hide file tree
Showing 47 changed files with 557 additions and 663 deletions.
7 changes: 0 additions & 7 deletions .gitignore

This file was deleted.

125 changes: 0 additions & 125 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/gradle.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/misc.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

60 changes: 59 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,59 @@
# MovieApp
![MovieApp](/readme/Photo%20for%20github.png?raw=true)


[![Kotlin](https://img.shields.io/badge/Kotlin-1.3.61-blue.svg)](https://kotlinlang.org)
[![Dagger2](https://img.shields.io/badge/Dagger%202-2.26-red.svg)](https://github.com/google/dagger)
[![Material design](https://img.shields.io/badge/Material%20Design-1.2.0--alpha%205-%237464f2)](https://material.io)

<h3 size="1">Application which retrieves data from Webserver (via Retrofit), saves it into Room and get from it if user is offline. There are applying MVVM architecture pattern and Dagger 2 example.</h3><br/>

<font size="6">Overview:</font><br/>
=======================================================


* ### __Model__
Model is implemented as Repository pattern. Firstly it begins from internet connection checking. Consequently if it's alive we're retrieving data from the server (by using Retrofit 2) and inserting into the SQLite database. Otherwise we're trying to fetch data from the SQLite itself.
* ### __View__
View is realised as 2 fragments. First one contains RecyclerView, second one depends on clicks on recycler-items and finally displays detailed data fetched from the Model. It implements state saving reflected on configuration changes.
<br/><br/>

<div align = "center">
<img src = "readme/Screenshot_1582798408_framed.png?raw=true" width="330">
<img src = "readme/Screenshot_1582798427_framed.png?raw=true" width="330">
</div>

* ### __ViewModel__
ViewModel is responsible for transferring data between view and model.
* ### __Dagger 2__
– Implementation of dependency injection for communication between app modules<br/>
– AndroidInjector applying for injecting into View components<br/>
– Unit-testing simplifying
<br/><br/>


<font size="6">Applied technologies and libraries:</font><br/>
=======================================================

* ### __Model__
* __Retrofit 2__ <br/>
– getting data from server into pojo-classes

* __SQLite__ <br/>
– storing data fetched from server. User get data here if he is offline

* __Coroutines__ <br/>
– managing asynchronous database and network queries<br/>
– using instead of callbacks<br/>
– providing light asynchronous operations

* ### __ViewModel__
* __LiveData__ <br/>
– observer-pattern implementation for View interaction

* ### __View__
* __Fragments__ <br/>
– interactive displaying and click reflecting

* __Data Binding__ <br/>
– replace basic operations with UI (e.g. findViewById() ) to the XML

1 change: 0 additions & 1 deletion app/.gitignore

This file was deleted.

32 changes: 26 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.movieapp"
minSdkVersion 21
Expand All @@ -26,6 +26,12 @@ android {
dataBinding {
enabled = true
}
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
}

dependencies {
Expand All @@ -35,11 +41,11 @@ dependencies {
// support libraries
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha04'
implementation 'com.google.android.material:material:1.2.0-alpha05'


// Android KTX
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'

// constraint layout
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Expand All @@ -49,14 +55,20 @@ dependencies {
implementation "android.arch.navigation:navigation-ui-ktx:1.0.0"

// coroutines for getting off the UI thread
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"


// retrofit for networking
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
implementation 'com.squareup.retrofit2:converter-moshi:2.6.0'
implementation "com.squareup.retrofit2:converter-gson:2.7.1"

//OkHTTP
implementation"com.squareup.okhttp3:okhttp:4.4.0"
implementation "com.squareup.okhttp3:logging-interceptor:4.4.0"
implementation 'com.google.code.gson:gson:2.8.5'

// moshi for parsing the JSON format
def moshi_version = "1.6.0"
Expand All @@ -76,8 +88,16 @@ dependencies {
kapt 'com.github.bumptech.glide:compiler:4.11.0'

//Database
def room_version = "2.2.0"
def room_version = "2.2.4"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"

//Dagger 2
def dagger_version = "2.25.4"
implementation "com.google.dagger:dagger:$dagger_version"
implementation "com.google.dagger:dagger-android:$dagger_version"
implementation "com.google.dagger:dagger-android-support:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version"
kapt "com.google.dagger:dagger-android-processor:$dagger_version"

}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".dagger.App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand All @@ -18,6 +19,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.detail.DetailActivity"/>

</application>

</manifest>
23 changes: 23 additions & 0 deletions app/src/main/java/com/example/movieapp/dagger/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.movieapp.dagger

import android.app.Application
import com.example.movieapp.dagger.component.AppComponent
import com.example.movieapp.dagger.component.DaggerAppComponent
import com.example.movieapp.dagger.module.NetworkModule
import com.example.movieapp.ui.detail.DetailActivity


class App : Application(){
companion object{
lateinit var appComponent: AppComponent
}

override fun onCreate() {
super.onCreate()
appComponent = DaggerAppComponent
.builder()
.networkModule(NetworkModule(this))
.build()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.movieapp.dagger.component


import com.example.movieapp.dagger.module.NetworkModule
import com.example.movieapp.dagger.module.viewModule.ViewModelModule
import com.example.movieapp.ui.detail.DetailActivity
import com.example.movieapp.ui.overview.OverviewFragment
import dagger.Component
import javax.inject.Singleton

@Singleton
@Component(modules = [NetworkModule::class, ViewModelModule::class])
interface AppComponent{
fun inject(overviewFragment: OverviewFragment)
fun inject(detailActivity: DetailActivity)
}
Loading

0 comments on commit 47a7cdf

Please sign in to comment.