RecycleView Nested on a ViewPAge - android-recyclerview

I am new on android App developtment.
Somebody know how to nest RecycleView into ViewPager2?
I need to group the male and female items in separate pages. The itens are on the WEB. So on ViewPager2 page 0 I will list all males itens, and on page 1 all female items.
Inititally I am calling on MainActivity the Viewpager2 adapter. Inside this adapter I am using the onBindViewHolder method to call the RecycleView adapter.
It is working well, however the second page of ViewPager2 is not being populated since its adapter position is changing from 0 to 1 and imediately from 1 to 2 when I swipe the Viewpager2 from position 0 to 1.
Thanks.

Related

Kotlin ViewPager2 stop scrolling on specific itemId

I have ViewPager2 with 4 items. I want to prevent user to scroll right to 4th item when he is trying to swipe right from position 3 to 4, but I want him to allow scrolling left all the time. I cannot remove the last 4-th item because I use it on another fragment.
How can I do that? When I make if like this :
if(position == 3){
binding.viewPager.isUserInputEnabled = false
}
This stops mi scrolling in every direction - right as I expected and left too. I need to detect in which direction user scroll and then stop scrolling right only. Ant tips?

how can I get row Id or item position from recyclerview when it is clicked in Kotlin

I have recyclerView_main in my main_activity.xml which is holding single_row.xml in Kotlin project.
recyclerView_main is filled up with multiple rows from database.
I need to get the row ID, or position whenever I click a specific row.
is there a way to do that?
I have buttons on that row and if type setOnClickListener() there is no option for getPosition() or getId()
is there a method to do this or I am missing something here?
Thanks
Are you using an Adapter to handle that recyclerview?
Inside adapter is the place where you bind each item, there you will have and onBindViewHolder function that receives position and you can set a 'setOnClickListener' there.
Here is an example code implementing a adapter:
RecyclerView Adapter
Check the onBindViewHolder there
What do you mean by the fact that you need to acces the id from the main_activity? When you create the adapter, you also define the onClick function that you'll use in the onBindViewHolder() method.
val onClick = {movie: Movie -> doSomethingWithTheId(movie.id)}
val adapter = MoviesAdapter(movies, rowLayout, context, onClick)

PageSource() gets different code than appium inspector code

I am having a really hard time understanding the following problem, i have an app, i use appium inspector to see the elements, but when i use the elements, i get that the element is not found, therefore i printed the code using the driver.getPageSource() method, and i realized that the xml code that is created while running the app, is actually different to what appium inspector sees, what is the problem and how can it be solved? i could ask to the developers to fix it once i know the root cause, thanks in advance.
This is an example of a difference
Under < XCUIElementTypeOther name = Picture, Left Rear Corner> there are 4 more elements 2 StaticText, 2 Buttons (appium inspector) and on the the same element but in the java console, there are only 2 tags, so i do not see the 2 static text and the 2 buttons (which is what i want to click)
As you can see the code in the console is different to what i see in appium iinspector. this is for IOS app.
while (driver.findElementsById("Additional Videos").size() == 0) {
swipeScreenDown();
}
driver.getPageSource();
WebElement additionalVideos = driver.findElementByXPath("//XCUIElementTypeOther[#name=\"Picture, Left Front Corner\"]");
driver.getPageSource();
List<WebElement> idf = additionalVideos.findElements(By.className("XCUIElementTypeButton"));
driver.getPageSource();
System.out.println(idf.size());
driver.getPageSource();
idf.get(0).click();
driver.getPageSource();
Error got:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
PageSource() action can print the visual elements at the screen.
As per my understanding, You are currently performing PageSource() action when loading the screen.
You need to click at the selected element
After click on this element use PageSource() action.
You get that element in the log of the PageSource().

MVC Complex ViewModel

I need to build a sample MVC UI app using Kendo UI.
I have 2 multiselect widgets for airline names and airport names respectively and below I have a grid with airline airport data.
Now when I select airlines or airports in the multiselect, upon clicking a Fetch button, the grid should refresh.
I created a ViewModel named AirlineAirportViewModel for containing List<Airlines>, List<Airports> and List<AirlineAirports>.
I instantiate the List<AirlineAirports> in the Get action method of the controller and fill the other two lists getting distinct airline and airport values from the List<AirlineAirports>.
While posting on filter button click, I am able to get action parameters as 2 List<string> types which contain only the selected multiselect items
Instead of that, I want this action parameter of type AirlineAirportViewModel so that in future, I will be able to add more filter widgets and the number of parameters stay one only.
Now, am I approaching this in the right way ? If I need the ViewModel as action parameter, where should I store the selected items from the multiselects ?

ListView containing GridViews and ListViews

I have a requirement to create a xaml page with Semantic Zoom where the zoomed in view contains both GridViews and ListViews. I have started out with the basic Grid Application template.
In order to try to achieve this, I have made the Semantic Zoom control's zoomed in view show a list view, and the list view contains the ListView and GridView controls I need to actually show the data as ListViewItems. This works, up to a point - the issue is that the mouse-down or tap animations happen on the whole child control of the parent ListView instead of the child's elements. This sort of layout would be simple if I didn't need to support semantic zoom.
So, my question is is this the best way to achieve this sort of layout, or am I missing something. If this is the best way, is it possible to control the behaviour so that the child item elements have the correct animation effect on selection?
Additional Info
The choice of GridView or ListView is based on the type of the items in the collections. In this example, grp 1, 3 and 4 (to be shown in grids) are all collections of type NewsFull and the remainder (to show in Lists) are of type HeadlineOnly, both types inherit from NewsBase.
The page layout (zoomed in) should be something like this...
Title
grp 1 grp 2 grp 3 grp 4 grp 5
[g][g][g][g] [_list item_] [g][g][g][g][g] [g][g][g] [_list_item_]
[g][g][g][g] [_list item_] [g][g][g][g][g] [g][g][g] [_list_item_]
[g][g][g][g] [_list item_] [g][g][g][g] [g][g] [_list_item_]
[g][g][g] [_list item_] [g][g][g][g] [g][g]
where [g] is a grid view item, and [_list_item_] is a list view item.
Zoomd out view is like this...
Title
grp 1 grp 2 grp 3 grp 4 grp 5
[summary] [summary] [summary] [summary] [summary]
Perhaps you can try using the ItemContainerStyleSelector to swap out the container of the items based on the item type or similar? This way, may be you can set one group to have a wrapping layout container and another can just be a stackpanel?
the design looks reasonable to me. the issue you have is merely " is it possible to control the behaviour so that the child item elements have the correct animation effect on selection?"
the problem here is that you probably lack abstraction here regarding different levels of UI object. I would assume you wrote this big control simply using one xaml object and then messed up with the style setup. In my opinion, you will need to break your UI to these levels of components:
ZoomPage // which is essentially a list
GroupElement // which could be GRID object or list object depending on the DATACONTEXT
GroupElement // which also has a summary state.
what you specified definitely can be achieved, looks to me just the styles are not deployed properly, if indeed your control is too complex, break it down, and test them separately.
hope this helps