How to save scrolling position of recyclerview list by updating RecyclerViewAdapter per second - android-recyclerview

(notifyDataSetChanged in onBindViewHolder is not working to update whole list per second . So I have updated list by creating new adapter per second time interval .)
To update counter and other chat data I have executed below lines periodically per second. It is getting scrolled up again and again.
So how to save scrollposition of the list even if it is updated periodically.
mAdapter = new ChatInfoRecyclerViewAdapter(getDataSet1());
//mAdapter.notifyDataSetChanged();
mRecyclerView.setAdapter(mAdapter);

Related

odoo 15 List View data is not getting saved when we directly change the Search Filter

My Timesheets is displaying my time sheets by default in list view and then i added a new Record in List View and instead of clicking Save button or outside, directly removed the MyTimesheets filter from search, now odoo loads all the time sheets, but not saved my new record data. How can i fix it to save the new record before loading the list after filter got removed ?

Recyclerview Notifydatachange For only one item

I have a Recyclerview with a long list of items. One Item have a TextView, this TextView need change every 0.5 seconds, so i need refresh. All my code works perflecly but If I refresh all my items (notifyDataChange), its to slow. So I need refresh only this item for a good perfomance of my app. Its possible?
AdaptadorRecyclerView.notifyDataSetChanged();
Use adapter.notifyItemChanged(int position, Object payload). You can mention the TextView's position and value with payload parameter. If you want to learn more about it please refer [this link](https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html#notifyItemChanged(int, java.lang.Object)).

Displaying data on an laretdialog using titanium and remote database

i'm developping a mobile app using titanium appcelerator. in my app i have a tableview contains list of persons' name retrieved from remote database. when i click on each row of my tableview, i want to display some other data from remote database (the activity of each person of my list). i used a php web services to do this. i used a loop "For" to display data, but the problem that when i click on a row all data (all activity of persons are displayed). i tried to do this whitout loop, i can display now only one data (on click, only the activity of the first person is displayed for all rows of my tableview). i do not know what exacly should i put as condition or witch loop must be used for this.
Any help please. this is a screenshot of my tableview and the alert dialog: https://www.dropbox.com/s/osan0bb4i6s2bqd/scrennShot.png
You have to add the click EventListner to TableView..
Hope it will works for you...
and Pass the data object to TableRow when its created
var row = Ti.UI.createTableViewRow({
height : Ti.UI.Size,
left : 0,
obj : your_data[i] // From the array etc for specific row .
});
Add EventListner
e.rowData.obj;

How can I add row of components to a GUI when a button has been pressed?

I'm putting together an app where a user can record information about like a sale of an unknown number of items in a business. My question is based on recording the quantity, name, individual price and total price of each item sold in a sale. I've already coded a java computer program where I have a table available on the GUI, the user records the information of one item in a table and if they need more rows there is a button which can be pressed each time a new row is needed. I'm wondering:
A) is there a table component I can use in Codenameone on the GUI and
B) can I have the same concept of pressing a button in order to add a new row to the table?
If this isn't possible, because I've had no luck while researching this topic, does anyone have any suggestions of how I can record an unknown number of items for a sale on one GUI page?
UPDATE:
Here is the code which is in the method that adds a new row to the table container.
protected void onSale_ButtonAction(Component c, ActionEvent event) {
Container tbl = findTbl(c);
TextField txt = new TextField();
ComboBox cmb = new ComboBox();
TextField txt2 = new TextField();
tbl.addComponent(txt);
tbl.addComponent(cmb);
tbl.addComponent(txt2);
tbl.animateLayout(300);
}
The button does add the new row but it changes the table layout by resizing all the components and some aren't visible on the screen. I have used the setWidth() method after declaring each component in hope of changing the size of the component but with no luck. How can I solve this problem, so that the new components are the same size as the very first row of components in the table?
And also, after a random number of rows have been filled in with information, i'd like to read this info and save it to a database. I've done this in a computer java program in a JTable and stored the data into a 2D array and then read from the array into the database. Is this method applicable for the container above?
There are "table components" specifically Table, TableLayout & GridLayout.
Adding a row to each of them is somewhat different, lets assume you use a TableLayout container with the container being tbl and having 2 columns:
tbl.addComponent(cmp1);
tbl.addComponent(cmp2);
tbl.animateLayout(300);
Adds both components and animates them into place.

Recreated active item doesn't get added to any container

I've encountered this in a couple spots in my app:
Let's assume I have 3 items in a carousel. I'm viewing item #2. I need to reload that carousel, so I do the following operations:
Ext.getCmp('carousel_name').removeAll();
var new_objects = (bunch of code that recreates the carousel's objects again, with the same IDs; this is the same code that was used to create the objects the first time, so it is likely not the issue)
Ext.getCmp('carousel_name').add(new_objects);
In the carousel object items list (Ext.getCmp('carousel_name').getItems()), all three items exist. However, only #1 and #3 (the ones which weren't the active item prior to the carousel reload) actually appear. #2 presents a blank white screen, and in the HTML nothing exists except for the item shell markup (no code that I've written shows up). If I do Ext.getCmp('carousel_item_2').show();, the item does appear, but is full-screen, and I get the error:
[DEPRECATE][Ext.Panel#show] Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component);
When I try to manually add that item to either the Viewport or the carousel, nothing is fixed.
I've tried inserting a dummy item in-between removal and reinsertion of new items, that doesn't work. Nor does hiding the entire Viewport before doing any of this and showing it afterwards. Nor does using setItems() rather than add(). Nor does doing Ext.getCmp('exercises_carousel').each(function(item){ item.destroy(); }) rather than removeAll(true)
I don't believe the issue is the code snippet that re-creates the new items, since it's the same code that's used to create the items the first time, and there are no issues on the first creation.
Pretty stumped here.
EDIT: I've found that if, when I get to the end of the carousel, if I add a empty item after the last item in the carousel, I don't get the blank item at N-2. No clue why this is the case. Still not a real solution, it's a hack.
Assuming there are no problems in your code snippet to re-populate new items in your carousel, then the only problem is because of this issue (I'm not sure whether it's a bug in Sencha Touch 2.1 or not but it does exist): when you call yourCarousel.removeAll() and add some new items again, your carousel will NOT set proper active item.
I've seen a similar problem and I added this after adding new items, which works:
carousel.setActiveItem(0);
Alright, this is a hack, so if anyone has a legitimate solution, that would be awesome. But the hack does work, so here it is:
Add an empty item in the carousel
Set active item to the new empty carousel item
Destroy all carousel items
Recreate (and re-add) all of the items
In code:
Ext.getCmp('carousel_name').add({});
Ext.getCmp('carousel_name').setActiveItem(Ext.getCmp('carousel_name').getMaxItemIndex());
Ext.getCmp('carousel_name').removeAll(true);
var new_objects = (bunch of code that recreates the carousel's objects again, with the same IDs)
Ext.getCmp('carousel_name').add(new_objects);
EDIT: As it turns out, this for some reason works 90% of the time; for some unknown reason 10% of the time it still doesn't get inserted. The only way to guarantee that all items get inserted correctly is to clear the entire viewport (Ext.Viewport.removeAll(true)), recreate all of the original items in the viewport, and reinsert them. I'd rather not have to do this every time an item doesn't get inserted.