RecyclerView items have an icon that have conditional databinding for visibility but it is not refreshing - android-recyclerview

I have a recyclerview that contains a list of pre-defined UI layout elements. In the pre-defined UI layout, there is an icon that is visible if the item is a type of project. If it's not that type, it is not visible. When the user enters selection mode, I set a custom variable in the adapter to hide this icon on all items, however it is not working.
I've tried using DiffUtil callback for updating the contents (i.e. returning false for contentsIsSame when it's the one with visible icon on status change), and I see it flicker, but for only one row, and it reverts.
I've tried using notifydatasetchanged, also invalidateAll, neither works.
I looked on internet for anything that is similar to my issue, but was unable to find any solutions that worked.
In the pre-defined UI layout XML for each row:
<variable
name="isSelecting"
type="boolean"/>
Then in the visibility binding (omitted other attributes):
<ImageView
app:visibleGone="#{project.isIconVisible && !isSelecting}"/>
In RecyclerView.Adapter class code that creates the list:
listItemBinding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_project_list, parent, false);
When the selection button is pressed, this is called:
public void setIsSelecting(boolean isSelecting){
listItemBinding.setIsSelecting(isSelecting);
This is where I tried different methods, such as listItemBinding.invalidateAll().
If I manually set isSelecting to true or false, before the list is populated, it correctly shows/hides the icons. It's just not updating when it's changed.

After digging, I realized that listItemBinding was one individual item, not the entire list. I then found this: RecyclerView - get all existing views/viewholders
I realized that I was looking at the wrong place to set the isSelected value, and it was supposed to go into onBindViewHolder, then just call notifyDataSetChanged() and it'll handle the rest.

Related

Treelist in DevExpress (how to use Focus Change event)

I am new using Dev Express I want to use a (devexpress) TreeList as a menu in my application (vbnet). I don't know how to make a node clickable to go to a form.
Please find below the treelist that I inplement
Thx in advance
First go through the documentation: Tree List to know that how this control works and then implement data in the tree list then do navigation stuff in below manner:
To respond to change in node selection, you can handle the TreeList.SelectionChanged event. To use it as Menu then you must set TreeListOptionsSelection.MultiSelect property to false. The SelectionChanged event fires each time a node is selected or deselected in such a case.
Then you can obtain the focused node using the TreeList.FocusedNode property. Then, use its TreeListNode.GetValue method to obtain a value of a specific column.
example code in c#:
private void treeList1_SelectionChanged(object sender, EventArgs e) {
//Write your code to open a form dialog after getting information
// using the required condition that you have
Form form = GetNavigationFormForNode(treeList1.GetDisplayText(columnDep));
if(form != null)
{
form.ShowDialog();
}
}
In case of fouused Node concern:
I suggest you go through documentation section "Respond to Focus Movement" of TreeList. Then you can respond to moving focus between nodes by handling the TreeList.FocusedNodeChanged event.
The event handler receives an argument of type FocusedNodeChangedEventArgs containing data related to this event. There you can get the current Tree List node from the Node property.
Reference:
How can I get data record for focused row in TreeList?
How to get tree list selected node text?
For using navigation bar for single form implementation then check it:
How can I use office navigation bar like backstageview in winforms?

Dojo dijit tree hide expand icon

I've got a dijit Tree which is populated via a store wrapped in Observable, essentially the example here: http://dojotoolkit.org/reference-guide/1.10/dijit/Tree.html#id7 (Not that the example actually runs from the dojo site though: unless that's just my browser).
It's working well and I can expand and collapse items. However, it displays an expand icon even for the last item in a hierarchy - i.e. an item that doesn't have any children. When you try and expand such an item, it seems to realise this and the expand icon then disappears.
Does anyone know of how to supress the expand icons from appearing in the first place?
Thanks!
Implement the mayHaveChildren() method of the model:
Implementing logic here avoids showing +/- expando icon for nodes that
we know don't have children. (For efficiency reasons we may not want
to check if an element actually has children until user clicks the
expando node)
This method inputs one of your items and outputs true if it can be expanded; false otherwise.

Force reapply of ItemTemplateSelector in WinRT

I have a GridView as my zoomed out view in a SemanticZoom control. This GridView uses a custom DataTemplateSelector as the ItemTemplateSelector. It shows an item for each content group that my app shows.
The template is different depending on whether the group is empty or not. This works fine on load, but it doesn't update when a group becomes empty or stops being empty.
I've found that the ItemTemplateSelector is only run when the page is first shown. How can I force the DataTemplateSelector get run again.
The WPF questions on this topic all suggest triggers, but these aren't available in WinRT XAML.
I've found an answer to a similar WPF question that answers this in a way that works in WinRT:
https://stackoverflow.com/a/11327087/31569
Basically you set the ItemTemplateSelector to null and then set it again. Like this:
var templateSelector = MyGroupView.ItemTemplateSelector;
MyGroupView.ItemTemplateSelector = null;
MyGroupView.ItemTemplateSelector = templateSelector;
This works, but happy to be told if there is a better way to do this.
I find it easier to just just remove the item in need updating from the collection and adding it back. This forces the GridView or ListView to apply the template. This is easy to do in MVVM world.
var itemToReload; //The object who's template needs updating
var reloadIndex = this.SomeCollection.IndexOf(itemToReload);
this.SomeCollection.Remove(itemToReload);
this.SomeCollection.Insert(reloadIndex, itemToReload);
One thing to note, is that if the item is a "Selected" item, you'll need to reapply that selection.

Is calling doLayout() method a must after adding child to a parent?

In our application, there is a tabpanel in which we are adding/removing the panel dynamically.
The panels get added at the click of a menu item by the following code in menu handler:
Ext.getCmp('mainTabPanelId').add(getPanel());
Here getPanel() method returns the panel after creating it.
Assuming that the id of main tab panel is mainTabPanelId and that of the child panel is panelId, in this context, could someone guide at the following:
Is it necessary to call doLayout() on mainTabPanel after the add method?
Should the doLayout() be called on the mainTabPanel or on the newly added child panel, that is, Ext.getCmp('mainTabId').doLayout() or Ext.getCmp('panelId').doLayout()?
Will a call to doLayout() take care of all the issues related to rendering, like scrollbars esp.?
The method getPanel() should return an already created panel (using Ext.create) or should it return a config object (having xtype:'panel')? Which one should be preferred for better performance keeping time in mind?
AbstractContainer::add()
<...> If the Container was configured with a size-managing layout manager, the Container will recalculate its internal layout at this time too.
So you don't have to do 1 — 3 because:
AbstractContainer::doLayout()
<...> The framework uses this internally to refresh layouts form most cases.
AbstractContainer::defaults
For defaults to work, the child items must be added using {xtype: ......} NOT using Ext.create("widget.type",{}) © roger.spall
So I'd prefer return configuration object instead of components itself.

Dojo : show() and hide() .... HOW?

I have a container element in which I create on the fly/place() a form, then another one..etc.
My goal is to switch between them i.e. hide all and show only the active form.
It hides alright, but I can't show the active back.
I tried using:
.style.display(none<->block) and visibility(visibility<->hidden)
dojo.style(...)
resize() and startup() after the changes
Several other variants i found on Internet from old dojo's
Nothing works.
/I need it to work with display, so that it does not occupy space./
Can you tell me what is the correct way to show and hide with dojo()
Also looked at this one :
How do I dynamically show and hide an entire TabContainer using DOJO?
Does not work.
The pseudo code I use is something like this :
....
//find or create the FORM element
form = dijit.byId(...);
if(typeof form != 'object') {
form = dojo.create('form', ....);
dojo.place(form,'containerx','last');
}
//hide all
dojo.query('#containerx > *').forEach(function(item){
dojo.style(item, 'visibility','hidden');// and all other variants i mentioned
})
//show only the current form
dojo.style(form, 'visibility','visible');
//if the dojo form obj was already created, then skip it
if (this.form_obj) return;
....build the form and the elements....
this.form_obj.startup()
thanx
I just answered the question in that thread you referenced in your question a few minutes ago. Basically it involved getting jQuery involved. Works great for me. I have all the tabs created statically (as opposed to programatically) and I'm able to manipulate whether they are shown or hidden with the help on jQuery. All the code any everything is in my post here:
How do I dynamically show and hide an entire TabContainer using DOJO?
Sounds like you might be looking for StackContainer functionality.
Just set things up so that the StackContainer has the dijit.form.Forms as children and you can use the selectChild method to choose what form to display.