├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── note_item.xml │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── pentabin │ │ │ └── livingroom │ │ │ ├── Note.java │ │ │ ├── NotesAdapter.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── pentabin │ │ │ └── livingroom │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── pentabin │ │ └── livingroom │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── livingroom ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── pentabin │ │ │ └── livingroom │ │ │ ├── BasicRepository.java │ │ │ ├── DateConverter.java │ │ │ ├── BasicEntity.java │ │ │ └── LivingRoomDatabase.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── pentabin │ │ │ └── livingroom │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── pentabin │ │ └── livingroom │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── LivingRoom-compiler ├── .gitignore ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── javax.annotation.processing.Processor │ │ └── java │ │ └── com │ │ └── pentabin │ │ └── livingroom │ │ └── compiler │ │ ├── LivingRoomDatabase.java │ │ ├── AsyncMethod.java │ │ ├── SelectMethod.java │ │ ├── EntityClass.java │ │ ├── LivingroomMethod.java │ │ └── LivingRoomProcessor.java └── build.gradle ├── LivingRoom-annotations ├── .gitignore ├── src │ └── main │ │ └── java │ │ └── com │ │ └── pentabin │ │ └── livingroom │ │ └── annotations │ │ ├── SelectableAll.java │ │ ├── SelectableById.java │ │ ├── SelectableWheres.java │ │ ├── Archivable.java │ │ ├── Deletable.java │ │ ├── Updatable.java │ │ ├── Insertable.java │ │ ├── SelectableWhere.java │ │ └── Crudable.java └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /livingroom/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /livingroom/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LivingRoom-compiler/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /LivingRoom-annotations/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /LivingRoom-compiler/src/main/resources/META-INF/services/javax.annotation.processing.Processor: -------------------------------------------------------------------------------- 1 | com.pentabin.livingroom.compiler.LivingRoomProcessor -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /livingroom/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/msbelaid/LivingRoom/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='LivingRoom' 2 | include ':app' 3 | include ':livingroom' 4 | include ':LivingRoom-annotations' 5 | include ':LivingRoom-compiler' 6 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/SelectableAll.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 2 | 3 | public @interface SelectableAll { 4 | } 5 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/SelectableById.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 2 | 3 | public @interface SelectableById { 4 | } 5 | -------------------------------------------------------------------------------- /LivingRoom-compiler/src/main/java/com/pentabin/livingroom/compiler/LivingRoomDatabase.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.compiler; 2 | 3 | // TODO LivingRoomDatabase class 4 | class LivingRoomDatabase { 5 | } 6 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/SelectableWheres.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 2 | 3 | public @interface SelectableWheres{ 4 | SelectableWhere[] value(); 5 | } 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | LivingRoom 3 | Title 4 | Add 5 | Content 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | 7 | -------------------------------------------------------------------------------- /LivingRoom-annotations/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.msbelaid' 5 | 6 | dependencies { 7 | implementation fileTree(dir: 'libs', include: ['*.jar']) 8 | 9 | } 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 15 17:29:13 CET 2020 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-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/Archivable.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 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.SOURCE) 9 | @Target(ElementType.TYPE) 10 | public @interface Archivable { 11 | } 12 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/Deletable.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 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.SOURCE) 9 | @Target(ElementType.TYPE) 10 | public @interface Deletable { 11 | } 12 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/Updatable.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 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.SOURCE) 9 | @Target(ElementType.TYPE) 10 | public @interface Updatable { 11 | } 12 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/Insertable.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 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.SOURCE) 9 | @Target(ElementType.TYPE) 10 | public @interface Insertable { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/pentabin/livingroom/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /livingroom/src/main/java/com/pentabin/livingroom/BasicRepository.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import android.app.Application; 4 | 5 | import androidx.lifecycle.LiveData; 6 | 7 | import java.util.List; 8 | 9 | public interface BasicRepository { 10 | LiveData> getAll(); 11 | Long insert(T t); 12 | void delete(T t); 13 | //void archive(T t); 14 | void update(T t); 15 | BasicRepository getInstance(Application app); 16 | //LiveData getById(long id); 17 | } 18 | -------------------------------------------------------------------------------- /livingroom/src/test/java/com/pentabin/livingroom/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /livingroom/src/main/java/com/pentabin/livingroom/DateConverter.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import androidx.room.TypeConverter; 4 | 5 | import java.util.Date; 6 | 7 | public class DateConverter { 8 | @TypeConverter 9 | public static Date toDate(Long timestamp) { 10 | return timestamp == null ? null : new Date(timestamp); 11 | } 12 | 13 | @TypeConverter 14 | public static Long toTimestamp(Date date) { 15 | return date == null ? null : date.getTime(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LivingRoom-compiler/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java-library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.msbelaid' 5 | 6 | dependencies { 7 | implementation fileTree(dir: 'libs', include: ['*.jar']) 8 | implementation 'com.squareup:javapoet:1.12.1' 9 | implementation 'androidx.room:room-runtime:2.2.5' 10 | annotationProcessor 'androidx.room:room-compiler:2.2.5' 11 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' 12 | implementation 'androidx.lifecycle:lifecycle-livedata:2.2.0' 13 | implementation project(path: ':LivingRoom-annotations') 14 | } 15 | 16 | -------------------------------------------------------------------------------- /LivingRoom-annotations/src/main/java/com/pentabin/livingroom/annotations/SelectableWhere.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom.annotations; 2 | 3 | 4 | import java.lang.annotation.Repeatable; 5 | 6 | @Repeatable(SelectableWheres.class) 7 | public @interface SelectableWhere { 8 | /** 9 | * 10 | * @return method name that will be generated in Dao, Repository and ViewModel 11 | */ 12 | String methodName(); 13 | /** 14 | * 15 | * @return where clause 16 | */ 17 | String[] params() default {""}; 18 | 19 | String where(); 20 | // TODO returns? List or One Live or not 21 | boolean liveData = true; 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /livingroom/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/pentabin/livingroom/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("com.pentabin.livingroom", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /livingroom/src/androidTest/java/com/pentabin/livingroom/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | 25 | assertEquals("com.pentabin.livingroom.test", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /livingroom/src/main/java/com/pentabin/livingroom/BasicEntity.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import androidx.room.PrimaryKey; 4 | 5 | import java.util.Date; 6 | 7 | public abstract class BasicEntity { 8 | @PrimaryKey(autoGenerate = true) 9 | private long id; 10 | private Date created_at; 11 | private Date updated_at; 12 | private boolean isDeleted; 13 | 14 | public long getId() { 15 | return id; 16 | } 17 | 18 | public void setId(long id) { 19 | this.id = id; 20 | } 21 | 22 | public Date getCreated_at() { 23 | return created_at; 24 | } 25 | 26 | public void setCreated_at(Date created_at) { 27 | this.created_at = created_at; 28 | } 29 | 30 | public Date getUpdated_at() { 31 | return updated_at; 32 | } 33 | 34 | public void setUpdated_at(Date updated_at) { 35 | this.updated_at = updated_at; 36 | } 37 | 38 | public boolean isDeleted() { 39 | return isDeleted; 40 | } 41 | 42 | public void setDeleted(boolean deleted) { 43 | isDeleted = deleted; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/pentabin/livingroom/Note.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import androidx.room.Entity; 4 | 5 | import com.pentabin.livingroom.annotations.Crudable; 6 | import com.pentabin.livingroom.annotations.SelectableWhere; 7 | 8 | @Crudable 9 | @SelectableWhere(methodName = "getArchived", where = "isDeleted = 1") 10 | @SelectableWhere(methodName = "getDateRange", 11 | where = "created_at > :from AND created_at < :to", 12 | params = {"java.util.Date from", "java.util.Date to"}) 13 | @Entity 14 | public class Note extends BasicEntity { 15 | private String title; 16 | private String content; 17 | 18 | public Note(String title, String content) { 19 | this.title = title; 20 | this.content = content; 21 | } 22 | 23 | public String getTitle() { 24 | return title; 25 | } 26 | 27 | public void setTitle(String title) { 28 | this.title = title; 29 | } 30 | 31 | public String getContent() { 32 | return content; 33 | } 34 | 35 | public void setContent(String content) { 36 | this.content = content; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | 21 | -------------------------------------------------------------------------------- /livingroom/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.msbelaid' 5 | 6 | android { 7 | compileSdkVersion 29 8 | buildToolsVersion "29.0.3" 9 | 10 | defaultConfig { 11 | minSdkVersion 23 12 | targetSdkVersion 29 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | consumerProguardFiles 'consumer-rules.pro' 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | 27 | } 28 | 29 | dependencies { 30 | implementation fileTree(dir: 'libs', include: ['*.jar']) 31 | implementation 'androidx.room:room-runtime:2.2.5' 32 | 33 | implementation 'androidx.appcompat:appcompat:1.1.0' 34 | testImplementation 'junit:junit:4.12' 35 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 36 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 37 | annotationProcessor project(path: ':LivingRoom-compiler') 38 | implementation project(path: ':LivingRoom-annotations') 39 | } 40 | -------------------------------------------------------------------------------- /livingroom/src/main/java/com/pentabin/livingroom/LivingRoomDatabase.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import java.lang.reflect.InvocationTargetException; 7 | import java.lang.reflect.Method; 8 | 9 | class LivingRoomDatabase { 10 | private static final String REPO_SUFFIX = "Repository"; 11 | private static final String TAG = "LivingRoomDatabase"; 12 | public static BasicRepository getRepository(Class entity, Application app) { 13 | /* ClassLoader classLoader = LivingRoomDatabase.class.getClassLoader(); 14 | String className = entity.getName() + REPO_SUFFIX; 15 | Log.e(TAG, "Class Name -->" + className); 16 | Method method = null; 17 | try { 18 | method = classLoader.loadClass(className).getMethod("getInstance"); 19 | } catch (NoSuchMethodException e) { 20 | e.printStackTrace(); 21 | } catch (ClassNotFoundException e) { 22 | e.printStackTrace(); 23 | } 24 | try { 25 | Object object = method.invoke(app); 26 | return (BasicRepository) object; 27 | } catch (IllegalAccessException e) { 28 | e.printStackTrace(); 29 | } catch (InvocationTargetException e) { 30 | e.printStackTrace(); 31 | } 32 | */ 33 | return null; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/note_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 17 | 26 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/pentabin/livingroom/NotesAdapter.java: -------------------------------------------------------------------------------- 1 | package com.pentabin.livingroom; 2 | 3 | import android.view.LayoutInflater; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.TextView; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.recyclerview.widget.RecyclerView; 10 | 11 | import java.util.List; 12 | 13 | public class NotesAdapter extends RecyclerView.Adapter { 14 | private List noteList; 15 | 16 | @NonNull 17 | @Override 18 | public NotesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 19 | View v = LayoutInflater.from(parent.getContext()) 20 | .inflate(R.layout.note_item, parent, false); 21 | return new NotesViewHolder(v); 22 | } 23 | 24 | @Override 25 | public void onBindViewHolder(@NonNull NotesViewHolder holder, int position) { 26 | Note note = noteList.get(position); 27 | holder.title.setText(note.getTitle()); 28 | holder.content.setText(note.getContent()); 29 | } 30 | 31 | @Override 32 | public int getItemCount() { 33 | return noteList == null ? 0 : noteList.size(); 34 | } 35 | 36 | static class NotesViewHolder extends RecyclerView.ViewHolder { 37 | TextView title; 38 | TextView content; 39 | NotesViewHolder(View v) { 40 | super(v); 41 | title = v.findViewById(R.id.title); 42 | content = v.findViewById(R.id.content); 43 | } 44 | } 45 | 46 | public void setNoteList(List noteList) { 47 | this.noteList = noteList; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.3" 6 | 7 | defaultConfig { 8 | applicationId "com.pentabin.livingroom" 9 | minSdkVersion 23 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "1.0" 13 | 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | compileOptions { 25 | sourceCompatibility 1.8 26 | targetCompatibility 1.8 27 | } 28 | 29 | } 30 | 31 | dependencies { 32 | implementation fileTree(dir: 'libs', include: ['*.jar']) 33 | 34 | implementation 'androidx.appcompat:appcompat:1.1.0' 35 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 36 | testImplementation 'junit:junit:4.12' 37 | androidTestImplementation 'androidx.test.ext:junit:1.1.1' 38 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 39 | 40 | implementation project(path: ':LivingRoom-annotations') 41 | annotationProcessor project(path: ':LivingRoom-compiler') 42 | implementation project(path: ':livingroom') 43 | implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' 44 | implementation 'androidx.lifecycle:lifecycle-livedata:2.2.0' 45 | 46 | implementation "androidx.recyclerview:recyclerview:1.1.0" 47 | implementation "androidx.cardview:cardview:1.0.0" 48 | 49 | implementation 'androidx.room:room-runtime:2.2.5' 50 | annotationProcessor 'androidx.room:room-compiler:2.2.5' 51 | 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 22 | 23 |