All Projects → leiyun1993 → EasyNote

leiyun1993 / EasyNote

Licence: other
使用kotlin开发的仿EMUI备忘录,使用ObjectBox框架

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to EasyNote

FlickOff
A lite movie guide app, with MVVM architecture, that lets you discover movies from TMDb.
Stars: ✭ 31 (+106.67%)
Mutual labels:  anko
learn-kotlin
🌟 Android application made with Kotlin to explain Kotlin.
Stars: ✭ 19 (+26.67%)
Mutual labels:  anko
objectbox-generator
ObjectBox Generator based on FlatBuffers schema files (fbs) for C and C++ (more languages in the future)
Stars: ✭ 30 (+100%)
Mutual labels:  objectbox
Hibiscus
Hibiscus, mobile microblogging application.
Stars: ✭ 14 (-6.67%)
Mutual labels:  anko
KBinding
A Small, Kotlin Android Databinding Library
Stars: ✭ 19 (+26.67%)
Mutual labels:  anko
DARK
Dagger 2 + Anko + Rx + Kotlin
Stars: ✭ 27 (+80%)
Mutual labels:  anko
Android-ORM-Benchmarks
No description or website provided.
Stars: ✭ 25 (+66.67%)
Mutual labels:  objectbox
ColorAlphaCalculator Kotlin
用 Kotlin 编写, 用来计算颜色透明度值
Stars: ✭ 27 (+80%)
Mutual labels:  anko
XinFramework
Android 快速开发框架 总结以往开发结合三方项目 不断更新
Stars: ✭ 21 (+40%)
Mutual labels:  objectbox
HenCoderPractice-Kotlin
HenCoder 练习项目- Kotlin 版
Stars: ✭ 26 (+73.33%)
Mutual labels:  anko
modern-android
Modern Android Project Skeleton
Stars: ✭ 17 (+13.33%)
Mutual labels:  anko
Kotlin-Example
An example for who are all going to start learning Kotlin programming language to develop Android application.
Stars: ✭ 54 (+260%)
Mutual labels:  anko
Objectbox Java
ObjectBox is a superfast lightweight database for objects
Stars: ✭ 3,950 (+26233.33%)
Mutual labels:  objectbox

EasyNote

使用Kotlin开发的仿华为手机EMUI备忘录,数据本地存储使用ObjectBox

Kotlin-ObjectBox的使用

1、工程配置

buildscript {
    ext.kotlin_version = '1.1.3-2'
    ext.objectBoxVersion = "0.9.13"
    repositories {
        google()
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "io.objectbox:objectbox-gradle-plugin:$objectBoxVersion"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" }
    }
}
apply plugin: 'kotlin-kapt'
apply plugin: 'io.objectbox'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile('org.jetbrains.anko:anko:0.10.0') {
    exclude group: 'com.google.android', module: 'android'
}
compile "io.objectbox:objectbox-android:$objectBoxVersion"
compile "io.objectbox:objectbox-kotlin:$objectBoxVersion"
kapt "io.objectbox:objectbox-processor:$objectBoxVersion"

2、配置KotlinBean--->make project

@Entity
data class Note(
    @Id var id: Long = 0,
    var type: String? = null,
    var content: String? = null,
    var date: Date? = null
)

3、使用ObjectBox(基本使用)

class App : Application() {

    lateinit var boxStore: BoxStore
        private set

    override fun onCreate() {
        super.onCreate()
        instance = this
        boxStore = MyObjectBox.builder().androidContext(this).build()
    }
}

private lateinit var noteBox: Box<Note>
private lateinit var noteQuery: Query<Note>

noteBox = (application as App).boxStore.boxFor(Note::class.java)
notesQuery = noteBox.query().order(Note_.content).build()

增、改

private fun addNote() {
    val content = contentTv.text.toString()
    val note = Note(type = type, content = content, date = date)
    if (noteID != -1L) {    //不传ID则ID自增,传入ID则为改
        note.id = noteID
    }
    noteBox.put(note)
}

noteBox.remove(note)

fun queryNotes() {      //查询全部
    val notes = noteQuery.find()
    mAdapter.setData(notes)
}

fun queryNotes(type: String) {      //查询指定type
    val builder: QueryBuilder<Note> = noteBox.query()
    val notes = builder.equal(Note_.type, type).build().find()
    mAdapter.setData(notes)
}

EasyNote预览

image image image image image

相关链接

1、GreenDao老东家的ObjectBox

2、Google 2017IO大会指定Android开发语言Kotlin

3、Anko是一个使开发Android应用更简单更快捷的库Anko

更新日志

1、升级objectBoxVersion

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].