Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions packages/helloworld/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.ksp)
}

android {
Expand Down Expand Up @@ -85,34 +86,29 @@ dependencies {
implementation("com.squareup.retrofit2:retrofit:2.7.0")

// lynx dependencies
implementation("org.lynxsdk.lynx:lynx:3.4.1")
implementation("org.lynxsdk.lynx:lynx-jssdk:3.4.1")
implementation("org.lynxsdk.lynx:lynx-trace:3.4.1")
implementation("org.lynxsdk.lynx:lynx:3.5.1")
implementation("org.lynxsdk.lynx:lynx-jssdk:3.5.1")
implementation("org.lynxsdk.lynx:lynx-trace:3.5.1")
implementation("org.lynxsdk.lynx:primjs:2.14.1")

// integrating image-service
implementation("org.lynxsdk.lynx:lynx-service-image:3.4.1")

// image-service dependencies, if not added, images cannot be loaded; if the host APP needs to use other image libraries, you can customize the image-service and remove this dependency
implementation("com.facebook.fresco:fresco:2.3.0")
implementation("com.facebook.fresco:animated-gif:2.3.0")
implementation("com.facebook.fresco:animated-webp:2.3.0")
implementation("com.facebook.fresco:webpsupport:2.3.0")
implementation("com.facebook.fresco:animated-base:2.3.0")
implementation("com.github.bumptech.glide:glide:5.0.5")
ksp("com.github.bumptech.glide:ksp:5.0.5")
implementation("com.caverock:androidsvg-aar:1.4")

// integrating log-service
implementation("org.lynxsdk.lynx:lynx-service-log:3.4.1")
implementation("org.lynxsdk.lynx:lynx-service-log:3.5.1")

// integrating http-service
implementation("org.lynxsdk.lynx:lynx-service-http:3.4.1")
implementation("org.lynxsdk.lynx:lynx-service-http:3.5.1")

implementation("com.squareup.okhttp3:okhttp:4.9.0")

// add devtool's dependencies
implementation ("org.lynxsdk.lynx:lynx-devtool:3.4.1")
implementation ("org.lynxsdk.lynx:lynx-service-devtool:3.4.1")
implementation ("org.lynxsdk.lynx:lynx-devtool:3.5.1")
implementation ("org.lynxsdk.lynx:lynx-service-devtool:3.5.1")

// add xelement's dependencies
implementation ("org.lynxsdk.lynx:xelement:3.4.1")
implementation ("org.lynxsdk.lynx:xelement-input:3.4.1")
implementation ("org.lynxsdk.lynx:xelement:3.5.1")
implementation ("org.lynxsdk.lynx:xelement-input:3.5.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import android.app.Activity
import android.os.Bundle
import com.helloworld.providers.GenericResourceFetcher
import com.helloworld.providers.TemplateProvider
import com.helloworld.services.ImageUI
import com.lynx.tasm.LynxBooleanOption
import com.lynx.tasm.LynxView
import com.lynx.tasm.LynxViewBuilder
import com.lynx.tasm.behavior.Behavior
import com.lynx.tasm.behavior.ui.LynxUI
import com.lynx.xelement.XElementBehaviors

class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

var uri = ""
uri = if (BuildConfig.DEBUG == true) {
"http://10.0.2.2:3000/main.lynx.bundle?fullscreen=true"
} else {
"main.lynx.bundle"
}
var uri = "http://10.63.106.9:3001/main.lynx.bundle?fullscreen=true"
// uri = if (BuildConfig.DEBUG == true) {
// "http://10.63.106.9:3000/main.lynx.bundle?fullscreen=true"
// } else {
// "main.lynx.bundle"
// }

val lynxView: LynxView = buildLynxView()
setContentView(lynxView)
Expand All @@ -30,6 +33,12 @@ class MainActivity : Activity() {
val viewBuilder: LynxViewBuilder = LynxViewBuilder()
viewBuilder.addBehaviors(XElementBehaviors().create())

viewBuilder.addBehavior(object : Behavior("image") {
override fun createUI(context: com.lynx.tasm.behavior.LynxContext): LynxUI<*> {
return ImageUI(context)
}
})

viewBuilder.setTemplateProvider(TemplateProvider(this))
viewBuilder.isEnableGenericResourceFetcher = LynxBooleanOption.TRUE
viewBuilder.setGenericResourceFetcher(GenericResourceFetcher())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import android.app.Application
import android.content.Intent
import android.os.Handler
import android.os.Looper
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.imagepipeline.core.ImagePipelineConfig
import com.facebook.imagepipeline.memory.PoolConfig
import com.facebook.imagepipeline.memory.PoolFactory
import com.helloworld.services.GlideImageService
import com.lynx.devtoolwrapper.LynxDevtoolGlobalHelper
import com.lynx.service.image.LynxImageService
import com.lynx.service.log.LynxLogService
import com.lynx.tasm.LynxEnv
import com.lynx.tasm.service.LynxServiceCenter
Expand All @@ -23,12 +19,7 @@ class MainApplication : Application() {
}

private fun initLynxService() {
val factory = PoolFactory(PoolConfig.newBuilder().build())
val builder =
ImagePipelineConfig.newBuilder(applicationContext).setPoolFactory(factory)
Fresco.initialize(applicationContext, builder.build())

LynxServiceCenter.inst().registerService(LynxImageService.getInstance())
LynxServiceCenter.inst().registerService(GlideImageService.getInstance())
LynxServiceCenter.inst().registerService(LynxLogService)
LynxServiceCenter.inst().registerService(LynxHttpService)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class GenericResourceFetcher : LynxGenericResourceFetcher() {
) {
if (request == null) {
callback.onResponse(
LynxResourceResponse.onFailed(
LynxResourceResponse.onFailed<ByteArray>(
Throwable("request is null!")
) as LynxResourceResponse<ByteArray?>?
)
)
return
}
Expand All @@ -32,7 +32,7 @@ class GenericResourceFetcher : LynxGenericResourceFetcher() {

val call: Call<ResponseBody> = templateApi.getTemplate(request.url) ?: run {
callback.onResponse(
LynxResourceResponse.onFailed(Throwable("create call failed.")) as LynxResourceResponse<ByteArray?>?
LynxResourceResponse.onFailed<ByteArray>(Throwable("create call failed."))
)

return
Expand All @@ -49,17 +49,17 @@ class GenericResourceFetcher : LynxGenericResourceFetcher() {
)
} else {
callback.onResponse(
LynxResourceResponse.onFailed(Throwable("response body is null.")) as LynxResourceResponse<ByteArray?>?
LynxResourceResponse.onFailed<ByteArray>(Throwable("response body is null."))
)
}
} catch (e: IOException) {
e.printStackTrace()
callback.onResponse(LynxResourceResponse.onFailed(e) as LynxResourceResponse<ByteArray?>?)
callback.onResponse(LynxResourceResponse.onFailed<ByteArray>(e))
}
}

override fun onFailure(call: Call<ResponseBody?>, throwable: Throwable) {
callback.onResponse(LynxResourceResponse.onFailed(throwable) as LynxResourceResponse<ByteArray?>?)
callback.onResponse(LynxResourceResponse.onFailed<ByteArray>(throwable))
}
})
}
Expand All @@ -68,7 +68,7 @@ class GenericResourceFetcher : LynxGenericResourceFetcher() {
request: LynxResourceRequest, callback: LynxResourceCallback<String>
) {
callback.onResponse(
LynxResourceResponse.onFailed(Throwable("fetchResourcePath not supported.")) as LynxResourceResponse<String?>?
LynxResourceResponse.onFailed<String>(Throwable("fetchResourcePath not supported."))
)
}

Expand Down
Loading