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.
Related
I am coding a basic adaptive UI using Xamarin.Forms. I have one view with a list of items in it and if you tap one of the items, it opens up a second view which show the item details. When the app is running on a phone, I want it to show a new page with the item details while when I am on a tablet, I want for the details to be shown as another view next to the original view with the list of items. What is the correct way to do this?
So far, my idea was that I would call a method in the parent page, which would decide based on the device type whether it should open up a new page or add a view to a stack layout next to the original view. I've read though that it's not exactly clean to reference the parent page from a child viewmodel, since the page method would be called by a command from the child.
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?
Hello there guys and ladies,
Right now I'm developing a content-providing application, which should be able to get live-ticking content.
So if content is uploaded to a server, the user should get the recent news. It don't have to be imediatly. I'm more thinking of an API-Calling method, which is doing an API-Call every now and then.
But what's more important right now: The content is provided in a List. So after fetching the content i've an arraylist, which is filled with content-objects.
Those content-objects will have a timestamp.
I wanna create a timeline. The thing is, if there is new content coming in, it should be marked. for example in a different color.
So imagine a timeline, when ur looking at the content. Then you put your phone away. and after you looked at the app again, there are e.g. 4 new content-objects available. These 4 content-objects should be marked in the timeline.
Can I dynamically color a listview? or would you rather recommmend another layout-element to reach my goal?
I've never done any design aspect in Android before, so I'm quite lost in this field. Do you guys know any good tutorials or books for designing android applications.
you should use a listview, and then in your list which contains your list view object, you should just add the new elements to it, and call adapter.notifiyDatasetChanged(). this will update your list with the new items. As for the color you could add an object field called color where you could store the hex value for your row, and each time you add new items set thier color to what ever color you want, and unset the other items in the array. then in the adapter change their background color accordingly
In my application I have requirement like this.I have number of data and I need to show that data on ListView kind of layout,now I have suppose total 6pages on each pages I want to show such data.I have listed number of textview on each page.Suppose i have 7pages so i need to make book kind of layout for that i am using this Code.https://github.com/harism/android_page_curl.
with this i am able to get such effect.As mentioned in below image.
Now my issue is,As OpenGl is converting entire layout to bitmap,i am not able to handle click event of textview.Whenever i click on textview on that time ACTION_DOWN method is called.and offcourse it should be called as entire layout is converting to bitmap thus we can't handle textview click event.
for making solution of this have googled and found some trick from This issue.Here mentioned to make seperate layout for handeling click listener,but not getting what exactly i have to do,as i don't have any experience in OpenGl,so if any one have idea about this issue,any one who can guide me handle click event.
The above solutions depends on your views pages. It may not work if you use ListViews on your pages or any ScrollView, you have to retest your application performance...
What i have done to get it working, is to create an extra root parent with,FrameLayout, place on top the widget, fi.harism.curl.CurlView and add PageContainer(RelativeLayout on may app).
At run time, get the drawable of your view page (View.getDrawingCache()) , and add The real PageView(witch contains click listener) to the PageContainer. Make the PageContainer alpha to 0. You have a duplicate page (transclude) to receive the page clic, the CurlView will still handle touch events for curl.
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.