Skip to content

Commit

Permalink
Merge branch 'master' into feature/#4
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlaster committed Feb 18, 2019
2 parents a0f9e66 + 00d43d6 commit 8a4c311
Show file tree
Hide file tree
Showing 474 changed files with 2,636 additions and 50,394 deletions.
18 changes: 11 additions & 7 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
compileSdkVersion 28
defaultConfig {
applicationId "moe.tlaster.shibasample"
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
Expand All @@ -21,22 +21,26 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.7'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'

implementation "com.squareup.okhttp3:okhttp:+"
implementation "com.squareup.okhttp3:okhttp:3.13.1"

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation project(':shiba')
implementation 'androidx.recyclerview:recyclerview:1.0.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.1'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.2'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,48 +92,6 @@ class Streaming(private val dataCallback: (JsonNode) -> Unit, private val layout

var host = "http://10.0.2.2:5000/streaming"

// fun fetch(): ServerSentEvent? {
// val request = Request.Builder().url(host).build()
// val okSse = OkSse()
// return okSse.newServerSentEvent(request, object : ServerSentEvent.Listener {
// override fun onOpen(sse: ServerSentEvent?, response: Response?) {
// }
//
// override fun onRetryTime(sse: ServerSentEvent?, milliseconds: Long): Boolean {
// return true
// }
//
// override fun onComment(sse: ServerSentEvent?, comment: String?) {
// }
//
// override fun onRetryError(sse: ServerSentEvent?, throwable: Throwable?, response: Response?): Boolean {
// return true
// }
//
// override fun onPreRetry(sse: ServerSentEvent?, originalRequest: Request?): Request {
// return originalRequest ?: throw Error()
// }
//
// override fun onMessage(sse: ServerSentEvent?, id: String?, event: String?, message: String?) {
// when (event) {
// "data_changed" -> {
// dataCallback.invoke(ObjectMapper().readTree(message?.trim('"')))
// }
// "layout_changed" -> {
// if (message != null) {
// layoutCallback.invoke(message.trim('"'))
// }
// }
// }
// }
//
// override fun onClosed(sse: ServerSentEvent?) {
// }
//
// })
// }


fun fetch(): Shutdownable {
val response = client.get(host)
if (response.isSuccessful) {
Expand Down Expand Up @@ -177,7 +135,7 @@ class Streaming(private val dataCallback: (JsonNode) -> Unit, private val layout
// )
// handler.onStatus(status)
// }
} catch (e: java.io.InterruptedIOException) {
} catch (e: Throwable) {
break
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class MainActivity : AppCompatActivity() {

// host.load("list { itemLayout = text -> \$bind items = \$bind androidList }", WithListModel())

val layout = "text -> awesome(\$json hello.world \${ if (it === null) return null; return it + \" +1!\" }) "
val layout = "<text text=\"{awesome(\$json hello.world { if(it === null) return null; return it + ' +1!'; })}\"/>"
host.load(layout, dataContext.jsonNode)
input.setText(layout)
input.addTextChangedListener(object : TextWatcher{
override fun afterTextChanged(s: Editable?) {
try {
host.load(s.toString(), dataContext)
host.load(s.toString(), dataContext.jsonNode)
} catch (e: Exception) {

} catch (e: Error) {
Expand Down
4 changes: 2 additions & 2 deletions Android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.11'
ext.kotlin_version = '1.3.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:3.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
Expand Down
4 changes: 2 additions & 2 deletions Android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 25 15:57:23 CST 2018
#Fri Jan 18 13:59:42 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
6 changes: 2 additions & 4 deletions Android/shiba/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.+'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'

implementation 'org.antlr:antlr4:4.7.1'

implementation 'com.github.LiquidPlayer:LiquidCore:0.5.+'
implementation 'com.github.LiquidPlayer:LiquidCore:0.6.+'

implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.+'

Expand Down Expand Up @@ -83,7 +81,7 @@ def issueUrl = 'https://github.com/Tlaster/Shiba/issues'
def buildNum = System.getenv('TRAVIS_BUILD_NUMBER')

group = "moe.tlaster"
version = "0.0.$buildNum"
version = "0.1.$buildNum"

install {
repositories.mavenInstaller {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ class ExampleInstrumentedTest {
@Test
@Throws(Exception::class)
fun useAppContext() {
Shiba.init(InstrumentationRegistry.getInstrumentation().targetContext.applicationContext)
val result = Shiba.configuration.scriptRuntime.execute("storage.save(\"sample\", \"hello\"); storage.load(\"sample\", \"world\")")

assert(result == "hello")


// val runtime = JSContext()
//
// runtime.evaluateScript("function resolveAfter2Seconds() {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package moe.tlaster.shiba.extensionExecutor
import moe.tlaster.shiba.*
import moe.tlaster.shiba.dataBinding.ShibaBinding
import moe.tlaster.shiba.type.ShibaExtension
import moe.tlaster.shiba.type.ShibaValueType

private const val dataContextPath = "dataContext"
class BindingExecutor(override val name: String = "bind") : IExtensionExecutor {
override fun provideValue(context: IShibaContext?, extension: ShibaExtension): Any? {
val path = if (extension.value != null && extension.value.typeCode == ShibaValueType.Token) extension.value.value as String else null
val path = extension.value
val bindingPath = if (path == null) dataContextPath else "$dataContextPath.$path"
return ShibaBinding(bindingPath).apply {
source = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import moe.tlaster.shiba.common.Singleton
import moe.tlaster.shiba.converters.ShibaConverter
import moe.tlaster.shiba.dataBinding.ShibaBinding
import moe.tlaster.shiba.type.ShibaExtension
import moe.tlaster.shiba.type.ShibaValueType

private const val dataContextPath = "dataContext"
class JsonExecutor(override val name: String = "json") : IExtensionExecutor {
override fun provideValue(context: IShibaContext?, extension: ShibaExtension): Any? {
val path = if (extension.value != null && extension.value.typeCode == ShibaValueType.Token) extension.value.value as String else null
val path = extension.value
val bindingPath = dataContextPath
return ShibaBinding(bindingPath).apply {
source = context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ListMapper : ViewMapper<androidx.recyclerview.widget.RecyclerView>() {

override fun createNativeView(context: IShibaContext): androidx.recyclerview.widget.RecyclerView {
return androidx.recyclerview.widget.RecyclerView(context.getContext()).apply {
layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context.getContext(), androidx.recyclerview.widget.LinearLayoutManager.VERTICAL, false)
layoutManager = androidx.recyclerview.widget.LinearLayoutManager(context.getContext(), androidx.recyclerview.widget.RecyclerView.VERTICAL, false)
adapter = ShibaRecyclerAdapter(context.getContext())
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package moe.tlaster.shiba.mapper

import android.content.Context
import android.graphics.Color
import android.widget.TextView
import moe.tlaster.shiba.IShibaContext
import android.util.TypedValue



class TextMapper : ViewMapper<TextView>() {
override var hasDefaultProperty = true
Expand All @@ -18,6 +22,15 @@ class TextMapper : ViewMapper<TextView>() {
view.setTextColor(Color.parseColor(it))
}
}))
add(PropertyMap("size", { view, it ->
if (view is TextView && it is Number) {
view.textSize = spToPx(it.toFloat(), view.context).toFloat()
}
}))
}
}
}
}

fun spToPx(sp: Float, context: Context): Int {
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, context.resources.displayMetrics).toInt()
}
66 changes: 0 additions & 66 deletions Android/shiba/src/main/java/moe/tlaster/shiba/parser/Shiba.interp

This file was deleted.

35 changes: 0 additions & 35 deletions Android/shiba/src/main/java/moe/tlaster/shiba/parser/Shiba.tokens

This file was deleted.

Loading

0 comments on commit 8a4c311

Please sign in to comment.