This issue appears on BB 9800 when the device/emulator is in full touch mode (closed slider).
I don't know if the issue appears on other TS devices (I have only this device).
I have the MainScreen (MS) object (where almost entire application is working here), and some "dialogs" (D1, D2) for displaying some details, which both extend FullScreen, and I display them with UiApplication.getUiApplication().pushScreen(this), and I close them with UiApplication.getUiApplication().popScreen(this);
D1 - some details
D2 - an EditField for adding some comments
If I push only one "dialog" MS -> D1 or MS -> D2 all things are ok.
if I push 2 "dialogs" MS -> D1-> D2, if I press on virtual keyboard, there are some visual mess (like no painting areas), only the first pressed key is taken from VirtualKeyboard (into edit); if I dissmiss this D2 (with popScreen()), the D1 has visual issues (again, like no painting areas)...
D1:
public class DialogBase extends FullScreen
{
public DialogBase()
{
super(new VerticalFieldManager(), Field.NON_FOCUSABLE);
. . .
}
. . .
public void open()
{
UiApplication.getUiApplication().pushScreen(this);
}
public void closeAndExit()
{
UiApplication.getUiApplication().popScreen(this);
}
}
D2 is very similar to D1 (the same constructor + open + close)
Do you have an ideea?
Thank you,
Tibi.
Related
I've been trying to access the Badger2040 buttons through Tinygo and not having any luck (I have succeeded in CircuitPython before).
When I try to change the led state based on Button A, the led is switched on and never switches off:
package main
import (
"machine"
"time"
)
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
button_a := machine.BUTTON_A
button_a.Configure(machine.PinConfig{Mode: machine.PinInputPullup})
for {
led.Set(button_a.Get())
time.Sleep(time.Second / 4)
}
}
If I change the led.Set to pass in !button_a.Get() then the led is always off.
It appears that button_a.Get() is always returning true.
Does anyone have any ideas please?
I based this on the included TinyGo examples (not for the Badger2040) - which used PinInputPullup - but it turns out the Badger2040 needs to use PinInputPulldown, i.e. configure the button like this:
button_a.Configure(machine.PinConfig{Mode: machine.PinInputPulldown})
Note that this works for the up/down/a/b/c buttons. The user button also toggles, but is inverted, i.e. returns true when not pressed.
I know that it is not the best title in the world but let me explain the problem first,
I have implemented a Glance widget with some items in it and when you press them, the app should be opened and navigated to the specific screen given via deep-link in NavHost. However, sometimes the page navigated via deep-link works and sometimes not. When it is not, got an error something like this:
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4d in tid 2486 (DefaultDispatch), pid 2259
I believe this is a segmentation error as I pass the argument from widget to app by using Gson()toJson(itemData). However, I do not understand why this sometimes works as I use the same thing for each item in order to open the app and navigate to the details screen.
The other thing is when the app does not crash with that error, the app directly opens the details page rather than showing the splash screen first and navigating to the detail screen.
In the end, how can I solve that segmentation error during deep-linking and how can I prepopulate the backstack(or just first navigate to splash and then to detail screen)?
For some more information, there is a sample code:
// CODE IN GLANCE WIDGET
#Composable
private fun Item(
model: ItemData,
) {
val intent = Intent(
Intent.ACTION_VIEW,
"${URL}/${Screens.DetailScreen.passArgument(model.toDetailData())}".toUri() // pass model just converts detailData to string with Gson().toJson()
)
Text(
text = model.title ?: "",
modifier = GlanceModifier
.clickable(
actionStartActivity(
intent
)
)
)
}
// CODE IN NAVHOST
NavHost(
// navhost parameters such as route, controller, start destination
// where start destination set to Splash Screen
){
composable(/*routeOfSpashScreen*/){SplashScreen}
.
. // These dots are some sub-navGraphs
.
.
detailScreenNavGraph()
}
// DETAIL SCREEN SUB-NAVGRAPH
fun NavGraphBuilder.detailScreenNavGraph(
controller: NavHostController? = null // This is optional and does not relate to problem
) {
navigation(
startDestination = Screens.DetailScreen.route,
route = DETAIL_SCREEN_ROUTE
) {
composable(
route = Screens.DetailScreen.route + "/{model}",
arguments = listOf(
navArgument(
name = "model"
) {
type = DetailDataNavType()
},
),
deepLinks = listOf(
navDeepLink {
uriPattern = "${URL}/" + Screens.DetailScreen.route + "/{model}"
}
)
) {
val model = it.arguments?.getParcelable<DetailData>("model")
if (model != null) {
DetailScreen(
model,
controller = controller ?: LocalNavigationManager.current
)
}
}
}
}
Any help or advice is appreciated.
Since no one is answering and I have solved my problem, I believe a proper explanation is needed if someone gets stuck like me.
What are receivers and how do they work?
Receivers are like singleton classes that control each widget, not only the widget called by. If you have to update the widget, you should have its proper GlanceId; currently, there is no official way to get that id. However, there is a hacky way such as:
// Add this to your callback and to your intent before broadcasting it
// so you can access the widget's GlanceId
val id = glanceId.toString().filter { it.isDigit() }.toInt()
Since you have the id in your onReceive of your receiver, you can properly update your widget
Why I am having a "Cannot marshall a parcel that contains binder objects" error?
This is because you are using LazyRow or LazyColumn and during drawing, as bitmaps contain smart components named binders which take extra space in your memory during drawing, you exceed the available limit given to the widget for memory. I have tried to reduce the size of the image and compress it as much as possible and it loads with the most disgusting images. However, if you use a Column instead of LazyColumn' you can easily render any image, at least this is what I have experienced.
How are these questions relate to my problem?
As I was trying to click an item on the widget that lazily loaded, I believe that I tried to access a memory space that has been either collected or freed during or after the widget is drawn. The other possibility is there was no memory space for the app to be launched and during launch, the memory is cleaned and I tried to access the deleted memory part. Either way, these are just assumptions and feel free to correct me if I am wrong.
What about the backstack part?
I totally changed the deeplink handling mechanism of the app such as:
if(appIsClosed)
start splash -> navigate home -> open the desired page from here
// pass the received intent parameters throughout navigation hierarchy
else
handle as deep-link to home -> open desired page from here
For sample I have one order that my user can add one store and in each store a lot of itens:
Amazon
- cup - $ 1
- notebook - $ 3
- $ 4 Ebay
- bike - $ 10
- boat - $ 13
- $ 23
Total order: $ 27 [Button to send the order]
And in my project I have 3 components:
CartView - (show the total from order and a button)
- StoreView (show de Store name, and total)
---StoreitemView (show the item and the button to remove)
lets to the doubts:
1 - The best way to show thats lists are usingo a GRID with one ROW? some like this:
Grid<StoreView> myGrid = new Grid();
myGrid.addComponentColumn(this::createStoreView).setAutoWidth(true);
or Its best to use a for just like this:
Div myDiv = new Div();
for(Store store in StoreList){
muDiv.add(new StoreView(store);
}
2 - How can I pass event to parent? so when my user click a button at StoreItemView I need to emit that event to my CartView(passing to StorView, and go to CarView to update the values and recreate the cart)
tks
Layout
The layout depends on how many stores and items you expect. If the number is low, just looping through and adding components is a decent approach.
If you have many items, using a Grid with one column is a better approach, as all items aren't rendered at once. An even better approach might be the IronList, or since Vaadin 21 the VirtualList.
If your views are complex with a lot of components, it's a good idea to use a TemplateRenderer instead of a ComponentRenderer. If writing views in HTML instead of Java is not your cup of tea, you can keep on using the ComponentRenderer, especially if performance seems to be good.
If there are a lot of items per store, you can consider having a virtual list for the store items inside the store also. Especially if there are only a few stores.
Events
There is no correct answer here. It seems like your StoreView and StoreItemView are tightly coupled, so the communication can be tightly coupled too. For example, the StoreItemView can expose the button directly with a getRemoveButton() method.
I would use the ComponentEvent for the removal event, something like the code below. Your logic for how the StoreItemViews are created would be different, and you could add a method in the StoreView for adding the event listener. You might want to add some data to the event, too.
public class StoreView extends HorizontalLayout {
public StoreView() {
// Create your store items as you see fit
StoreItemView storeItemView = new StoreItemView();
storeItemView.getRemoveButton().addClickListener(e -> {
remove(storeItemView);
fireEvent(new StoreItemRemovedEvent(storeItemView));
});
add(storeItemView);
}
public static class StoreItemRemovedEvent extends
ComponentEvent<StoreItemView> {
public StoreItemRemovedEvent(StoreItemView source) {
super(source, false);
}
}
}
public class CartView extends VerticalLayout {
public CartView() {
StoreView storeView = new StoreView();
ComponentUtil.addListener(storeView, StoreView.StoreItemRemovedEvent.class, e ->
Notification.show("Store item removed"));
add(storeView);
}
}
I'm trying to display text on 16x2 display using a Nodemcu board. I have connected the display using a serial connector to board like below.
Vcc => 3v Pin
GND => G pin
SCL => D1 pin
SDA => D2 pin
This is the code I have tried
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Hello world");
lcd.setCursor(1,0);
lcd.print("ESP32 I2C LCD");
}
void loop() {}
I was able to compile this code successfully and save it to the board using Arduino IDE, but nothing display on the screen, the backlights are working fine.
Does anyone know what is going on?
the example I followed https://www.instructables.com/id/Interface-LCD-Using-NodeMCU/
Try to change
lcd.backlight();
to
lcd.setBacklight((uint8_t)1);
I'd like to get the keyboard input of a user in Websharper for an entire page (or whatever gets me closest), and I can't see any nice way of doing this.
I've attempted something along the lines of
JQuery.Of("document").Keyup(fun _ _ -> Window.Self.Alert("boo"))
But I keep running into a lot of NotImplementedExceptions. Are these really not implemented? Or am I hitting some weird edge case because I'm going against the grain?
Update:
I've got version 2.4.85.235 installed from nuget, if that means anything to anyone. I'm also using VS 2012.
I've also tested with a fresh sitelets templated site from VS 2010, and I see the same thing. I've installed the latest package from the WebSharper site.
Make sure that you're not calling client-side methods that are not implemented on the server. If that's the case separate client and server code, display the involved elements and invoke the JavaScript through the Web Control mechanism and use "html", "body" or Dom.Document.Current as a selector. Below is a sample for displaying an alert every time the enter key is pressed:
module Client =
open IntelliFactory.WebSharper
open IntelliFactory.WebSharper.Html
open IntelliFactory.WebSharper.JQuery
[<JavaScriptAttribute>]
let paragraph () =
P [Text "Press the Enter key to display an alert box."]
|>! OnAfterRender (fun x ->
JQuery.Of("html").Keydown(fun _ event ->
match event.Which with
| 13 -> JavaScript.Alert "Enter key was pressed."
| _ -> ()).Ignore)
type ParagraphViewer () =
inherit Web.Control()
[<JavaScript>]
override this.Body = paragraph () :> _