├── kratos ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── kratos │ │ │ ├── package-info.java │ │ │ ├── card │ │ │ ├── render │ │ │ │ ├── SearchMenu.kt │ │ │ │ ├── SearchStyle.kt │ │ │ │ ├── Menu.kt │ │ │ │ ├── Header.kt │ │ │ │ ├── Style.kt │ │ │ │ └── Template.kt │ │ │ ├── entity │ │ │ │ └── KData.kt │ │ │ ├── utils │ │ │ │ ├── OnCardRenderListener.kt │ │ │ │ ├── DelegateExt.kt │ │ │ │ ├── Skip.java │ │ │ │ ├── FixSwipeRefreshLayout.kt │ │ │ │ ├── NotNullCardRenderListenter.kt │ │ │ │ ├── JsonVerify.java │ │ │ │ ├── DrawableUtils.java │ │ │ │ ├── StringUtils.java │ │ │ │ ├── GsonUtilsCreator.java │ │ │ │ ├── GsonUtils.java │ │ │ │ └── ActivityUtils.java │ │ │ ├── event │ │ │ │ ├── FailEvent.java │ │ │ │ ├── ExceptionEvent.java │ │ │ │ ├── SuccessEvent.java │ │ │ │ ├── KMenuClickEvent.java │ │ │ │ └── KOnClickEvent.java │ │ │ ├── KCard.kt │ │ │ ├── KCardActivity.kt │ │ │ └── RenderExt.kt │ │ │ ├── internal │ │ │ ├── KBinder.java │ │ │ ├── KBase.kt │ │ │ ├── KStringDeserializer.java │ │ │ ├── ViewExt.kt │ │ │ ├── KFinder.java │ │ │ ├── KBoolean.kt │ │ │ ├── Binding.java │ │ │ └── KString.kt │ │ │ └── Kratos.java │ │ ├── res │ │ ├── menu │ │ │ └── empty.xml │ │ ├── layout │ │ │ ├── inc_toolbar.xml │ │ │ └── kcard_main.xml │ │ └── values │ │ │ └── style.xml │ │ └── AndroidManifest.xml ├── gradle.properties ├── proguard-rules.pro └── build.gradle ├── kratos-sample ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── me │ │ │ └── ele │ │ │ └── kratos_sample │ │ │ ├── package-info.java │ │ │ ├── entity │ │ │ ├── KText.java │ │ │ └── Customer.java │ │ │ ├── TextCard.java │ │ │ ├── CardSampleActivity.java │ │ │ └── SimpleActivity.java │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ └── colors.xml │ │ ├── raw │ │ │ └── sample.json │ │ └── layout │ │ │ ├── kcard_text.xml │ │ │ └── activity_simple.xml │ │ └── AndroidManifest.xml ├── build.gradle └── proguard-rules.pro ├── images ├── card.gif ├── demo.png ├── logo.jpg ├── example.gif ├── customer.png └── complexcard.png ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── gradle-mvn-push.gradle ├── kratos-compiler ├── gradle.properties ├── src │ └── main │ │ └── java │ │ └── kratos │ │ └── compiler │ │ ├── KBinding.java │ │ ├── binding │ │ ├── KBindingGeneric.java │ │ ├── KBooleanBinding.java │ │ └── KStringBinding.java │ │ ├── UpdateKStringBinding.java │ │ ├── FieldViewBinding.java │ │ ├── KBindings.java │ │ ├── BindingClass.java │ │ └── KratosProcessor.java └── build.gradle ├── kratos-annotation ├── gradle.properties ├── src │ └── main │ │ └── java │ │ └── kratos │ │ ├── WithBind.java │ │ ├── PackageName.java │ │ ├── Binds.java │ │ ├── LBindLayout.java │ │ ├── LBindText.java │ │ ├── OnKStringChanged.java │ │ ├── OnKBooleanChanged.java │ │ ├── BindText.java │ │ ├── BindLayout.java │ │ └── Bind.java └── build.gradle ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew ├── LICENSE └── README.md /kratos/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kratos-sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/package-info.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | -------------------------------------------------------------------------------- /images/card.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ACEMerlin/Kratos/HEAD/images/card.gif -------------------------------------------------------------------------------- /images/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ACEMerlin/Kratos/HEAD/images/demo.png -------------------------------------------------------------------------------- /images/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ACEMerlin/Kratos/HEAD/images/logo.jpg -------------------------------------------------------------------------------- /images/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ACEMerlin/Kratos/HEAD/images/example.gif -------------------------------------------------------------------------------- /images/customer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ACEMerlin/Kratos/HEAD/images/customer.png -------------------------------------------------------------------------------- /kratos/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_ARTIFACT_ID=kratos 2 | POM_NAME=Kratos 3 | POM_PACKAGING=aar 4 | -------------------------------------------------------------------------------- /images/complexcard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ACEMerlin/Kratos/HEAD/images/complexcard.png -------------------------------------------------------------------------------- /kratos/src/main/res/menu/empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /kratos/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ACEMerlin/Kratos/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /kratos-compiler/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=Kratos Compiler 2 | POM_ARTIFACT_ID=kratos-compiler 3 | POM_PACKAGING=jar 4 | -------------------------------------------------------------------------------- /kratos-annotation/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=Kratos Annotations 2 | POM_ARTIFACT_ID=kratos-annotations 3 | POM_PACKAGING=jar 4 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/render/SearchMenu.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.render 2 | 3 | class SearchMenu : Menu() { 4 | } -------------------------------------------------------------------------------- /kratos-sample/src/main/java/me/ele/kratos_sample/package-info.java: -------------------------------------------------------------------------------- 1 | @PackageName package me.ele.kratos_sample; 2 | 3 | import kratos.PackageName; -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/render/SearchStyle.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.render 2 | 3 | class SearchStyle : Style() { 4 | 5 | var expand: Boolean = false 6 | } -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':kratos' 2 | include ':kratos-annotation' 3 | include ':kratos-compiler' 4 | include ':kratos-sample' 5 | 6 | rootProject.name = 'kratos-parent' -------------------------------------------------------------------------------- /kratos-compiler/src/main/java/kratos/compiler/KBinding.java: -------------------------------------------------------------------------------- 1 | package kratos.compiler; 2 | 3 | /** 4 | * Created by merlin on 15/12/7. 5 | */ 6 | public interface KBinding { 7 | } 8 | -------------------------------------------------------------------------------- /kratos-sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Kratos-sample 3 | Jump to Card Sample Activity 4 | 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | /kratos/build 9 | /kratos-annotation/build 10 | /kratos-compiler/build 11 | /kratos-sample/build 12 | *.hprof -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/internal/KBinder.java: -------------------------------------------------------------------------------- 1 | package kratos.internal; 2 | 3 | /** 4 | * Created by merlin on 15/12/7. 5 | */ 6 | public interface KBinder { 7 | void bind(T target, KFinder finder); 8 | } 9 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/entity/KData.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.entity 2 | 3 | import kratos.card.render.Style 4 | import java.io.Serializable 5 | 6 | open class KData : Serializable { 7 | var style: Style? = null 8 | } 9 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/OnCardRenderListener.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.utils 2 | 3 | /** 4 | * Created by sanvi on 11/16/15. 5 | */ 6 | interface OnCardRenderListener { 7 | open fun onRender(json: String): String 8 | } -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/DelegateExt.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.utils 2 | 3 | import kotlin.properties.ReadWriteProperty 4 | 5 | object DelegateExt { 6 | fun notNullCardRenderListener(): 7 | ReadWriteProperty = NotNullCardRenderListener() 8 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 21 11:34:03 PDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /kratos-sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffff 4 | #0086ff 5 | #444444 6 | #888888 7 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/event/FailEvent.java: -------------------------------------------------------------------------------- 1 | package kratos.card.event; 2 | 3 | public class FailEvent { 4 | 5 | public String code; 6 | public String message; 7 | 8 | public FailEvent(String code, String message) { 9 | this.code = code; 10 | this.message = message; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/event/ExceptionEvent.java: -------------------------------------------------------------------------------- 1 | package kratos.card.event; 2 | 3 | public class ExceptionEvent { 4 | public String message; 5 | public String code; 6 | 7 | public ExceptionEvent(String code, String message) { 8 | this.code = code; 9 | this.message = message; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/event/SuccessEvent.java: -------------------------------------------------------------------------------- 1 | package kratos.card.event; 2 | 3 | public class SuccessEvent { 4 | 5 | public String code; 6 | public String message; 7 | 8 | public SuccessEvent(String code, String message) { 9 | this.code = code; 10 | this.message = message; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /kratos-sample/src/main/java/me/ele/kratos_sample/entity/KText.java: -------------------------------------------------------------------------------- 1 | package me.ele.kratos_sample.entity; 2 | 3 | import kratos.card.entity.KData; 4 | import kratos.internal.KString; 5 | 6 | /** 7 | * Created by merlin on 15/12/17. 8 | */ 9 | public class KText extends KData { 10 | public KString text1; 11 | public KString text2; 12 | } 13 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/Skip.java: -------------------------------------------------------------------------------- 1 | package kratos.card.utils; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target(ElementType.FIELD) 10 | public @interface Skip { 11 | } 12 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/render/Menu.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.render 2 | 3 | import java.io.Serializable 4 | 5 | open class Menu : Serializable { 6 | var type: String? = null 7 | var style: T? = null 8 | var id: Int = 0 9 | var hint: String? = null 10 | 11 | companion object { 12 | val SEARCH = "search" 13 | val TEXT = "text" 14 | } 15 | } -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/render/Header.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.render 2 | 3 | import java.io.Serializable 4 | 5 | class Header : Serializable { 6 | var title: String? = null 7 | var arrow: Boolean = false 8 | var icon: String? = null 9 | var background: String? = null 10 | var bodyBackgroud: String? = null 11 | var menus: MutableList> = arrayListOf() 12 | } 13 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/WithBind.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by merlin on 16/1/28. 10 | */ 11 | @Retention(RetentionPolicy.CLASS) 12 | @Target(ElementType.TYPE) 13 | public @interface WithBind { 14 | } 15 | -------------------------------------------------------------------------------- /kratos-compiler/src/main/java/kratos/compiler/binding/KBindingGeneric.java: -------------------------------------------------------------------------------- 1 | package kratos.compiler.binding; 2 | 3 | import com.squareup.javapoet.MethodSpec; 4 | 5 | /** 6 | * Created by sanvi on 1/8/16. 7 | */ 8 | public interface KBindingGeneric { 9 | public void addGenericCode(MethodSpec.Builder result, String key); 10 | 11 | public String getMethodName(); 12 | 13 | public String[] getParameterTypes(); 14 | } -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/PackageName.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by merlin on 15/12/21. 10 | */ 11 | @Retention(RetentionPolicy.CLASS) 12 | @Target(ElementType.PACKAGE) 13 | public @interface PackageName { 14 | } 15 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/Binds.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by merlin on 15/12/22. 10 | */ 11 | @Retention(RetentionPolicy.CLASS) 12 | @Target(ElementType.TYPE) 13 | public @interface Binds { 14 | Bind[] value(); 15 | } 16 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/LBindLayout.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by merlin on 15/12/21. 10 | */ 11 | @Retention(RetentionPolicy.CLASS) 12 | @Target(ElementType.TYPE) 13 | public @interface LBindLayout { 14 | String value(); 15 | } 16 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/LBindText.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by merlin on 15/12/4. 10 | */ 11 | @Retention(RetentionPolicy.CLASS) 12 | @Target(ElementType.FIELD) 13 | public @interface LBindText { 14 | String[] value(); 15 | } 16 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/OnKStringChanged.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by merlin on 15/12/24. 10 | */ 11 | @Retention(RetentionPolicy.CLASS) 12 | @Target(ElementType.METHOD) 13 | public @interface OnKStringChanged { 14 | String value(); 15 | } 16 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/OnKBooleanChanged.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by merlin on 15/12/24. 10 | */ 11 | @Retention(RetentionPolicy.CLASS) 12 | @Target(ElementType.METHOD) 13 | public @interface OnKBooleanChanged { 14 | String value(); 15 | } 16 | -------------------------------------------------------------------------------- /kratos-sample/src/main/res/raw/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "header": { 3 | "title": "Card Sample" 4 | }, 5 | "body": [ 6 | { 7 | "data": { 8 | "text1": "{Customer.name}", 9 | "text2": "this is text2" 10 | }, 11 | "type": "me.ele.kratos_sample.TextCard", 12 | "id": "textCard1", 13 | "style": { 14 | "margin_top": 20, 15 | "margin_left": 20, 16 | "margin_right": 20 17 | } 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/BindText.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import android.support.annotation.IdRes; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Created by merlin on 15/12/7. 12 | */ 13 | @Retention(RetentionPolicy.CLASS) 14 | @Target(ElementType.FIELD) 15 | public @interface BindText { 16 | @IdRes int[] value(); 17 | } 18 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/BindLayout.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import android.support.annotation.LayoutRes; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Created by merlin on 15/12/21. 12 | */ 13 | @Retention(RetentionPolicy.CLASS) 14 | @Target(ElementType.TYPE) 15 | public @interface BindLayout { 16 | @LayoutRes int value(); 17 | } 18 | -------------------------------------------------------------------------------- /kratos-annotation/src/main/java/kratos/Bind.java: -------------------------------------------------------------------------------- 1 | package kratos; 2 | 3 | import android.support.annotation.IdRes; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Created by merlin on 15/12/22. 12 | */ 13 | @Retention(RetentionPolicy.CLASS) 14 | @Target(ElementType.TYPE) 15 | public @interface Bind { 16 | String data(); 17 | 18 | @IdRes int id(); 19 | } 20 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/render/Style.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.render 2 | 3 | import java.io.Serializable 4 | 5 | open class Style : Serializable { 6 | 7 | var margin_top: Int = 0 8 | var margin_bottom: Int = 0 9 | var margin_left: Int = 0 10 | var margin_right: Int = 0 11 | var background_color: String? = null 12 | var text_color: String? = null 13 | var normal_color: String? = null 14 | var pressed_color: String? = null 15 | var href_color: String? = null 16 | var text_type: String? = null 17 | var text_length: Int ? = null 18 | } 19 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/render/Template.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.render 2 | 3 | import kratos.card.KCard 4 | import kratos.card.entity.KData 5 | import java.io.Serializable 6 | 7 | 8 | /** 9 | * Created by sanvi on 11/4/15. 10 | */ 11 | class Template : Serializable { 12 | var header: Header? = null 13 | val body: MutableList> = arrayListOf() 14 | val footer: MutableList> = arrayListOf() 15 | 16 | companion object { 17 | const val BUNDLE_TEMPLAT: String = "template" 18 | const val BUNDLE_URL: String = "url" 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/event/KMenuClickEvent.java: -------------------------------------------------------------------------------- 1 | package kratos.card.event; 2 | 3 | public class KMenuClickEvent { 4 | 5 | public String data; 6 | public int id; 7 | public String url; 8 | public int position; 9 | 10 | public KMenuClickEvent(int id, String data, String url) { 11 | this.id = id; 12 | this.data = data; 13 | this.url = url; 14 | } 15 | 16 | public KMenuClickEvent(int id, String data, String url, int position) { 17 | this.id = id; 18 | this.data = data; 19 | this.url = url; 20 | this.position = position; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/FixSwipeRefreshLayout.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.utils 2 | 3 | import android.content.Context 4 | import android.support.v4.widget.SwipeRefreshLayout 5 | import android.util.AttributeSet 6 | import android.view.View 7 | 8 | public class FixSwipeRefreshLayout : SwipeRefreshLayout { 9 | 10 | public var target: View? = null 11 | 12 | constructor(ctx: Context) : super(ctx) 13 | 14 | constructor(ctx: Context, attr: AttributeSet) : super(ctx, attr) 15 | 16 | override fun canChildScrollUp(): Boolean { 17 | return target?.canScrollVertically(-1) ?: super.canChildScrollUp() 18 | } 19 | } -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/internal/KBase.kt: -------------------------------------------------------------------------------- 1 | package io.nothing.kratos.core.generic 2 | 3 | import android.view.View 4 | import java.io.Serializable 5 | import java.util.* 6 | 7 | /** 8 | * Created by sanvi on 1/8/16. 9 | */ 10 | abstract class KBase() : Serializable { 11 | protected var views = LinkedHashMap() 12 | 13 | inline fun getView(str: String): T { 14 | return views.get(str)!! as T 15 | } 16 | 17 | abstract fun get(): Any 18 | 19 | 20 | /** 21 | * 通过resource name获取ID 22 | */ 23 | fun getId(str: String): String { 24 | return str.split("/")[1] 25 | } 26 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-XX:MaxPermSize=1024m 2 | 3 | GROUP=com.github.acemerlin 4 | VERSION_NAME=0.2.4 5 | 6 | POM_DESCRIPTION=Add basic double binding support to android. 7 | 8 | POM_URL=https://github.com/ACEMerlin/Kratos 9 | POM_SCM_URL=https://github.com/ACEMerlin/Kratos 10 | POM_SCM_CONNECTION=scm:git:git://github.com/ACEMerlin/Kratos.git 11 | POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/ACEMerlin/Kratos.git 12 | 13 | POM_LICENCE_NAME=GNU GENERAL PUBLIC LICENSE, Version 3.0 14 | POM_LICENCE_URL=http://www.gnu.org/licenses/gpl-3.0.en.html 15 | POM_LICENCE_DIST=repo 16 | 17 | POM_DEVELOPER_ID=merlin 18 | POM_DEVELOPER_NAME=Ge Chen 19 | -------------------------------------------------------------------------------- /kratos-compiler/src/main/java/kratos/compiler/UpdateKStringBinding.java: -------------------------------------------------------------------------------- 1 | package kratos.compiler; 2 | 3 | /** 4 | * Created by merlin on 15/12/24. 5 | */ 6 | public class UpdateKStringBinding { 7 | 8 | private String methodName; 9 | private String[] parameterTypes; 10 | 11 | public UpdateKStringBinding(String methodName, String[] parameterTypes) { 12 | this.methodName = methodName; 13 | this.parameterTypes = parameterTypes; 14 | } 15 | 16 | public String getMethodName() { 17 | return methodName; 18 | } 19 | 20 | public String[] getParameterTypes() { 21 | return parameterTypes; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /kratos-annotation/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | sourceCompatibility = rootProject.ext.sourceCompatibilityVersion 4 | targetCompatibility = rootProject.ext.targetCompatibilityVersion 5 | 6 | def logger = new com.android.build.gradle.internal.LoggerWrapper(project.logger) 7 | def sdkHandler = new com.android.build.gradle.internal.SdkHandler(project, logger) 8 | for (File file : sdkHandler.sdkLoader.repositories) { 9 | repositories.maven { 10 | url = file.toURI() 11 | } 12 | } 13 | 14 | dependencies { 15 | compile 'com.android.support:support-annotations:23.1.1' 16 | } 17 | 18 | apply from: rootProject.file('gradle/gradle-mvn-push.gradle') -------------------------------------------------------------------------------- /kratos-sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'com.neenbedankt.android-apt' 3 | 4 | android { 5 | compileSdkVersion rootProject.ext.compileSdkVersion 6 | buildToolsVersion rootProject.ext.buildToolsVersion 7 | 8 | defaultConfig { 9 | applicationId 'me.ele.kratos' 10 | minSdkVersion rootProject.ext.minSdkVersion 11 | targetSdkVersion rootProject.ext.targetSdkVersion 12 | versionCode 1 13 | versionName "1.0" 14 | } 15 | } 16 | 17 | dependencies { 18 | compile project(':kratos') 19 | apt project(':kratos-compiler') 20 | compile 'com.android.support:appcompat-v7:23.1.1' 21 | } 22 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/event/KOnClickEvent.java: -------------------------------------------------------------------------------- 1 | package kratos.card.event; 2 | 3 | 4 | import kratos.card.entity.KData; 5 | 6 | public class KOnClickEvent { 7 | 8 | public T data; 9 | public String id; 10 | public String url; 11 | public int position; 12 | 13 | public KOnClickEvent(String id, T data, String url) { 14 | this.id = id; 15 | this.data = data; 16 | this.url = url; 17 | } 18 | 19 | public KOnClickEvent(String id, T data, String url, int position) { 20 | this.id = id; 21 | this.data = data; 22 | this.url = url; 23 | this.position = position; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /kratos/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/merlin/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kratos-compiler/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | sourceCompatibility = rootProject.ext.sourceCompatibilityVersion 4 | targetCompatibility = rootProject.ext.targetCompatibilityVersion 5 | 6 | def logger = new com.android.build.gradle.internal.LoggerWrapper(project.logger) 7 | def sdkHandler = new com.android.build.gradle.internal.SdkHandler(project, logger) 8 | for (File file : sdkHandler.sdkLoader.repositories) { 9 | repositories.maven { 10 | url = file.toURI() 11 | } 12 | } 13 | 14 | dependencies { 15 | compile project (':kratos-annotation') 16 | compile 'com.google.auto.service:auto-service:1.0-rc2' 17 | compile 'com.squareup:javapoet:1.4.0' 18 | } 19 | 20 | apply from: rootProject.file('gradle/gradle-mvn-push.gradle') -------------------------------------------------------------------------------- /kratos-sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/merlin/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/NotNullCardRenderListenter.kt: -------------------------------------------------------------------------------- 1 | package kratos.card.utils 2 | 3 | import kotlin.properties.ReadWriteProperty 4 | import kotlin.reflect.KProperty 5 | 6 | /** 7 | * Created by sanvi on 11/16/15. 8 | */ 9 | internal class NotNullCardRenderListener() : ReadWriteProperty { 10 | private var value: T? = null 11 | override fun getValue(thisRef: Any?, property: KProperty<*>): T { 12 | return value ?: object : OnCardRenderListener { 13 | override fun onRender(json: String): String { 14 | return json 15 | } 16 | } as T 17 | } 18 | 19 | override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) { 20 | this.value = value 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/internal/KStringDeserializer.java: -------------------------------------------------------------------------------- 1 | package kratos.internal; 2 | 3 | import com.google.gson.JsonDeserializationContext; 4 | import com.google.gson.JsonDeserializer; 5 | import com.google.gson.JsonElement; 6 | import com.google.gson.JsonParseException; 7 | 8 | import java.lang.reflect.Type; 9 | 10 | /** 11 | * Created by sanvi on 12/22/15. 12 | */ 13 | public class KStringDeserializer implements JsonDeserializer { 14 | 15 | private Class mTargetClass; 16 | 17 | @Override 18 | public KString deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { 19 | KString field = new KString(); 20 | field.setInitData(json.getAsString()); 21 | return field; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/JsonVerify.java: -------------------------------------------------------------------------------- 1 | package kratos.card.utils; 2 | 3 | import com.google.gson.JsonParseException; 4 | import com.google.gson.JsonParser; 5 | 6 | /** 7 | * To verify whether a json is legal 8 | * Created by Wayne on 15/12/25. 9 | */ 10 | public class JsonVerify { 11 | 12 | public static boolean isIllegalJson(String json) { 13 | return !isLegalJson(json); 14 | } 15 | 16 | public static boolean isLegalJson(String json) { 17 | if ((json).isEmpty()) { 18 | return false; 19 | } 20 | try { 21 | new JsonParser().parse(json); 22 | return true; 23 | } catch (JsonParseException e) { 24 | e.printStackTrace(); 25 | return false; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/internal/ViewExt.kt: -------------------------------------------------------------------------------- 1 | package kratos.internal 2 | 3 | import android.view.View 4 | import android.widget.EditText 5 | import android.widget.TextView 6 | 7 | /** 8 | * Created by sanvi on 1/8/16. 9 | */ 10 | public fun TextView.updateText(new: String) { 11 | this.text = new 12 | } 13 | 14 | public fun EditText.updateText(new: String) { 15 | val position = this.selectionStart 16 | this.setText(new) 17 | this.setSelection(position) 18 | } 19 | 20 | public fun View.updateText(new: String): Unit = when (this) { 21 | is EditText -> this.updateText(new) 22 | is TextView -> this.updateText(new) 23 | else -> throw NoSuchMethodException("no update method on $this") 24 | } 25 | 26 | public fun View.updateVisibility(new: Boolean) { 27 | if (new) { 28 | this.visibility = View.VISIBLE 29 | } else { 30 | this.visibility = View.GONE 31 | } 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /kratos/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | 4 | android { 5 | compileSdkVersion rootProject.ext.compileSdkVersion 6 | buildToolsVersion rootProject.ext.buildToolsVersion 7 | 8 | defaultConfig { 9 | minSdkVersion rootProject.ext.minSdkVersion 10 | } 11 | } 12 | 13 | dependencies { 14 | compile project(':kratos-annotation') 15 | compile 'com.android.support:appcompat-v7:23.1.1' 16 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 17 | compile 'de.greenrobot:eventbus:2.4.0' 18 | compile 'com.google.code.gson:gson:2.5' 19 | } 20 | buildscript { 21 | ext.kotlin_version = '1.0.0' 22 | repositories { 23 | mavenCentral() 24 | } 25 | dependencies { 26 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 27 | } 28 | } 29 | 30 | 31 | apply from: rootProject.file('gradle/gradle-mvn-push.gradle') -------------------------------------------------------------------------------- /kratos-sample/src/main/res/layout/kcard_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 25 | -------------------------------------------------------------------------------- /kratos-compiler/src/main/java/kratos/compiler/FieldViewBinding.java: -------------------------------------------------------------------------------- 1 | package kratos.compiler; 2 | 3 | import com.squareup.javapoet.TypeName; 4 | 5 | import static kratos.compiler.KratosProcessor.VIEW_TYPE; 6 | 7 | /** 8 | * Created by merlin on 15/12/7. 9 | */ 10 | public final class FieldViewBinding implements KBinding { 11 | private final String name; 12 | private final TypeName type; 13 | private final boolean required; 14 | 15 | FieldViewBinding(String name, TypeName type, boolean required) { 16 | this.name = name; 17 | this.type = type; 18 | this.required = required; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public TypeName getType() { 26 | return type; 27 | } 28 | 29 | public boolean isRequired() { 30 | return required; 31 | } 32 | 33 | public boolean requiresCast() { 34 | return !VIEW_TYPE.equals(type.toString()); 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /kratos-sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /kratos/src/main/res/layout/inc_toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 19 | 20 | 25 | 26 | -------------------------------------------------------------------------------- /kratos-sample/src/main/java/me/ele/kratos_sample/TextCard.java: -------------------------------------------------------------------------------- 1 | package me.ele.kratos_sample; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | import android.widget.TextView; 6 | 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | import kratos.Bind; 10 | import kratos.BindLayout; 11 | import kratos.Binds; 12 | import kratos.OnKStringChanged; 13 | import kratos.card.KCard; 14 | import me.ele.kratos_sample.entity.KText; 15 | 16 | /** 17 | * Created by merlin on 15/12/17. 18 | */ 19 | @BindLayout(R.layout.kcard_text) //@LBindLayout("kcard_text") 20 | @Binds({@Bind(id = R.id.kcard_text_text1, data = "text1"), 21 | @Bind(id = R.id.kcard_text_text2, data = "text2")}) 22 | public class TextCard extends KCard { 23 | public TextCard(Context context) { 24 | super(context); 25 | } 26 | 27 | @Override 28 | public void init() { 29 | setOnLinkListener(); 30 | } 31 | 32 | @OnKStringChanged("text1") 33 | public void updateText1(@NotNull TextView v, @NotNull String s) { 34 | v.setText(s); 35 | Log.d("TextCard", "custom updater!"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /kratos-sample/src/main/java/me/ele/kratos_sample/entity/Customer.java: -------------------------------------------------------------------------------- 1 | package me.ele.kratos_sample.entity; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | import kratos.internal.KString; 7 | 8 | /** 9 | * Created by merlin on 16/2/18. 10 | */ 11 | public class Customer implements Parcelable { 12 | 13 | public KString name = new KString(); 14 | 15 | @Override 16 | public int describeContents() { 17 | return 0; 18 | } 19 | 20 | @Override 21 | public void writeToParcel(Parcel dest, int flags) { 22 | dest.writeParcelable(this.name, flags); 23 | } 24 | 25 | public Customer() { 26 | } 27 | 28 | protected Customer(Parcel in) { 29 | this.name = in.readParcelable(KString.class.getClassLoader()); 30 | } 31 | 32 | public static final Creator CREATOR = new Creator() { 33 | public Customer createFromParcel(Parcel source) { 34 | return new Customer(source); 35 | } 36 | 37 | public Customer[] newArray(int size) { 38 | return new Customer[size]; 39 | } 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /kratos-sample/src/main/java/me/ele/kratos_sample/CardSampleActivity.java: -------------------------------------------------------------------------------- 1 | package me.ele.kratos_sample; 2 | 3 | import android.widget.Toast; 4 | 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import kratos.card.KCardActivity; 8 | import kratos.card.entity.KData; 9 | import kratos.card.event.KOnClickEvent; 10 | import me.ele.kratos_sample.entity.Customer; 11 | 12 | /** 13 | * Created by merlin on 15/12/14. 14 | */ 15 | public class CardSampleActivity extends KCardActivity { 16 | 17 | Customer customer = new Customer(); 18 | 19 | private void showToast(String text) { 20 | Toast.makeText(CardSampleActivity.this, text, Toast.LENGTH_SHORT).show(); 21 | } 22 | 23 | @Override 24 | public void onEventMainThread(@NotNull KOnClickEvent event) { 25 | super.onEventMainThread(event); 26 | switch (event.id) { 27 | case "textCard1": 28 | showToast("Handle click on textCard1!"); 29 | break; 30 | } 31 | } 32 | 33 | @Override 34 | public void onFinishRender() { 35 | bind(this, customer); 36 | customer.name.set("Merlin"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/DrawableUtils.java: -------------------------------------------------------------------------------- 1 | package kratos.card.utils; 2 | 3 | import android.content.Context; 4 | import android.graphics.Color; 5 | import android.graphics.PorterDuff; 6 | import android.graphics.drawable.Drawable; 7 | import android.support.v4.content.ContextCompat; 8 | 9 | public class DrawableUtils { 10 | 11 | public static Drawable changeWhiteDrawable(Context context, Drawable drawable) { 12 | return changeDrawableColor(drawable, Color.parseColor("#FFFFFF")); 13 | } 14 | 15 | public static Drawable changeDrawableColor(Drawable drawable, int color) { 16 | drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); 17 | return drawable; 18 | } 19 | 20 | 21 | public static Drawable getMipmap(Context context, String name) { 22 | int resourceId = context.getResources().getIdentifier(name, "mipmap", context.getPackageName()); 23 | return ContextCompat.getDrawable(context, resourceId); 24 | } 25 | 26 | public static int getMipmapId(Context context, String name) { 27 | return context.getResources().getIdentifier(name, "mipmap", context.getPackageName()); 28 | } 29 | 30 | 31 | } -------------------------------------------------------------------------------- /kratos-sample/src/main/java/me/ele/kratos_sample/SimpleActivity.java: -------------------------------------------------------------------------------- 1 | package me.ele.kratos_sample; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | 7 | import kratos.BindText; 8 | import kratos.Kratos; 9 | import kratos.card.utils.ActivityUtils; 10 | import kratos.internal.KString; 11 | 12 | /** 13 | * Created by merlin on 15/12/10. 14 | */ 15 | public class SimpleActivity extends Activity { 16 | 17 | private final int CODE_CARD_SAMPLE = 123; 18 | 19 | @BindText({R.id.test_doublebinding_input, R.id.test_doublebinding_presenter}) 20 | KString boundData1 = new KString(); 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | setContentView(R.layout.activity_simple); 26 | Kratos.bind(this); 27 | findViewById(R.id.card_sample).setOnClickListener(new View.OnClickListener() { 28 | @Override 29 | public void onClick(View v) { 30 | ActivityUtils.jump(SimpleActivity.this, CardSampleActivity.class, CODE_CARD_SAMPLE, R.raw.sample); 31 | } 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /kratos-compiler/src/main/java/kratos/compiler/KBindings.java: -------------------------------------------------------------------------------- 1 | package kratos.compiler; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.LinkedHashSet; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | /** 10 | * Created by merlin on 15/12/7. 11 | */ 12 | public class KBindings { 13 | private final Set fieldBindings = new LinkedHashSet<>(); 14 | private final String id; 15 | 16 | KBindings(String id) { 17 | this.id = id; 18 | } 19 | 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | public void addFieldBinding(FieldViewBinding fieldBinding) { 25 | fieldBindings.add(fieldBinding); 26 | } 27 | 28 | public Collection getFieldBindings() { 29 | return fieldBindings; 30 | } 31 | 32 | public List getRequiredBindings() { 33 | List requiredViewBindings = new ArrayList<>(); 34 | for (FieldViewBinding fieldBinding : fieldBindings) { 35 | if (fieldBinding.isRequired()) { 36 | requiredViewBindings.add(fieldBinding); 37 | } 38 | } 39 | return requiredViewBindings; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /kratos/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 16 | 17 | 21 | 22 | 28 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | package kratos.card.utils; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | 8 | /** 9 | * Created by merlin on 15/12/14. 10 | */ 11 | public class StringUtils { 12 | 13 | public static String convertStreamToString(InputStream is) { 14 | /* 15 | * To convert the InputStream to String we use the 16 | * BufferedReader.readLine() method. We iterate until the BufferedReader 17 | * return null which means there's no more data to read. Each line will 18 | * appended to a StringBuilder and returned as String. 19 | */ 20 | BufferedReader reader = new BufferedReader(new InputStreamReader(is)); 21 | StringBuilder sb = new StringBuilder(); 22 | 23 | String line = null; 24 | try { 25 | while ((line = reader.readLine()) != null) { 26 | sb.append(line + "\n"); 27 | } 28 | } catch (IOException e) { 29 | e.printStackTrace(); 30 | } finally { 31 | try { 32 | is.close(); 33 | } catch (IOException e) { 34 | e.printStackTrace(); 35 | } 36 | } 37 | 38 | return sb.toString(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /kratos/src/main/java/kratos/card/utils/GsonUtilsCreator.java: -------------------------------------------------------------------------------- 1 | package kratos.card.utils; 2 | 3 | import android.content.Context; 4 | 5 | import com.google.gson.InstanceCreator; 6 | 7 | import java.lang.reflect.InvocationTargetException; 8 | import java.lang.reflect.Type; 9 | 10 | import kratos.card.KCard; 11 | 12 | 13 | /** 14 | * Created by sanvi on 11/26/15. 15 | */ 16 | public class GsonUtilsCreator implements InstanceCreator { 17 | private Context context; 18 | 19 | public GsonUtilsCreator(Context context) { 20 | this.context = context; 21 | } 22 | 23 | @Override 24 | public KCard createInstance(Type type) { 25 | KCard np = null; 26 | try { 27 | np = (KCard) Class.forName(type.toString().replace("class ", "")).getConstructor(Context.class).newInstance(context); 28 | } catch (InstantiationException e) { 29 | e.printStackTrace(); 30 | } catch (IllegalAccessException e) { 31 | e.printStackTrace(); 32 | } catch (InvocationTargetException e) { 33 | e.printStackTrace(); 34 | } catch (NoSuchMethodException e) { 35 | e.printStackTrace(); 36 | } catch (ClassNotFoundException e) { 37 | e.printStackTrace(); 38 | } 39 | // KCard np = new KCard(context); 40 | return np; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /kratos/src/main/res/layout/kcard_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | 17 | 18 | 22 | 23 | 28 | 29 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /kratos-sample/src/main/res/layout/activity_simple.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 28 | 29 |