Skip to content

Commit ec1ba1a

Browse files
committed
Add App class. Update libs version
1 parent f30a1ea commit ec1ba1a

15 files changed

+131
-613
lines changed

.gitignore

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
# built application files
1+
# Built application files
22
*.apk
33
*.ap_
44

5-
# files for the dex VM
5+
# Files for the dex VM
66
*.dex
77

88
# Java class files
99
*.class
1010

11-
# generated files
11+
# Generated files
1212
bin/**
1313
gen/**
1414
out/**
1515
gen-external-apklibs/**
16+
reports/**
1617

1718
# Local configuration file (sdk path, etc)
1819
local.properties
1920

20-
# AndroidStudio
21+
# Android Studio
2122
*.iml
2223
*.ipr
2324
*.iws
@@ -26,6 +27,9 @@ local.properties
2627
classes/**
2728
target/**
2829

30+
# JNI
31+
.externalNativeBuild
32+
2933
# Mac OS
3034
.DS_Store
3135

app/build.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ kapt {
2525
generateStubs = true
2626
}
2727

28-
ext.support_lib_version = '27.0.2'
28+
ext.support_lib_version = '27.1.0'
2929
ext.kotlinx_coroutines = '0.20'
3030
ext.leakcanary = '1.5'
3131

@@ -34,7 +34,6 @@ dependencies {
3434

3535
// Kotlin
3636
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
37-
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinx_coroutines"
3837

3938
// Android
4039
implementation "com.android.support:appcompat-v7:$support_lib_version"
@@ -46,7 +45,7 @@ dependencies {
4645
testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary"
4746

4847
// Logger
49-
implementation 'com.jakewharton.timber:timber:4.6.0'
48+
implementation 'com.jakewharton.timber:timber:4.6.1'
5049

5150
// Unit tests
5251
testImplementation 'junit:junit:4.12'

app/src/main/AndroidManifest.xml

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
package="com.zhukovme.player">
44

55
<application
6+
android:name=".App"
67
android:allowBackup="false"
78
android:icon="@mipmap/ic_launcher"
89
android:label="@string/app_name"
910
android:roundIcon="@mipmap/ic_launcher_round"
1011
android:supportsRtl="true"
11-
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity">
12+
android:theme="@style/AppTheme.Default">
13+
14+
<activity android:name=".ui.MainActivity">
1315
<intent-filter>
1416
<action android:name="android.intent.action.MAIN"/>
15-
1617
<category android:name="android.intent.category.LAUNCHER"/>
1718
</intent-filter>
1819
</activity>
20+
1921
</application>
2022

2123
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.zhukovme.player
2+
3+
import android.app.Application
4+
import android.content.Context
5+
import com.squareup.leakcanary.LeakCanary
6+
import com.squareup.leakcanary.RefWatcher
7+
import timber.log.Timber
8+
9+
/**
10+
* Created by Michael Zhukov on 25.12.2017.
11+
12+
*/
13+
class App : Application() {
14+
15+
companion object {
16+
fun get(context: Context): App = context.applicationContext as App
17+
}
18+
19+
lateinit var refWatcher: RefWatcher
20+
21+
override fun onCreate() {
22+
super.onCreate()
23+
if (setupLeakCanary()) return
24+
25+
debugInit()
26+
}
27+
28+
private fun setupLeakCanary(): Boolean {
29+
if (LeakCanary.isInAnalyzerProcess(this)) {
30+
return true
31+
}
32+
refWatcher = LeakCanary.install(this)
33+
return false
34+
}
35+
36+
private fun debugInit() {
37+
if (BuildConfig.DEBUG) {
38+
Timber.plant(Timber.DebugTree())
39+
}
40+
}
41+
}

app/src/main/java/com/zhukovme/player/MainActivity.kt

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.zhukovme.player.ui
2+
3+
import android.os.Bundle
4+
import com.zhukovme.player.R
5+
import com.zhukovme.player.ui.base.BaseActivity
6+
7+
/**
8+
* Created by Michael Zhukov on 05.03.2018.
9+
10+
*/
11+
class MainActivity : BaseActivity() {
12+
13+
override fun onCreate(savedInstanceState: Bundle?) {
14+
super.onCreate(savedInstanceState)
15+
setContentView(R.layout.activity_main)
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.zhukovme.player.ui.base
2+
3+
import android.support.v7.app.AppCompatActivity
4+
5+
/**
6+
* Created by Michael Zhukov on 05.03.2018.
7+
8+
*/
9+
abstract class BaseActivity : AppCompatActivity()
+2-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<android.support.constraint.ConstraintLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:app="http://schemas.android.com/apk/res-auto"
54
xmlns:tools="http://schemas.android.com/tools"
65
android:layout_width="match_parent"
76
android:layout_height="match_parent"
8-
tools:context="com.zhukovme.player.MainActivity">
7+
tools:context="com.zhukovme.player.ui.MainActivity">
98

109
<TextView
1110
android:layout_width="wrap_content"
1211
android:layout_height="wrap_content"
13-
android:text="Hello World!"
14-
app:layout_constraintBottom_toBottomOf="parent"
15-
app:layout_constraintLeft_toLeftOf="parent"
16-
app:layout_constraintRight_toRightOf="parent"
17-
app:layout_constraintTop_toTopOf="parent"/>
12+
android:text="@string/app_name"/>
1813

1914
</android.support.constraint.ConstraintLayout>

app/src/main/res/values/styles.xml

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<resources>
22

3-
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5-
<!-- Customize your theme here. -->
3+
<style name="AppTheme.Default" parent="Theme.AppCompat.Light.NoActionBar">
64
<item name="colorPrimary">@color/colorPrimary</item>
75
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
86
<item name="colorAccent">@color/colorAccent</item>

build.gradle

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.2.0'
2+
ext.kotlin_version = '1.2.30'
33
repositories {
44
google()
55
jcenter()
@@ -11,7 +11,7 @@ buildscript {
1111
}
1212

1313
plugins {
14-
id "io.gitlab.arturbosch.detekt" version "1.0.0.RC5-6"
14+
id "io.gitlab.arturbosch.detekt" version "1.0.0.RC6-3"
1515
}
1616

1717
allprojects {
@@ -26,12 +26,10 @@ task clean(type: Delete) {
2626
}
2727

2828
detekt {
29-
debug = true
30-
version = "1.0.0.RC5-6"
29+
version = "1.0.0.RC6-3"
3130
profile("main") {
3231
input = "$rootDir/app/src/main/java"
3332
output = "$rootDir/reports"
34-
config = "$rootDir/tools/detekt-config.yml"
35-
filters = ".*test.*,.*/resources/.*"
33+
filters = ".*test.*,.*/resources/.*,.*/tmp/.*"
3634
}
3735
}

prepare-commit-msg-hook

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
run () {
4+
echo -e "\n --- ${1} --- \n"
5+
eval $2
6+
result=$?
7+
if [ $result -ne 0 ]
8+
then
9+
echo -e "\n --- ${1} failed --- \n"
10+
echo "Commit rejected"
11+
exit 1
12+
fi
13+
}
14+
15+
checkForSkipTestsSign () {
16+
skip_tests_sign="!"
17+
first_char=$(head -c 1 $1)
18+
if [ "$first_char" == "$skip_tests_sign" ]
19+
then
20+
echo $(sed "s/^${first_char}//" $1) > $1
21+
return 1
22+
fi
23+
return 0
24+
}
25+
26+
# Detekt
27+
detekt_task_title="Detekt"
28+
detekt_task="./gradlew detektCheck --daemon"
29+
# Lint
30+
lint_task_title="Lint"
31+
lint_task="./gradlew lint --daemon"
32+
# Tests
33+
tests_task_title="Tests"
34+
tests_task="./gradlew test --daemon"
35+
36+
checkForSkipTestsSign $1
37+
if [ $? -eq 0 ]
38+
then
39+
run "$detekt_task_title" "$detekt_task"
40+
run "$lint_task_title" "$lint_task"
41+
run "$tests_task_title" "$tests_task"
42+
fi

reports/detekt-checkstyle.xml

-3
This file was deleted.

reports/detekt-plain.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)