Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update projet with latest dependancies versions + mockK + some fixes #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ https://home.openweathermap.org/api_keys

### Tools / Libs Utilized
- Jetbrains Kotlin : https://kotlinlang.org/
- Toothpick Dependency Injection : https://github.com/stephanenicolas/toothpick
- Toothpick Dependency Injection 2.1.0 : https://github.com/stephanenicolas/toothpick
- RxJava 2 / RxAndroid : https://github.com/ReactiveX/RxJava
- Retrofit 2 : http://square.github.io/retrofit/
- Picasso : http://square.github.io/picasso/
- EasyMock : http://easymock.org/
- Mockk : https://github.com/mockk/mockk
52 changes: 24 additions & 28 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "weather.ekamp.com.weatherappkotlin"
minSdkVersion 23
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand All @@ -32,33 +33,28 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$SUPPORT_LIBS_VERSION"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "com.squareup.picasso:picasso:$PICASSO_VERSION"
compile "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:converter-moshi:$RETROFIT_VERSION"
compile "com.squareup.retrofit2:adapter-rxjava2:$RETROFIT_VERSION"
compile "io.reactivex.rxjava2:rxjava:$RX_JAVA_VERSION"
compile "io.reactivex.rxjava2:rxandroid:$RX_ANDROID_VERSION"
compile "com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"
compile "com.github.stephanenicolas.toothpick:toothpick-runtime:$TOOTHPICK_VERSION"
compile "com.github.stephanenicolas.toothpick:smoothie:$TOOTHPICK_VERSION"
kapt "com.github.stephanenicolas.toothpick:toothpick-compiler:$TOOTHPICK_VERSION"
testCompile "com.github.stephanenicolas.toothpick:toothpick-testing:$TOOTHPICK_VERSION"
testCompile "junit:junit:$JUNIT_VERSION"
testCompile "org.easymock:easymock:$EASYMOCK_VERSION"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.appcompat:appcompat:1.0.2"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31"
implementation "com.squareup.picasso:picasso:2.71828"
implementation "com.squareup.retrofit2:retrofit:2.6.0"
implementation "com.squareup.retrofit2:converter-moshi:2.6.0"
implementation "com.squareup.retrofit2:adapter-rxjava2:2.6.0"
implementation "io.reactivex.rxjava2:rxjava:2.2.10"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
implementation "com.google.android.gms:play-services-location:17.0.0"

implementation 'com.github.stephanenicolas.toothpick:toothpick-runtime:2.1.0'
implementation 'com.github.stephanenicolas.toothpick:smoothie:2.1.0'
implementation "com.github.stephanenicolas.toothpick:smoothie-androidx:2.1.0"
kapt "com.github.stephanenicolas.toothpick:toothpick-compiler:2.1.0"
testImplementation "com.github.stephanenicolas.toothpick:toothpick-testing-junit4:2.1.0"
testImplementation "junit:junit:4.12"
testImplementation "io.mockk:mockk:1.9.3"
}

kapt {
generateStubs = true

arguments {
arg("toothpick_registry_package_name", "weather.ekamp.com.weatherappkotlin")
arg("toothpick_registry_children_package_names", "toothpick.smoothie")
}
}

repositories {
mavenCentral()
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
package weather.ekamp.com.weatherappkotlin

import android.app.Application
import toothpick.smoothie.module.SmoothieApplicationModule
import toothpick.Toothpick
import toothpick.smoothie.module.SmoothieApplicationModule
import weather.ekamp.com.weatherappkotlin.model.inject.WeatherApplicationModule

import toothpick.configuration.Configuration.forDevelopment
import toothpick.configuration.Configuration.forProduction
import toothpick.registries.FactoryRegistryLocator
import toothpick.registries.MemberInjectorRegistryLocator
import toothpick.Toothpick.setConfiguration

class WeatherApplication : Application() {
override fun onCreate() {
super.onCreate()
val configuration = if (BuildConfig.DEBUG) forDevelopment() else forProduction()
setConfiguration(configuration.disableReflection())
FactoryRegistryLocator.setRootRegistry(FactoryRegistry())
MemberInjectorRegistryLocator.setRootRegistry(MemberInjectorRegistry())

val appScope = Toothpick.openScope(this)
appScope.installModules(SmoothieApplicationModule(this), WeatherApplicationModule(this))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.Manifest
import android.app.Activity
import android.app.Application
import android.content.pm.PackageManager
import android.support.v4.app.ActivityCompat
import android.support.v4.content.ContextCompat
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import javax.inject.Inject
import javax.inject.Singleton

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UserLocationManager {
fusedLocationClient.lastLocation
.addOnCompleteListener(activity) { task ->
if (task.isSuccessful && task.result != null) {
locationUpdateListener.onLocationUpdated(task.result)
locationUpdateListener.onLocationUpdated(task.result!!)
} else {
Log.w(TAG, "getLastLocation:exception", task.exception)
locationUpdateListener.onLocationNotFound()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import javax.inject.Singleton
@Singleton
open class WeatherService @Inject constructor(var application: Application) {

private val BASE_URL = "http://api.openweathermap.org/data/2.5/"
private val BASE_URL = "https://api.openweathermap.org/data/2.5/"
private val WEATHER_API_KEY = BuildConfig.WEATHER_API_KEY
private val TEMPERATURE_UNITS = "imperial"
private val sizeOfHttpCache : Long = 10 * 1024 * 1024 // 10 MiB
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package weather.ekamp.com.weatherappkotlin.view

import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import kotlinx.android.synthetic.main.error_dialog.*
import weather.ekamp.com.weatherappkotlin.R
import kotlinx.android.synthetic.main.error_dialog.*;

class ErrorDialog : DialogFragment() {

lateinit private var message : String
lateinit private var message: String

companion object {
fun newInstance(message : String) : ErrorDialog {
fun newInstance(message: String): ErrorDialog {
var newInstance = ErrorDialog()
newInstance.message = message
return newInstance
}
}

override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater?.inflate(R.layout.error_dialog, container)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater.inflate(R.layout.error_dialog, container)
}

override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
confirmationButton.setOnClickListener {
dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package weather.ekamp.com.weatherappkotlin.view

import android.annotation.SuppressLint
import android.location.Location
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import androidx.appcompat.app.AppCompatActivity
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.activity_main.*
import toothpick.Scope
Expand All @@ -14,14 +16,15 @@ import weather.ekamp.com.weatherappkotlin.model.location.UserLocationManager
import weather.ekamp.com.weatherappkotlin.model.parsers.WeatherDescription
import weather.ekamp.com.weatherappkotlin.presenter.LandingPresenter
import javax.inject.Inject
import android.view.animation.AnimationUtils

class Landing : AppCompatActivity(), LandingView {

@Inject lateinit var presenter : LandingPresenter
@Inject lateinit var userLocationManager : UserLocationManager
lateinit private var errorDialog : ErrorDialog
lateinit private var activityScope : Scope
@Inject
lateinit var presenter: LandingPresenter
@Inject
lateinit var userLocationManager: UserLocationManager
lateinit private var errorDialog: ErrorDialog
lateinit private var activityScope: Scope

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -37,26 +40,22 @@ class Landing : AppCompatActivity(), LandingView {
weather_description.text = weatherDescription.getWeatherInformation().description
temperature.text = weatherDescription.main.temp
var weatherIconPath = weatherDescription.getIconUrlPath()
Picasso.with(this).
load(weatherIconPath).
fit().
placeholder(R.drawable.cloud).
error(R.drawable.cloud).
into(weather_representation)
Picasso.get().load(weatherIconPath).fit().placeholder(R.drawable.cloud).error(R.drawable.cloud).into(weather_representation)
}

override fun displayUserLocation(userLocationForDisplay : String) {
override fun displayUserLocation(userLocationForDisplay: String) {
user_location.text = userLocationForDisplay
}

@SuppressLint("ResourceType")
override fun displayLoadingIndicator() {
loading_indicator.visibility = View.VISIBLE
weather_description.visibility = View.GONE
temperature.visibility = View.GONE
weather_representation.visibility = View.GONE
sync_button.animation?.let {
sync_button.animation.repeatCount = Animation.INFINITE
} ?:run {
} ?: run {
val rotation = AnimationUtils.loadAnimation(this, R.animator.sync_rotator)
rotation.repeatCount = Animation.INFINITE
sync_button.startAnimation(rotation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package weather.ekamp.com.weatherappkotlin.view
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import toothpick.Scope
import toothpick.Toothpick
import weather.ekamp.com.weatherappkotlin.R
Expand All @@ -15,10 +15,11 @@ import javax.inject.Inject
class Splash : AppCompatActivity(), SplashView {
val ERROR_DIALOG_TAG = "location_permission_error_dialog"

@Inject lateinit var presenter : SplashPresenter
lateinit var activityScope : Scope
@Inject
lateinit var presenter: SplashPresenter
lateinit var activityScope: Scope

lateinit var errorDialog : ErrorDialog
lateinit var errorDialog: ErrorDialog
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityScope = Toothpick.openScopes(application, this)
Expand Down
Loading