Skip to content

Commit

Permalink
alpha3 -> ActivityLifecycleEvent in BaseApp, new Sqlite module
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazer committed Jul 8, 2016
1 parent 41b7eb2 commit 0c18da2
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ext {
ankoVersion : "0.8.3",
]
GROUP = "com.guizion.frameworks.yaf"
VERSION_NAME = "1.0.0-alpha2"
VERSION_NAME = "1.0.0-alpha3"
}

buildscript {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.vithor.yamvpframework.ui
package io.vithor.yamvpframework.core

/**
* Created by Hazer on 4/11/16.
*/
enum class ActivityLifecycle {
enum class ActivityLifecycleEvent {
None,
Started,
Stopped,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package io.vithor.yamvpframework.core

import android.app.Activity
import android.app.Application
import android.os.Bundle
import android.support.multidex.MultiDexApplication
import de.halfbit.tinybus.TinyBus


/**
* Created by Vithorio Polten on 12/31/15.
*/
open class BaseApplication : MultiDexApplication() {
open class BaseApplication : MultiDexApplication(), Application.ActivityLifecycleCallbacks {
val bus: TinyBus by lazy { TinyBus.from(this) }

/*
Expand All @@ -29,6 +32,40 @@ open class BaseApplication : MultiDexApplication() {

override fun onCreate() {
super.onCreate()
activityState = ActivityLifecycleEvent.None
bus.register(this)
}

override fun onActivityStarted(activity: Activity?) {
activityState = ActivityLifecycleEvent.Started
}

override fun onActivityStopped(activity: Activity?) {
activityState = ActivityLifecycleEvent.Stopped
}

override fun onActivityResumed(activity: Activity?) {
activityState = ActivityLifecycleEvent.Resumed
}

override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) {
activityState = ActivityLifecycleEvent.SaveInstanceState
}

override fun onActivityDestroyed(activity: Activity?) {
activityState = ActivityLifecycleEvent.Destroyed
}

override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) {
activityState = ActivityLifecycleEvent.Created
}

override fun onActivityPaused(activity: Activity?) {
activityState = ActivityLifecycleEvent.Paused
}

companion object {
var activityState = ActivityLifecycleEvent.None
private set
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ include ':core',
':permissions',
':validation',
':migration',
':sqlite',
':rest'

1 change: 1 addition & 0 deletions sqlite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
56 changes: 56 additions & 0 deletions sqlite/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
buildscript {
repositories { jcenter() }
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
apply plugin: 'org.jetbrains.dokka-android'

kapt {
generateStubs = true
}

android {
compileSdkVersion compile_sdk_version
buildToolsVersion "$build_tools_version"

defaultConfig {
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
}

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile "com.winterbe:expekt:0.4.0"
testCompile 'com.nhaarman:mockito-kotlin:0.5.0'

compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

compile "org.jetbrains.anko:anko-sdk23:${libraries.ankoVersion}"
compile "org.jetbrains.anko:anko-support-v4:${libraries.ankoVersion}"
compile "org.jetbrains.anko:anko-appcompat-v7:${libraries.ankoVersion}"

compile 'com.github.Hazer:kuery:0.0.1-alpha0'

//javadocDeps "com.android.support:support-v4:${libraries.supportVersion}"
}

apply from: new File("${rootProject.projectDir}/publish.gradle")
17 changes: 17 additions & 0 deletions sqlite/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Guizion/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.vithor.yaframework.sqlite;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
4 changes: 4 additions & 0 deletions sqlite/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.vithor.yaframework.sqlite">
<application/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package io.vithor.yaframework.sqlite
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.vithor.yaframework.sqlite;

import org.junit.Test;

import static org.junit.Assert.*;

/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}

0 comments on commit 0c18da2

Please sign in to comment.