Add a different view in between RecyclerView items without using viewholder - android

After doing a pretty long research on SO and other sites and reaching deadends, I am posting a new question. Here goes:
I have implemented a RecyclerView that uses only 1 list item type (i don't need to use multiple layout items in the recycler view based on position). The layout as shown below: box 1 in image
what i want to do is, based on some event(click or a push notification), add a different view between two items of the RecyclerView (basically anywhere within the RecyclerView list). The view as shown below. box 2 in image
The following picture depicts what I want to achieve.
the image with the list item type and view to be added
The contents of the view to be added comes from a different source that the data source passed to the RecyclerViewAdapter. so notifyDataSetChanged() or adapter.notifyItemInserted() should not be called (in my opinion).
Is there any way I can get the above mentioned result?

Related

Handle file upload progress on recyclerview item while scrolling?

I am working on a chat application. It has a chat activity similar to WhatsApp, This app has features like sending text messages and files(images/pdf/doc, etc.). We are using recyclerview for message list in chat activity. Recyclerview on chat activity has multiple view types like textview for text message and imageview for images and few other custom views for another file types like DOC and PDF. We have a custom view class for view type file. When a user sends a file (image, pdf, doc etc.) a view is created according to file type.
When a user sends a file to another user a new view is created and added to the list, we are also showing file uploading status like uploading-in-progress, uploading-failed, uploading-success on the chat item.
We are facing an issue here while a user sending multiple files to another user, and scroll the screen up and down, the views are re-cycled and the positions of views are changes, therefore while showing uploading status, we lost the older view on which the uploading starts. Now we have another view instance on that position.
Therefore, after scrolling the uploading progress is showing on another view. We just wants to show the uploading status on right place where it was before the scrolling.
We have tried out few ways like setting
recyclerview.getRecycledViewPool().setMaxRecycledViews(VIEW_TYPE_FILE, 0);
It makes recylerview to not recycle the view file type ,but it makes the recylcerview scrolling very slow.
Kindly help with a solution. Any help appreciated.
This is not how it is supposed to work. You should configure a recycled views to match the objects it represents now. If you do nothing it shows the object it represented previously. So every time you are asked to provide a view and you are given a recycled view, you need to get the corresponding object from your collection and replace all visualized information in the recycled view with the information of the object it should represent now. I assume in your case the object is a message.

Expanding recycler view items

I have gone through other questions as well but couldn't figure out something. I have a well set up RecyclerView.
I m trying this library: https://github.com/AAkira/ExpandableLayout
Now I want the items to be expandable so that they show a TextView which is different for each item.
But I can't figure out how to place itms in XML. Where to place RecyclerView and where the expandable layout? How to setup these things?
Take a look at one of the samples given in the library, it is called 'examplerecyclerview' which I think is the one you need.
These are specific files that you should watch:
RecyclerView Activity and Adapter (Java)
RecyclerView Activity (XML)
RecyclerView List Row (XML)

how to show image grid in a Drawer which has a listview inside it

In continuation with my last question
How can I make a multi-level(more than 3 level) navigation drawer in android?
What's happening: Basically I am showing filters in my navigation drawer which has children up to many levels. Whenever I click on any, it puts the selected filter at the top and shows its children below as a simple list.
What do I want: When I select a filter, I want to see the images of its children in a grid view inside the drawer(which is vertically scroll-able) just below the name of the filter. If an image is selected here, the name of this children gets added in the hierarchy list and I could see image grid of the new children. This could got upto many levels(safe to assume 4-5).
I was thinking I could make a fragment with same colors as that of the drawer and show my grid view inside it. But I lack much knowledge in it, how could I keep the fragment just below my list and inside the drawer.
Kindly provide a detailed solution. Android noob here.

How to create custom ListView like this?

I want to create a Custom listview like this the below image. I am creating a chat app, in that app have to pass text, images and video etc. see below image.
In that, when a user send/receive image in chat, if he wants to see that by clicking on the button beside that image, how to move to another activity with that image path (or) url, for showing full image, and when user clickngi on image have to show a Quick view. same way if that is video, i have to get that path (or) url to play video properly.
How to differenciate the list item depends on the item type.
If you want to show different rows for audio, image and text messages, you need to have 3 row layouts, then you will decide which row needs to be returned from your getView() of your CustomAdapter. There are two methods getViewTypeCount() and getItemViewType() of Adapter which will help your recycling the row to show up in ListView.
You will first tell that how many layouts in your ListView will be using getViewTypeCount() which tells the adapter how many row types will be there, next check what kind of data is present at that position in your data model and you return the view type from getItemViewType(), so getView() will receive the relevant recycled view (if there is any).
Here is my blog post about using 9 patch images, it demonstrate sender and receiver type of views, same can be applied for image and audio based on the item in your data model at that specific position.
You can
implement ScrollView and add views into it.
create adapter that contains all of the possible views and then decide which view to hide or to show
you can create adapter and dynamically add view into each row (in this case it's too slow).
My choise is #2 - create row view with all possible views and then decide what to hide, in this case you can save time because you won't have to inflate you views each time and you can use even ViewHolder pattern.

Technique used in the news feed screen - custom view in the "new" Google Plus app - Android

I would like to know some insights or ideas regarding the custom list like view in the new google plus updated android app. I'm specifically researching to know if this was a list view or a scroll view with inflated custom views in it.
P.S this also has a custom entry in animation when user scrolls which is giving me a doubt that this could also be a list view with custom adapter which has an animation when list items are recycled via getView.
Check the screenshot for some clear understanding.
I don't have installed this app, but at least the way how it looks could be implemented with a ListView.
A custom adapter needs to be defined, and that custom adapter will inflate the layout for every entry, in the getView() method.
The layout of every entry, or with other words the layout of each row, could be represented by a RelativeLayout with all its components: The title, the +1 button, the photo, the date, etc.

Categories

Resources