From 3d8ff65af44df88ce5164747790642f23e8c86d8 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Tue, 9 Sep 2014 23:31:32 -0400 Subject: [PATCH] Bringing back Kotlin I can do manual DI for testing, other Android classes can handle interfacing with Kotlin. From my testing, interop is quite smooth. --- app/build.gradle | 5 + .../format/osisparser/VerseContent.java | 110 ------------------ .../format/osisparser/VerseReference.java | 27 ----- .../service/format/osisparser/VerseContent.kt | 29 +++++ .../format/osisparser/VerseReference.kt | 12 ++ 5 files changed, 46 insertions(+), 137 deletions(-) delete mode 100644 app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseContent.java delete mode 100644 app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseReference.java create mode 100644 app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseContent.kt create mode 100644 app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseReference.kt diff --git a/app/build.gradle b/app/build.gradle index 40d3825..99f175f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,14 +1,18 @@ buildscript { + ext.kotlin_version = '0.8.11' + repositories { mavenCentral() } dependencies { classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: 'android-sdk-manager' apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' android { compileSdkVersion 20 @@ -71,6 +75,7 @@ dependencies { compile 'com.android.support:appcompat-v7:20.+' compile 'org.apache.commons:commons-lang3:+' compile 'com.google.code.gson:gson:+' + compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" androidTestCompile 'com.jayway.awaitility:awaitility:+' androidTestCompile 'org.mockito:mockito-core:+' diff --git a/app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseContent.java b/app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseContent.java deleted file mode 100644 index 109e2de..0000000 --- a/app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseContent.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.bspeice.minimalbible.service.format.osisparser; - -import com.google.gson.Gson; - -import org.crosswire.jsword.passage.Verse; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by bspeice on 9/9/14. - */ -public class VerseContent { - private int id; - private String bookName = ""; - private int chapter; - private int verseNum; - private String content = ""; - private String chapterTitle = ""; - private String paraTitle = ""; - private List references = new ArrayList(); - - public VerseContent() { - } - - public VerseContent(Verse v) { - this.id = v.getOrdinal(); - this.bookName = v.getBook().toString(); - this.chapter = v.getChapter(); - this.verseNum = v.getVerse(); - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getChapterTitle() { - return chapterTitle; - } - - public void setChapterTitle(String chapterTitle) { - this.chapterTitle = chapterTitle; - } - - public String getParaTitle() { - return paraTitle; - } - - public void setParaTitle(String paraTitle) { - this.paraTitle = paraTitle; - } - - public List getReferences() { - return references; - } - - public void setReferences(List references) { - this.references = references; - } - - public void appendContent(String content) { - this.content += content; - } - - public void appendReference(VerseReference reference) { - this.references.add(reference); - } - - public String getBookName() { - return bookName; - } - - public void setBookName(String bookName) { - this.bookName = bookName; - } - - public int getChapter() { - return chapter; - } - - public void setChapter(int chapter) { - this.chapter = chapter; - } - - public int getVerseNum() { - return verseNum; - } - - public void setVerseNum(int verseNum) { - this.verseNum = verseNum; - } - - public String toJson() { - // Lazy load Gson - not likely that we'll call this method multiple times, so - // don't have to worry about a penalty there. - return new Gson().toJson(this); - } -} diff --git a/app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseReference.java b/app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseReference.java deleted file mode 100644 index 1d74451..0000000 --- a/app/src/main/java/org/bspeice/minimalbible/service/format/osisparser/VerseReference.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.bspeice.minimalbible.service.format.osisparser; - -import org.crosswire.jsword.passage.Verse; - -/** - * Created by bspeice on 9/9/14. - */ -public class VerseReference { - private Verse verse; - private int index; - - public Verse getVerse() { - return verse; - } - - public void setVerse(Verse verse) { - this.verse = verse; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseContent.kt b/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseContent.kt new file mode 100644 index 0000000..cfb2fae --- /dev/null +++ b/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseContent.kt @@ -0,0 +1,29 @@ +/** + * Created by bspeice on 9/9/14. + */ +package org.bspeice.minimalbible.service.format.osisparser + +import com.google.gson.Gson +import org.crosswire.jsword.passage.Verse +import java.util.ArrayList + +class VerseContent(v: Verse?) { + var id = v?.getOrdinal() ?: 0 + var bookName = v?.getName() ?: "" + var chapter = v?.getChapter() ?: 0 + var verseNum = v?.getVerse() ?: 0 + var content = "" + var chapterTitle = "" + var paraTitle = "" + var references: MutableList = ArrayList() + + public fun toJson(): String { + // Lazy load Gson - not likely that we'll call this method multiple times, so + // don't have to worry about a penalty there. + return Gson().toJson(this) as String + } + + public fun appendContent(content: String) { + this.content += content + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseReference.kt b/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseReference.kt new file mode 100644 index 0000000..d9250f4 --- /dev/null +++ b/app/src/main/kotlin/org/bspeice/minimalbible/service/format/osisparser/VerseReference.kt @@ -0,0 +1,12 @@ +package org.bspeice.minimalbible.service.format.osisparser + +import org.crosswire.jsword.passage.Verse + +/** + * Created by bspeice on 9/9/14. + */ + +class VerseReference(verse: Verse, index: Int) { + val verse: Verse = verse + val index: Int = index +}