Kodi Community Forum

Full Version: Q/Help needed: visible conditions / (Widget)Container Refresh
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.

In my Example i want to fill and  refresh a panel container  (id=5001) based on the input of an edit control (id="100002")


Which works pretty well, but once my the panel container is empty, it cant refresh due to my visible condition
xml:
<visible>[Integer.IsGreater(Container(5001).NumItems,0) | Container(5001).IsUpdating]</visible>

The simplest solution will be to get rid of the visible condition,
BUT I DONT WANT AN EMPTY AREA USING SPACE

So that leads me to try the following:

issues :
 - once numitems=0, no more refresh/visible till reload due to visible condition
 - if i add static item container seems to get numitems issue ?? (sorry i cant descripe better) 2 items flickering around - HELP NEED FIND CORRECT VISIBLE  CONDITION
           

test to resolve
 - add to content path : &amp;reload=$INFO[Window(home).Property(EmbuaryWidgetUpdate)] - no succes
 - removed vis condition (container) - ok, but group always visible unwished
 - added a static item as content - ok, but jumps around due to visible cond : 
         
!Integer.IsGreater(Container(5001).NumItems,1) | Container(5001).IsUpdating
                                       
or
           Integer.IsLess(Container(5001).NumItems,2) | Container(5001).IsUpdating

                 
                    ( + if static item is placed as second 'content' tag , container still focus static item first onfocus )




Code:

xml:

<control type="panel" id="5001">
                <description>hardcoded content artist</description>
                <left>5</left>
                <width>1600</width>
                <!-- <height max="850" min="360">auto</height>
               need to make include based on vis content,3 more ids :-(
                -->
                <height>850</height>
                <top>50</top>
                <preloaditems>2</preloaditems>
                <orientation>vertical</orientation>
                <onleft>11999</onleft>
                <onright>500160</onright>
                <onup>9000</onup>
                <ondown>5002</ondown>
                
                <scrolltime tween="quadratic">400</scrolltime>
                <autoscroll>true</autoscroll>
                
                <pagecontrol>500160</pagecontrol>
                <visible>[Integer.IsGreater(Container(5001).NumItems,0) | Container(5001).IsUpdating]</visible>
                <itemlayout height="300" width="420">
                    <control type="group">
                        <height>243</height>
                        <width>405</width>
                        <include content="HUB_Landscape">
                            <param name="colordiffuse" value="$VAR[Container_item_nf]" />
                            <param name="autoscroll" value="false" />
                            <param name="bordersize_bg" value="6" />
                        </include>
                    </control>
                </itemlayout>
                <focusedlayout height="300" width="420">
                    <control type="group">
                        <height>243</height>
                        <width>405</width>
                        <include>Item_Focus_Animation</include>
                        <control type="group">
                            <include content="HUB_Landscape">
                                <param name="colordiffuse" value="$VAR[Container_item_fo]" />
                                <param name="autoscroll" value="true" />
                                <param name="bordersize_bg" value="4" />
                            </include>
                            <include>FocusOverlay</include>
                        </control>
                    </control>
                </focusedlayout>
                <content>
                    <item id="999">
                        <description>workaround to refresh via edit,5001 shouldnt remain empty</description>
                        <label>No Results Found</label>
                        <label2 />
                        <visible>!Integer.IsGreater(Container(5001).NumItems,1) | !Container(5001).IsUpdating</visible>
                        <icon>$VAR[emptywidget]</icon>
                        <thumb>$VAR[emptywidget]</thumb>
                    </item>
                </content>
                <content target="music" limit="50">$VAR[HUB_content_artists_1]</content>
                
            </control>
...
...
...
<variable name="HUB_content_artists_1">
        <value condition="!String.IsEmpty(Control.GetLabel(100002).index(1))">musicdb://artists/?xsp=%7B%22order%22%3A%7B%22direction%22%3A%22ascending%22%2C%22ignorefolders%22%3A0%2C%22method%22%3A%22sorttitle%22%7D%2C%22rules%22%3A%7B%22and%22%3A%5B%7B%22field%22%3A%22artist%22%2C%22operator%22%3A%22contains%22%2C%22value%22%3A%5B%22$INFO[Control.GetLabel(100002).index(1)]%22%5D%7D%5D%7D%2C%22type%22%3A%22artists%22%7D&amp;reload=$INFO[Window(home).Property(EmbuaryWidgetUpdate)]</value>
        <value>musicdb://artists/</value>
    </variable>
               
Video Describe/Show Off

EDIT:
also tried refresh via button and different actions, without succes

Container(5001).Refresh , Container.Refresh(5001) , Container.Refresh
Container(5001).Update , Container.Update (5001) , Container.Update
What is control 100002? Is it a button? How is its label set?

To refresh the container, use a window property in your visible condition:
Code:
<visible>Integer.IsGreater(Container(5001).NumItems,0) | Container(5001).IsUpdating | !String.IsEmpty(Window(Home).Property(Refresh5001))</visible>

If control 1000002 is a button, you can set the property momentarily and then turn it off again onfocus/onclick etc. to make the container visible again when you update its content path.
Code:

<onfocus>SetProperty(Refresh5001,1,Home)</onfocus>
<onfocus>AlarmClock(ResetRefresh,ClearProperty(Refresh5001,Home),00:00,silent)</onfocus>

The problem with your original visibility condition is that once Container(5001).NumItems is 0 then the container never becomes visible again and so it never updates (it needs to be visible to update). Using the window property allows you to temporarily force it to be visible and thus update. Once it starts updating the Container.IsUpdating condition becomes true so the property no longer needs to be set.
(2019-10-25, 13:56)jurialmunkey Wrote: [ -> ]What is control 100002? Is it a button? How is its label set?

To refresh the container, use a window property in your visible condition:
Code:
<visible>Integer.IsGreater(Container(5001).NumItems,0) | Container(5001).IsUpdating | !String.IsEmpty(Window(Home).Property(Refresh5001))</visible>

If control 1000002 is a button, you can set the property momentarily and then turn it off again onfocus/onclick etc. to make the container visible again when you update its content path.
Code:

<onfocus>SetProperty(Refresh5001,1,Home)</onfocus>
<onfocus>AlarmClock(ResetRefresh,ClearProperty(Refresh5001,Home),00:00,silent)</onfocus>

The problem with your original visibility condition is that once Container(5001).NumItems is 0 then the container never becomes visible again and so it never updates (it needs to be visible to update). Using the window property allows you to temporarily force it to be visible and thus update. Once it starts updating the Container.IsUpdating condition becomes true so the property no longer needs to be set.

Thanks.

Its an edit control.
which should also be able to have onfocus/onunfocus/ondown actions.

i am afk now,but will try soon your method soon

To the flicker...
xml:
<control type="edit" id="100002">
                    <top>5</top>
                    <height>60</height>
                    <width>420</width>
                    <hinttext>Search me....</hinttext>
                    <texturefocus colordiffuse="white">buttons/NF_1zu5.png</texturefocus>
                    <texturenofocus colordiffuse="44FFFFFF">buttons/button_6to1_Trans.png</texturenofocus>

                    <font>MenucontrolItem</font>
                    <textoffsetx>20</textoffsetx>
                    <textoffsety>20</textoffsety>
                    <textcolor>grey</textcolor>
                    <focusedcolor>white</focusedcolor>
                    <disabledcolor>green</disabledcolor>
                    <invalidcolor>orange</invalidcolor>
                    <aligny>top</aligny>
                    <pulseonselect>no</pulseonselect>
                    <label></label>
                </control>


Quote:The problem with your original visibility condition is that once Container(5001).NumItems is 0 then the container never becomes visible again and so it never updates


Thats the reason why i try a workaround with an static item.
I would deal with that, but the issue there is the flicker.

May you got an idea about the flicker issue?

e.g.
panel 5001 stays as long it isnt empty
!Container(5001).NumItems(0)

to have it never empty i put
static content item (id=999),
only visible on
!Integer.IsGreater(Container(5001).
NumItems,1)

i assumed this will respect just the static item itself , but as soon i also get 1 result in the second content tag booth items are visible and flickering/flip araound.

xml:
<content>
<item id="999">
<description>workaround to refresh via edit,5001 shouldnt remain empty</description>
<label>No Results Found</label>
<label2 />
<visible>!Integer.IsGreater(Container(5001).NumItems,1) | !Container(5001).IsUpdating</visible>
<icon>$VAR[emptywidget]</icon>
<thumb>$VAR[emptywidget]</thumb>
</item>
</content>
<content target="music" limit="50">$VAR[HUB_content_artists_1]</content>

Thanks for taking a look Smile
@jurialmunkey 

I did the test now, onfocus on an 'edit control type' doesnt seems to work.
thats not an issue, as i can have an 'hidden' button as overlay.

the big issue there is more that i will need a chain reaction to imitate the onclick/force refresh action (e.g. set skin string) to recognize that content will be refreshed.
, which seems pretty complicatited.
Because container refreshes on 'input' or 'dialogkeyboard output' of the edit control ( $INFO[Control.GetLabel(100002).index(1)] )  not 'onclick' like a button Sad

So i need to compare strings in a loop,to recognize that content will be refreshed.
unsure if possible and if it'll be an good idea.

To set Property used as label to return $INFO[Control.GetLabel(100002).index(1)] after change

e.g.

xml:
<onfocus contidion="!String.IsEmpty(Control.GetLabel(100002).index(1)) + String.IsEmpty(Window(home).Property(EditLabel2HasChanged))">SetProperty(EditLabel2HasChanged,$INFO[Control.GetLabel(100002).index(1)],Home)
<onfocus condition="!String.IsEqual(Window(home).Property(EditLabel2HasChanged),$INFO[Control.GetLabel(100002).index(1)])">SetProperty(EditLabel2HasChanged,$INFO[Control.GetLabel(100002).index(1)],Home)</onfocus>

....

But i really like to keep 'edit control type', as it's offer pretty nice search in comparison 'button control type' method.

Hopefully the solution to resolve flicker is a thing.


kind regards
In that case, have you tried <onunload> from DialogKeyboard?

Other option is to set property by using a hidden button on focus which also then sets focus to edit control. Then have conditions onleft/onup/onback etc in the edit control to clear the property when you move back off the edit control.
Yeehaaa !

Finally got a correct/working condition.

This way i dont have to deal with set/clear propertys, can circumstance the 'flicker' issue if using static item as content + THE IMPORTANT OF AT ALL use edit control for search engine.


Strangely i can use    String.IsEmpty(Container(5004).ListitemNoWrap(0).Album) + String.IsEmpty(Container(5004).ListitemNoWrap(1).Album)
as visible condition for the static item

(while others was failing, and i dont want to deal with animations)
need slide anmiation if = String.IsEmpty(Container(5001).ListitemNoWrap(1).Artist) + Integer.IsEqual(Container(5001).NumItems,2)
                            !Control.HasFocus(5001) + String.IsEmpty(Container(5001).ListitemNoWrap(1).Artist)
wrong syntax !String.Contains(Container(5001).ListitemNoWrap(1).Control.GetLabel(100002).index(1))
wrong syntax !String.StartsWith(Container(5001).ListitemNoWrap(1).Control.GetLabel(100002).index(1))
flicker !Integer.IsGreater(Container(5001).NumItems,1) -->
flicker String.IsEmpty(Container(5001).ListItemPosition(1).Artist)
flicker String.IsEmpty(Container(5001).ListItemAbsolute(1).Artist)


e.g. for artists

<content>
xml:
                    <item id="888">
                        <description>hidden if empty workaround</description>
                        <label>No Results Found</label>
                        <label2 />
                        <visible>String.IsEmpty(Container(5004).ListitemNoWrap(0).Album) + String.IsEmpty(Container(5004).ListitemNoWrap(1).Album)</visible>
                        <icon>$VAR[emptywidget]</icon>
                        <thumb>$VAR[emptywidget]</thumb>
                    </item>
                  </content>
                <content limit="50">$VAR[HUB_content_albums_1]</content>

So, at @jurialmunkey ,
First Thanks, for taking time and answering me, even if i try now another method.
I thank you for the help.

AND may this could be also interesting for you.



The benefit of the edit control type is that it can be used to fill content dynamicaly and is more comfortable than the 'setkinstring' via button method.

So, even if you miss keyboard (e.g. most remotes ) you can click the edit to define what you wanna search,
- no need to set/clear skinstrings
- just return Control.GetLabel(id).index(1)

Working Now
https://streamable.com/6z9kw