-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename example to example_javaOnly * add example_kotlinOnly * update to plugin style for annotation processor * remove nullable and notnull annotations * fix activity and make testrecord open * quick fix * ignore valueof warning and add example type info in log tag * update to official version of android gradle plugin * add example_kotlinJavaMix * finished kotlinJavaMix * remove "redundant public modifier" * Cleanup test imports * Cleanup example records * fix some warnings see: https://stackoverflow.com/questions/47833237/android-studio-shows-kotlin-dependency-warning-after-second-build * Update Readme.md : change code sections * Readme.md: fix 'App module build file dependencies' * Readme.md : fix typo @SkipGenerationOfRealmFieldNames to @SkipGenerationOfRealmFieldName * Readme.md: wrong annotation * Readme.md: start spliting usages JavaOnly first * Readme.md: spliting usages KotlinOnly * Readme.md: fix unnecessary non-null cast * readme.md: adjust indent of kotlin Example Queries
- Loading branch information
1 parent
c2133c5
commit b677dd7
Showing
59 changed files
with
822 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'kotlin-kapt' | ||
apply plugin: 'realm-android' | ||
|
||
android { | ||
compileSdkVersion sdk_version | ||
buildToolsVersion build_tools_version | ||
|
||
defaultConfig { | ||
applicationId "com.quarkworks.android.realmtypesafequery.example" | ||
minSdkVersion 19 | ||
targetSdkVersion sdk_version | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "com.android.support:appcompat-v7:$support_library_version" | ||
implementation project(':query') | ||
implementation project(':annotations') | ||
kapt project(':annotationprocessor') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/berbschloe/Library/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.quarkworks.android.realmtypesafequery.example"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".MainActivityJavaCallMix"></activity> | ||
<activity android:name=".MainActivityKotlincallMix"></activity> | ||
</application> | ||
|
||
</manifest> |
27 changes: 27 additions & 0 deletions
27
...inJavaMix/src/main/java/com/quarkworks/android/realmtypesafequery/example/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.quarkworks.android.realmtypesafequery.example | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.widget.Button | ||
|
||
class MainActivity : Activity() { | ||
var javaCallMix:Button? = null; | ||
var kotlinCallMix:Button? = null; | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
javaCallMix = findViewById(R.id.javaCallMix) as Button? | ||
kotlinCallMix = findViewById(R.id.kotlinCallMix) as Button? | ||
javaCallMix!!.setOnClickListener { | ||
val i = Intent(this, MainActivityJavaCallMix::class.java) | ||
startActivity(i) | ||
|
||
} | ||
kotlinCallMix!!.setOnClickListener { | ||
val i = Intent(this, MainActivityKotlincallMix::class.java) | ||
startActivity(i) | ||
} | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
.../main/java/com/quarkworks/android/realmtypesafequery/example/MainActivityJavaCallMix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.quarkworks.android.realmtypesafequery.example; | ||
|
||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
|
||
import com.quarkworks.android.realmtypesafequery.RealmTypeSafeQuery; | ||
import com.quarkworks.android.realmtypesafequery.generated.TestRecordKtFieldNames; | ||
import com.quarkworks.android.realmtypesafequery.generated.TestRecordKtFields; | ||
|
||
import java.util.Date; | ||
|
||
import io.realm.Realm; | ||
import io.realm.RealmConfiguration; | ||
|
||
public class MainActivityJavaCallMix extends AppCompatActivity { | ||
|
||
private static final String TAG = MainActivity.class.getSimpleName(); | ||
|
||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main_mix); | ||
|
||
Object f1 = TestRecordKtFieldNames.DATE_FIELD; | ||
Object f2 = TestRecordKtFieldNames.STRING_FIELD; | ||
|
||
Realm.init(this.getApplicationContext()); | ||
|
||
RealmConfiguration config = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build(); | ||
Realm.setDefaultConfiguration(config); | ||
|
||
try (Realm realm = Realm.getDefaultInstance()) { | ||
|
||
realm.executeTransaction(new Realm.Transaction() { | ||
@Override | ||
public void execute(Realm realm) { | ||
realm.deleteAll(); | ||
for (int i = 0; i < 10; i++) { | ||
TestRecordKt record = realm.createObject(TestRecordKt.class, String.valueOf(i)); | ||
record.setBooleanField ( i % 2 == 0 ); | ||
record.setByteArrayField( new byte[]{(byte) i} ); | ||
record.setByteField ( (byte) i ); | ||
record.setDateField ( new Date(i * 1000) ); | ||
record.setDoubleField ( i * 1000d ); | ||
record.setFloatField ( i * 2000f ); | ||
record.setIntegerField ( i ); | ||
record.setLongField ( i * 10L ); | ||
record.setShortField ( (short) i ); | ||
record.setStringField ( i % 3 == 0 ? null : String.valueOf(i) ); | ||
record.setIgnoredField ( new Object() ); | ||
record.setIndexedField ( "indexed value: " + i ); | ||
record.setRequiredField ( String.valueOf(i) ); | ||
} | ||
} | ||
}); | ||
|
||
Log.d(TAG, "TestRecordKt Count:" + RealmTypeSafeQuery.with(realm).where(TestRecordKt.class).count()); | ||
|
||
Log.d(TAG, "TestRecordKt Equal To 1: " + RealmTypeSafeQuery.with(realm).where(TestRecordKt.class).equalTo(TestRecordKtFields.STRING_FIELD, "1").findAll().toString()); | ||
Log.d(TAG, "TestRecordKt Equal To null: " + RealmTypeSafeQuery.with(realm).where(TestRecordKt.class).equalTo(TestRecordKtFields.STRING_FIELD, null).findAll().toString()); | ||
Log.d(TAG, "TestRecordKt IsNull: " + RealmTypeSafeQuery.with(realm).where(TestRecordKt.class).isNull(TestRecordKtFields.STRING_FIELD).findAll().toString()); | ||
Log.d(TAG, "TestRecordKt IsNotNull: " + RealmTypeSafeQuery.with(realm).where(TestRecordKt.class).isNotNull(TestRecordKtFields.STRING_FIELD).findAll().toString()); | ||
} | ||
} | ||
} |
Oops, something went wrong.