mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
add ability to send typed actions in demo application
commit_hash:3fcdd7a4d76f8c2bb94ee371f62d3112f688e9cf
This commit is contained in:
+8
-1
@@ -23,6 +23,7 @@ import com.yandex.div.core.DivViewFacade
|
||||
import com.yandex.div.core.experiments.Experiment
|
||||
import com.yandex.div.core.util.SafeAlertDialogBuilder
|
||||
import com.yandex.div.core.view2.Div2View
|
||||
import com.yandex.div.data.DivParsingEnvironment
|
||||
import com.yandex.div.font.YandexSansDisplayDivTypefaceProvider
|
||||
import com.yandex.div.font.YandexSansDivTypefaceProvider
|
||||
import com.yandex.div.internal.Assert
|
||||
@@ -283,7 +284,13 @@ class Div2ScenarioActivity : AppCompatActivity(), Div2MetadataBottomSheet.Metada
|
||||
.setPositiveButton("Perform action") { _, _ ->
|
||||
val action = editText.text.toString()
|
||||
preferences.edit().putString(KEY_DIV2_ACTION_URL, action).apply()
|
||||
actionHandler.handleActionUrl(Uri.parse(action), div2View)
|
||||
try {
|
||||
val env = DivParsingEnvironment(ParsingErrorLogger.LOG)
|
||||
val jsonObject = JSONObject(action)
|
||||
actionHandler.handleAction(DivAction(env, jsonObject), div2View, div2View.expressionResolver)
|
||||
} catch (e: JSONException) {
|
||||
actionHandler.handleActionUrl(Uri.parse(action), div2View)
|
||||
}
|
||||
}
|
||||
adb.create().show()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user