Skip to content
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.
6 changes: 6 additions & 0 deletions .idea/encodings.xml

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

29 changes: 29 additions & 0 deletions annotation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/build
# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries

# Freeline
freeline.py
freeline/
freeline_project_description.json
.idea/misc.xml
.idea/runConfigurations.xml
.idea/vcs.xml
.idea/modules.xml
10 changes: 10 additions & 0 deletions annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apply plugin: 'java-library'
apply plugin: 'kotlin'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

sourceCompatibility = "7"
targetCompatibility = "7"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.umairjavid.kombind.anontation

@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FIELD)
annotation class SimpleKombindAdapter(val layoutRes: Int = 0)
6 changes: 6 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
kapt {
generateStubs = true
}
dataBinding {
enabled = true
}
Expand All @@ -44,6 +47,9 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':kombind')
compileOnly project(':annotation')
kapt project(':processor')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "androidx.legacy:legacy-support-v4:$androidx_legacy_support_library_version"
implementation "androidx.appcompat:appcompat:$androidx_appcompat"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import com.umairjavid.kombind.ui.KombindActivity
import com.umairjavid.kombindsample.R
import com.umairjavid.kombindsample.model.SimpleHeader
import com.umairjavid.kombindsample.repo.SimpleItemRepository
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_main.simple_item_list
import main.KombindAdapter_MainState_Items

class MainActivity : KombindActivity<MainViewModel>() {
override val viewModelClass = MainViewModel::class.java
Expand All @@ -21,8 +23,12 @@ class MainActivity : KombindActivity<MainViewModel>() {
private fun setupSimpleItemList() {
simple_item_list.apply {
layoutManager = LinearLayoutManager(this@MainActivity)
adapter = SimpleItemAdapter(viewModel.state.items, viewModel)
.registerObserver(this@MainActivity)
adapter = object :KombindAdapter_MainState_Items(viewModel.state.items, viewModel) {
override fun getLayout(position: Int) = when(items[position]) {
is SimpleHeader -> R.layout.item_simpleheader
else -> R.layout.item_simpleitem
}
} .registerObserver(this@MainActivity)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.umairjavid.kombindsample.ui.main

import com.umairjavid.kombind.anontation.SimpleKombindAdapter
import com.umairjavid.kombind.model.MutableLiveArrayList
import com.umairjavid.kombind.model.MutableLiveField

class MainState {
val title = MutableLiveField("Items Loaded!")
@SimpleKombindAdapter
val items = MutableLiveArrayList<Any>()

operator fun invoke(func: MainState.() -> Unit) = func()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import com.umairjavid.kombindsample.repo.SimpleItemRepository
class MainViewModel(application: Application, private val simpleItemRepository: SimpleItemRepository) : KombindViewModel(application),
SimpleItemAdapter.HeaderActionHandler,
SimpleItemAdapter.ItemActionHandler {
val state = MainState()
Comment thread
RobertKeazor marked this conversation as resolved.

val state = MainState()
init {
loadItems()
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.android_plugin_version = '3.2.1'
ext.kotlin_version = '1.3.0'
ext.android_plugin_version = '3.4.0'
ext.kotlin_version = '1.3.30'
repositories {
google()
jcenter()
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Nov 10 09:57:43 EST 2018
#Thu Apr 18 00:03:04 EDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6 changes: 2 additions & 4 deletions kombind/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ group = 'com.github.ujavid'

project.ext {
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
minSdkVersion = 14
targetSdkVersion = 28
versionCode = 1
versionName = '1.0'

support_library_version = '27.1.1'
androidx_appcompat = '1.0.2'
android_material = '1.1.0-alpha01'
android_material = '1.1.0-alpha05'
lifecycle_version = '2.0.0'
junit_version = '4.12'
test_runner_version = '1.1.0'
Expand All @@ -25,7 +24,6 @@ project.ext {

android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion
defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
Expand Down Expand Up @@ -54,7 +52,7 @@ dependencies {

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier 'sources'
archiveClassifier.set("sources")
}

artifacts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open class DialogFragmentBuilder<out T: DialogFragment>(private val clazz: Class
val fragment = clazz.newInstance()
fragment.arguments = arguments
return fragment
} catch (e: java.lang.InstantiationException) {
} catch (e: InstantiationException) {
throw RuntimeException(e)
} catch (e: IllegalAccessException) {
throw RuntimeException(e)
Expand All @@ -27,7 +27,7 @@ open class DialogFragmentBuilder<out T: DialogFragment>(private val clazz: Class
val fragment = fragmentManager.findFragmentByTag(fragmentTag)

return if (fragment != null) {
clazz.cast(fragment)
clazz.cast(fragment)!!
} else {
forceShow(fragmentManager)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.umairjavid.kombind.ui

import android.app.Dialog
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import android.os.Bundle
import androidx.fragment.app.DialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.databinding.library.baseAdapters.BR
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import com.umairjavid.kombind.ext.registerViewActionObserver

abstract class KombindDialogFragment<VM: KombindViewModel> : DialogFragment() {
Expand All @@ -28,7 +28,7 @@ abstract class KombindDialogFragment<VM: KombindViewModel> : DialogFragment() {
viewModel.activityViewModel = (activity as KombindActivity<*>).viewModel
viewBinding = DataBindingUtil.inflate(inflater, layoutResId, container, false)
viewBinding.setVariable(BR.viewModel, viewModel)
viewBinding.setLifecycleOwner(this)
viewBinding.lifecycleOwner = this
registerViewActionObserver(viewModel.viewAction)
return viewBinding.root
}
Expand All @@ -43,7 +43,7 @@ abstract class KombindDialogFragment<VM: KombindViewModel> : DialogFragment() {
super.onViewStateRestored(savedInstanceState)

val width = resources.displayMetrics.widthPixels
dialog.window?.setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT)
dialog!!.window?.setLayout(width, ViewGroup.LayoutParams.WRAP_CONTENT)
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
Expand Down
29 changes: 29 additions & 0 deletions processor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/build
# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries

# Freeline
freeline.py
freeline/
freeline_project_description.json
.idea/misc.xml
.idea/runConfigurations.xml
.idea/vcs.xml
.idea/modules.xml
34 changes: 34 additions & 0 deletions processor/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apply plugin: 'java-library'
apply plugin: 'kotlin'
apply plugin: 'kotlin-kapt'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
kapt 'com.google.auto.service:auto-service:1.0-rc2'
implementation 'com.google.auto.service:auto-service:1.0-rc2'
implementation project(':annotation')
implementation 'com.squareup:kotlinpoet:1.2.0'
}

sourceCompatibility = "7"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not 8 as @gregriggins36 mentioned?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I thought about it, I don't know if its useful for the sourceCompatibility to be the same as the JVM Target.. Wouldn't it be safer for it to be compatible with a lesser version?

targetCompatibility = "7"
buildscript {
repositories {
mavenCentral()
}

}
repositories {
mavenCentral()
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
Loading