Last active
December 25, 2015 02:39
-
-
Save luisbebop/6904316 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package org.scaloid.hello | |
import org.scaloid.common._ | |
import android.graphics.Color | |
import org.jamruby.core.Jamruby; | |
import org.jamruby.mruby.MRuby; | |
import org.jamruby.mruby.ParserState; | |
import org.jamruby.mruby.Value; | |
object TestScalaObject { | |
val TEST_SYMBOL = "*" | |
var ctx :SVerticalLayout = _; | |
def SetContext(c : SVerticalLayout) = { | |
ctx = c | |
} | |
def GetContext() : SVerticalLayout = { | |
ctx | |
} | |
def testMethod() : String = { | |
"LOL" | |
} | |
} | |
class HelloScaloid extends SActivity { | |
onCreate { | |
contentView = new SVerticalLayout { | |
style { | |
case b: SButton => b.textColor(Color.RED).onClick(loading()) | |
case t: STextView => t textSize 10.dip | |
case v => v.backgroundColor(Color.YELLOW) | |
} | |
TestScalaObject.SetContext(this) | |
val code = """c = JAVA.find_class("org/scaloid/hello/TestScalaObject") | |
sm = c.get_static_method("testMethod","()Ljava/lang/String;") | |
o = c.call_static(sm) | |
""" | |
// val code = """c = JAVA.find_class("org/scaloid/hello/TestScalaObject") | |
// sm = c.get_static_method("GetContext","()Lorg/scaloid/common/SVerticalLayout;") | |
// o = c.call_static(sm) | |
// """ | |
var jamRuby: Jamruby = new Jamruby() | |
var ps: ParserState = jamRuby.parse(code) | |
var ret: Value = jamRuby.run(ps) | |
STextView(ret.toString(jamRuby.state())) | |
STextView("Me too") | |
STextView("I am taller than you") textSize 15.dip // overriding | |
SEditText("Yellow input field") | |
SButton(R.string.red) | |
} padding 20.dip | |
} | |
def getInstance():String = { | |
"LOL" | |
} | |
def coolToast(s:String):String= { | |
toast(s) | |
"lol" | |
} | |
def loading() = { | |
toast("Bang!") | |
//spinnerDialog("Dialog", "working ....") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment