Skip to content

Commit 6a94fe4

Browse files
committed
arch components implementation
1 parent dab38ba commit 6a94fe4

File tree

138 files changed

+1822
-3583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+1822
-3583
lines changed

.gitignore

+52-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,53 @@
1-
.gradle
2-
/local.properties
3-
/.idea
1+
### Android template
2+
# Built application files
3+
*.apk
4+
*.ap_
5+
6+
# Files for the ART/Dalvik VM
7+
*.dex
8+
9+
# Java class files
10+
*.class
11+
12+
# Generated files
13+
bin/
14+
gen/
15+
out/
16+
17+
# Gradle files
18+
.gradle/
19+
build/
20+
21+
# Local configuration file (sdk path, etc)
22+
local.properties
23+
keys.properties
24+
25+
# Proguard folder generated by Eclipse
26+
proguard/
27+
28+
# Log Files
29+
*.log
30+
31+
# Android Studio Navigation editor temp files
32+
.navigation/
33+
34+
# Android Studio captures folder
35+
captures/
36+
37+
# Intellij
438
*.iml
5-
.DS_Store
6-
/build
7-
/captures
8-
sqlite_scheme.sqs
39+
.idea/
40+
41+
# Keystore files
42+
*.jks
43+
44+
# External native build folder generated in Android Studio 2.2 and later
45+
.externalNativeBuild
46+
47+
# Google Services (e.g. APIs or Firebase)
48+
google-services.json
49+
50+
# Freeline
51+
freeline.py
52+
freeline/
53+
freeline_project_description.json

app/build.gradle

+36-16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ apply plugin: 'com.android.application'
1818
apply plugin: 'kotlin-android'
1919
apply plugin: 'kotlin-kapt'
2020

21+
def keysProperties = new Properties()
22+
keysProperties.load(new FileInputStream(rootProject.file("keys.properties")))
23+
2124
android {
2225
compileSdkVersion 25
2326
buildToolsVersion "25.0.2"
@@ -37,50 +40,67 @@ android {
3740
}
3841
}
3942

43+
buildTypes.each {
44+
it.buildConfigField 'String', 'MOVIE_DB_API_KEY', keysProperties['MovieDbApiKey']
45+
}
46+
4047
dataBinding {
4148
enabled = true
4249
}
4350
}
4451

4552
ext {
4653
supportLibVersion = '25.3.1'
54+
archComponentsVersion = '1.0.0-alpha1'
4755
daggerVersion = '2.7'
48-
ankoVersion = '0.9.1'
49-
rxBindingVersion = '1.0.0'
56+
retrofitVersion = '2.3.0'
5057
paperParcelVersion = '2.0.1'
51-
retrofitVersion = '2.1.0'
58+
stethoVersion = '1.5.0'
5259
}
5360

5461
dependencies {
5562
compile fileTree(dir: 'libs', include: ['*.jar'])
5663
testCompile 'junit:junit:4.12'
57-
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
64+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
65+
exclude group: 'com.android.support', module: 'support-annotations'
66+
})
67+
68+
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
5869
kapt 'com.android.databinding:compiler:2.3.0'
70+
5971
compile "com.android.support:support-v4:${supportLibVersion}"
6072
compile "com.android.support:appcompat-v7:${supportLibVersion}"
6173
compile "com.android.support:design:${supportLibVersion}"
6274
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
6375
compile "com.android.support:support-annotations:${supportLibVersion}"
64-
compile 'com.facebook.stetho:stetho:1.5.0'
76+
compile "android.arch.lifecycle:runtime:$archComponentsVersion"
77+
compile "android.arch.lifecycle:extensions:$archComponentsVersion"
78+
compile "android.arch.lifecycle:reactivestreams:$archComponentsVersion"
79+
kapt "android.arch.lifecycle:compiler:$archComponentsVersion"
80+
compile "android.arch.persistence.room:runtime:$archComponentsVersion"
81+
compile "android.arch.persistence.room:rxjava2:$archComponentsVersion"
82+
kapt "android.arch.persistence.room:compiler:$archComponentsVersion"
83+
6584
compile "com.google.dagger:dagger:${daggerVersion}"
6685
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
6786
provided 'javax.annotation:jsr250-api:1.0'
68-
compile 'io.reactivex:rxjava:1.2.4'
69-
compile 'io.reactivex:rxandroid:1.2.1'
70-
compile 'com.jakewharton.rxrelay:rxrelay:1.2.0'
71-
compile "com.jakewharton.rxbinding:rxbinding-kotlin:${rxBindingVersion}"
72-
compile "com.jakewharton.rxbinding:rxbinding-support-v4-kotlin:${rxBindingVersion}"
73-
compile "com.jakewharton.rxbinding:rxbinding-appcompat-v7-kotlin:${rxBindingVersion}"
74-
compile "com.jakewharton.rxbinding:rxbinding-design-kotlin:${rxBindingVersion}"
75-
compile "org.jetbrains.anko:anko-common:${ankoVersion}"
76-
compile "org.jetbrains.anko:anko-sqlite:${ankoVersion}"
87+
88+
compile 'io.reactivex.rxjava2:rxjava:2.1.0'
89+
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
90+
compile 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
91+
92+
compile "com.facebook.stetho:stetho:${stethoVersion}"
93+
compile "com.facebook.stetho:stetho-okhttp3:${stethoVersion}"
7794
compile 'com.jakewharton.timber:timber:4.5.1'
95+
7896
compile "nz.bradcampbell:paperparcel:${paperParcelVersion}"
7997
compile "nz.bradcampbell:paperparcel-kotlin:${paperParcelVersion}"
8098
kapt "nz.bradcampbell:paperparcel-compiler:${paperParcelVersion}"
81-
compile 'com.github.bumptech.glide:glide:3.7.0'
99+
82100
compile "com.squareup.retrofit2:retrofit:${retrofitVersion}"
83101
compile "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
84-
compile "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"
102+
compile "com.squareup.retrofit2:adapter-rxjava2:${retrofitVersion}"
103+
104+
compile 'com.github.bumptech.glide:glide:3.7.0'
85105
compile 'com.vinaysshenoy:mugen:1.0.2'
86106
}

app/src/androidTest/java/ch/berta/fabio/popularmovies/DbTest.java

-133
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ch.berta.fabio.popularmovies;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.assertEquals;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("ch.berta.fabio.popularmovies", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,6 @@
4848
android:theme="@style/AppTheme.DrawStatusBar.Explode"
4949
/>
5050

51-
<provider
52-
android:name=".data.storage.MovieProvider"
53-
android:authorities="ch.berta.fabio.popularmovies"
54-
android:enabled="true"
55-
android:exported="false"
56-
/>
5751
</application>
5852

5953
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package ch.berta.fabio.popularmovies
2+
3+
import android.animation.ObjectAnimator
4+
import android.widget.TextView
5+
import io.reactivex.Observable
6+
import java.text.DateFormat
7+
import java.util.*
8+
9+
10+
fun <T> Observable<T>.log(tag: String): Observable<T> = doOnNext { timber.log.Timber.d("$tag: $it") }
11+
12+
private const val COLLAPSE_EXPAND_ANIM_TIME: Long = 300
13+
private const val MAX_LINES_EXPANDED = 500
14+
15+
/**
16+
* Expands or collapses a [TextView] by increasing or decreasing its maxLines setting.
17+
*
18+
* @param maxLinesCollapsed the number of lines in the collapsed state
19+
*/
20+
fun TextView.expandOrCollapse(maxLinesCollapsed: Int) {
21+
val value = if (maxLines == maxLinesCollapsed) MAX_LINES_EXPANDED else maxLinesCollapsed
22+
val anim = ObjectAnimator.ofInt(this, "maxLines", value)
23+
anim.duration = COLLAPSE_EXPAND_ANIM_TIME
24+
anim.start()
25+
}
26+
27+
fun Date.formatLong(): String = DateFormat.getDateInstance(DateFormat.LONG, Locale.getDefault()).format(this)
28+
29+
fun Date.formatShort(): String = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()).format(this)

app/src/main/java/ch/berta/fabio/popularmovies/Maybe.kt

-33
This file was deleted.

0 commit comments

Comments
 (0)