Skip to content

Commit

Permalink
-migrated to AndroidX
Browse files Browse the repository at this point in the history
-changed package scope to more valid
-upgraded arch.lifecycle version
-simplified unused imports
  • Loading branch information
Luteoos committed Jul 1, 2019
1 parent 12ccf12 commit afe3128
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 71 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Android--MVVMLib with LiveData
Base classes for easier handling MVVM in android/Kotlin

Contains android.arch.lifecycle:extensions:1.1.1
Contains android.arch.lifecycle:extensions:2.0.0

```
maven { url 'https://jitpack.io' }
implementation 'com.github.Luteoos:Android--MVVMLib:3.0.1'
implementation 'com.github.Luteoos:Android--MVVMLib:3.1.0x'
```

### Library implements simple 'bus' between VM and View able to transfer Int-based parameters, to enable it:
Expand All @@ -18,9 +18,10 @@ override fun onVMMessage(msg: Int?){
```

- after initialization viewModel invoke `connectToVMMessage()`
- `0` is default value assigned, do not use it as your custom parameter value
- `0` and `null` are values used to flush data, do not use it as your custom parameter value

### changes in 3.0.0
- removed Realm implementation
- removed rxJava implementation
- BaseFragmentMVVM now inherits from BaseFragmentMVVMwithoutVM
### changes in 3.1.0x
-migrated to AndroidX
-changed package scope to more valid
-upgraded arch.lifecycle version
-simplified unused imports
12 changes: 2 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.2.61'
ext.kotlin_version = '1.3.40'
ext.kotlin_plugin_version = "1.2.61"
ext.realm_version = "5.0.0"

repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:$realm_version"
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.26.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -45,5 +38,4 @@ ext {
rxJava = '2.1.12'
rxAndroid = '2.0.2'
rxBinding = '2.0.0'
rxBus = '1.0.2'
}
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Mon Jul 01 11:59:38 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
10 changes: 8 additions & 2 deletions mvvmBaseLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ android {
targetSdkVersion 28
versionCode 2
versionName "2.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
ext {
Expand All @@ -25,7 +27,11 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'

testImplementation 'org.mockito:mockito-core:2.9.0'
testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test:rules:1.2.0'
}

1 change: 1 addition & 0 deletions mvvmBaseLib/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class io.github.luteoos.mvvmbaselib.** {*;}
35 changes: 0 additions & 35 deletions mvvmBaseLib/src/main/java/com/luteoos/kotlin/mvvmbaselib/Test.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.luteoos.kotlin.mvvmbaselib
package io.github.luteoos.mvvmbaselib

import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProviders
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import android.content.Context
import android.content.pm.ActivityInfo
import android.net.ConnectivityManager
import android.os.Bundle
import android.support.v4.app.FragmentActivity
import android.support.v7.app.AppCompatActivity
import androidx.fragment.app.FragmentActivity
import androidx.appcompat.app.AppCompatActivity
import android.view.inputmethod.InputMethodManager

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.luteoos.kotlin.mvvmbaselib
package io.github.luteoos.mvvmbaselib

import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProviders
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.luteoos.kotlin.mvvmbaselib
package io.github.luteoos.mvvmbaselib

import android.content.Context
import android.net.ConnectivityManager
import android.os.Bundle
import android.support.v4.app.Fragment
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.luteoos.kotlin.mvvmbaselib
package io.github.luteoos.mvvmbaselib

import android.arch.lifecycle.LiveData
import android.arch.lifecycle.MutableLiveData
import android.arch.lifecycle.ViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
* Created by Luteoos on 13.09.2018
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.luteoos.mvvmbaselib

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class BaseViewModelUnitTest {

// @Before
// fun init(){
// testViewModel = o
// }
//
// @Test
// fun getVMMessage_BaseViewModdel_ReturnIntLiveData(){
// val testViewModel: BaseViewModel = object : BaseViewModel(){}
// val testLiveData = MutableLiveData<Int>() as LiveData<Int>
// assertEquals(testViewModel.VMMessage(), testLiveData)
// }
}

0 comments on commit afe3128

Please sign in to comment.